1 | import {Deprecation} from '../deprecations';
|
2 | import {SourceSpan} from './source_span';
|
3 |
|
4 | export {SourceLocation} from './source_location';
|
5 | export {SourceSpan} from './source_span';
|
6 |
|
7 | /**
|
8 | * An object that can be passed to {@link LegacySharedOptions.logger} to control
|
9 | * how Sass emits warnings and debug messages.
|
10 | *
|
11 | * @example
|
12 | *
|
13 | * ```js
|
14 | * const fs = require('fs');
|
15 | * const sass = require('sass');
|
16 | *
|
17 | * let log = "";
|
18 | * sass.renderSync({
|
19 | * file: 'input.scss',
|
20 | * logger: {
|
21 | * warn(message, options) {
|
22 | * if (options.span) {
|
23 | * log += `${span.url}:${span.start.line}:${span.start.column}: ` +
|
24 | * `${message}\n`;
|
25 | * } else {
|
26 | * log += `::: ${message}\n`;
|
27 | * }
|
28 | * }
|
29 | * }
|
30 | * });
|
31 | *
|
32 | * fs.writeFileSync('log.txt', log);
|
33 | * ```
|
34 | *
|
35 | * @category Logger
|
36 | */
|
37 | export interface Logger {
|
38 | /**
|
39 | * This method is called when Sass emits a warning, whether due to a [`@warn`
|
40 | * rule](https://sass-lang.com/documentation/at-rules/warn) or a warning
|
41 | * generated by the Sass compiler.
|
42 | *
|
43 | * If this is `undefined`, Sass will print warnings to standard error.
|
44 | *
|
45 | * @param message - The warning message.
|
46 | * @param options.deprecation - Whether this is a deprecation warning.
|
47 | * @param options.deprecationType - The type of deprecation this warning is
|
48 | * for, if any.
|
49 | * @param options.span - The location in the Sass source code that generated this
|
50 | * warning.
|
51 | * @param options.stack - The Sass stack trace at the point the warning was issued.
|
52 | */
|
53 | warn?(
|
54 | message: string,
|
55 | options: (
|
56 | | {
|
57 | deprecation: true;
|
58 | deprecationType: Deprecation;
|
59 | }
|
60 | | {deprecation: false}
|
61 | ) & {span?: SourceSpan; stack?: string}
|
62 | ): void;
|
63 |
|
64 | /**
|
65 | * This method is called when Sass emits a debug message due to a [`@debug`
|
66 | * rule](https://sass-lang.com/documentation/at-rules/debug).
|
67 | *
|
68 | * If this is `undefined`, Sass will print debug messages to standard error.
|
69 | *
|
70 | * @param message - The debug message.
|
71 | * @param options.span - The location in the Sass source code that generated this
|
72 | * debug message.
|
73 | */
|
74 | debug?(message: string, options: {span: SourceSpan}): void;
|
75 | }
|
76 |
|
77 | /**
|
78 | * A namespace for built-in {@link Logger}s.
|
79 | *
|
80 | * @category Logger
|
81 | * @compatibility dart: "1.43.0", node: false
|
82 | */
|
83 | export namespace Logger {
|
84 | /**
|
85 | * A {@link Logger} that silently ignores all warnings and debug messages.
|
86 | *
|
87 | * @example
|
88 | *
|
89 | * ```js
|
90 | * const sass = require('sass');
|
91 | *
|
92 | * const result = sass.renderSync({
|
93 | * file: 'input.scss',
|
94 | * logger: sass.Logger.silent,
|
95 | * });
|
96 | * ```
|
97 | */
|
98 | export const silent: Logger;
|
99 | }
|