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