minor api changes
This commit is contained in:
parent
de68f3f375
commit
b63697548d
@ -1578,7 +1578,7 @@ impl<'a> Visitor<'a> {
|
||||
return;
|
||||
}
|
||||
let loc = self.map.look_up_span(span);
|
||||
self.options.logger.warning(loc, message);
|
||||
self.options.logger.warn(loc, message);
|
||||
}
|
||||
|
||||
fn visit_warn_rule(&mut self, warn_rule: AstWarn) -> SassResult<()> {
|
||||
|
@ -1,16 +1,18 @@
|
||||
use codemap::SpanLoc;
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// Sink for log messages
|
||||
/// A trait to allow replacing logging mechanisms
|
||||
pub trait Logger: Debug {
|
||||
/// Logs message from a `@debug` statement
|
||||
/// Logs message from a [`@debug`](https://sass-lang.com/documentation/at-rules/debug/)
|
||||
/// statement
|
||||
fn debug(&self, location: SpanLoc, message: &str);
|
||||
|
||||
/// Logs message from a `@warn` statement
|
||||
fn warning(&self, location: SpanLoc, message: &str);
|
||||
/// Logs message from a [`@warn`](https://sass-lang.com/documentation/at-rules/warn/)
|
||||
/// statement
|
||||
fn warn(&self, location: SpanLoc, message: &str);
|
||||
}
|
||||
|
||||
/// Logs events to standard error
|
||||
/// Logs events to standard error, through [`eprintln!`]
|
||||
#[derive(Debug)]
|
||||
pub struct StdLogger;
|
||||
|
||||
@ -26,7 +28,7 @@ impl Logger for StdLogger {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn warning(&self, location: SpanLoc, message: &str) {
|
||||
fn warn(&self, location: SpanLoc, message: &str) {
|
||||
eprintln!(
|
||||
"Warning: {}\n ./{}:{}:{}",
|
||||
message,
|
||||
@ -37,7 +39,7 @@ impl Logger for StdLogger {
|
||||
}
|
||||
}
|
||||
|
||||
/// Discards all log events
|
||||
/// Discards all logs
|
||||
#[derive(Debug)]
|
||||
pub struct NullLogger;
|
||||
|
||||
@ -46,5 +48,5 @@ impl Logger for NullLogger {
|
||||
fn debug(&self, _location: SpanLoc, _message: &str) {}
|
||||
|
||||
#[inline]
|
||||
fn warning(&self, _location: SpanLoc, _message: &str) {}
|
||||
fn warn(&self, _location: SpanLoc, _message: &str) {}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ pub struct Options<'a> {
|
||||
pub(crate) load_paths: Vec<PathBuf>,
|
||||
pub(crate) allows_charset: bool,
|
||||
pub(crate) unicode_error_messages: bool,
|
||||
// TODO: remove in favor of NullLogger
|
||||
pub(crate) quiet: bool,
|
||||
pub(crate) input_syntax: Option<InputSyntax>,
|
||||
pub(crate) custom_fns: HashMap<String, Builtin>,
|
||||
@ -76,32 +75,28 @@ impl<'a> Options<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
/// This flag tells Sass not to emit any warnings
|
||||
/// when compiling. By default, Sass emits warnings
|
||||
/// when deprecated features are used or when the
|
||||
/// `@warn` rule is encountered. It also silences the
|
||||
/// `@debug` rule. Setting this option to `true` will
|
||||
/// stop all events from reaching the assigned [`logger`].
|
||||
/// This flag tells Sass not to emit any warnings when compiling. By default,
|
||||
/// Sass emits warnings when deprecated features are used or when the `@warn`
|
||||
/// rule is encountered. It also silences the `@debug` rule.
|
||||
///
|
||||
/// Setting this option to `true` will stop all logs from reaching the [`crate::Logger`].
|
||||
///
|
||||
/// By default, this value is `false` and warnings are emitted.
|
||||
#[must_use]
|
||||
#[deprecated = "use `logger(&NullLogger)` instead"]
|
||||
#[inline]
|
||||
pub const fn quiet(mut self, quiet: bool) -> Self {
|
||||
self.quiet = quiet;
|
||||
self
|
||||
}
|
||||
|
||||
/// All Sass implementations allow users to provide
|
||||
/// load paths: paths on the filesystem that Sass
|
||||
/// will look in when locating modules. For example,
|
||||
/// if you pass `node_modules/susy/sass` as a load path,
|
||||
/// you can use `@import "susy"` to load `node_modules/susy/sass/susy.scss`.
|
||||
/// All Sass implementations allow users to provide load paths: paths on the
|
||||
/// filesystem that Sass will look in when locating modules. For example, if
|
||||
/// you pass `node_modules/susy/sass` as a load path, you can use
|
||||
/// `@import "susy"` to load `node_modules/susy/sass/susy.scss`.
|
||||
///
|
||||
/// Imports will always be resolved relative to the current
|
||||
/// file first, though. Load paths will only be used if no
|
||||
/// relative file exists that matches the module's URL. This
|
||||
/// ensures that you can't accidentally mess up your relative
|
||||
/// Imports will always be resolved relative to the current file first, though.
|
||||
/// Load paths will only be used if no relative file exists that matches the
|
||||
/// module's URL. This ensures that you can't accidentally mess up your relative
|
||||
/// imports when you add a new library.
|
||||
///
|
||||
/// This method will append a single path to the list.
|
||||
|
@ -189,7 +189,7 @@ impl Logger for TestLogger {
|
||||
self.0.borrow_mut().debug_messages.push(message.into());
|
||||
}
|
||||
|
||||
fn warning(&self, _location: SpanLoc, message: &str) {
|
||||
fn warn(&self, _location: SpanLoc, message: &str) {
|
||||
self.0.borrow_mut().warning_messages.push(message.into());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user