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