1 | import ts from "typescript";
|
2 | import type { MinimalSourceFile } from "./minimalSourceFile.js";
|
3 | import type { TranslatedString, TranslationProxy } from "../internationalization/internationalization.js";
|
4 | import type { IfInternal } from "./index.js";
|
5 | /**
|
6 | * List of known log levels. Used to specify the urgency of a log message.
|
7 | */
|
8 | export declare enum LogLevel {
|
9 | Verbose = 0,
|
10 | Info = 1,
|
11 | Warn = 2,
|
12 | Error = 3,
|
13 | None = 4
|
14 | }
|
15 | /**
|
16 | * A logger that will not produce any output.
|
17 | *
|
18 | * This logger also serves as the base class of other loggers as it implements
|
19 | * all the required utility functions.
|
20 | */
|
21 | export declare class Logger {
|
22 | /**
|
23 | * Translation utility for internationalization.
|
24 | * @privateRemarks
|
25 | * This is fully initialized by the application during bootstrapping.
|
26 | */
|
27 | i18n: TranslationProxy;
|
28 | /**
|
29 | * How many error messages have been logged?
|
30 | */
|
31 | errorCount: number;
|
32 | /**
|
33 | * How many warning messages have been logged?
|
34 | */
|
35 | warningCount: number;
|
36 | private seenErrors;
|
37 | private seenWarnings;
|
38 | /**
|
39 | * The minimum logging level to print.
|
40 | */
|
41 | level: LogLevel;
|
42 | /**
|
43 | * Has an error been raised through the log method?
|
44 | */
|
45 | hasErrors(): boolean;
|
46 | /**
|
47 | * Has a warning been raised through the log method?
|
48 | */
|
49 | hasWarnings(): boolean;
|
50 | /**
|
51 | * Reset the error counter.
|
52 | */
|
53 | resetErrors(): void;
|
54 | /**
|
55 | * Reset the warning counter.
|
56 | */
|
57 | resetWarnings(): void;
|
58 | /**
|
59 | * Log the given verbose message.
|
60 | *
|
61 | * @param text The message that should be logged.
|
62 | */
|
63 | verbose(text: string): void;
|
64 | /** Log the given info message. */
|
65 | info(text: IfInternal<TranslatedString, string>): void;
|
66 | /**
|
67 | * Log the given warning.
|
68 | *
|
69 | * @param text The warning that should be logged.
|
70 | */
|
71 | warn(text: IfInternal<TranslatedString, string>, node?: ts.Node): void;
|
72 | warn(text: IfInternal<TranslatedString, string>, pos: number, file: MinimalSourceFile): void;
|
73 | /**
|
74 | * Log the given error.
|
75 | *
|
76 | * @param text The error that should be logged.
|
77 | */
|
78 | error(text: IfInternal<TranslatedString, string>, node?: ts.Node): void;
|
79 | error(text: IfInternal<TranslatedString, string>, pos: number, file: MinimalSourceFile): void;
|
80 | /**
|
81 | * Print a log message.
|
82 | *
|
83 | * @param _message The message itself.
|
84 | * @param level The urgency of the log message.
|
85 | */
|
86 | log(_message: string, level: LogLevel): void;
|
87 | /**
|
88 | * Print the given TypeScript log messages.
|
89 | *
|
90 | * @param diagnostics The TypeScript messages that should be logged.
|
91 | */
|
92 | diagnostics(diagnostics: ReadonlyArray<ts.Diagnostic>): void;
|
93 | /**
|
94 | * Print the given TypeScript log message.
|
95 | *
|
96 | * @param diagnostic The TypeScript message that should be logged.
|
97 | */
|
98 | diagnostic(diagnostic: ts.Diagnostic): void;
|
99 | protected addContext(message: string, _level: LogLevel, ..._args: [ts.Node?] | [number, MinimalSourceFile]): string;
|
100 | }
|
101 | /**
|
102 | * A logger that outputs all messages to the console.
|
103 | */
|
104 | export declare class ConsoleLogger extends Logger {
|
105 | /**
|
106 | * Print a log message.
|
107 | *
|
108 | * @param message The message itself.
|
109 | * @param level The urgency of the log message.
|
110 | */
|
111 | log(message: string, level: Exclude<LogLevel, LogLevel.None>): void;
|
112 | protected addContext(message: string, level: Exclude<LogLevel, LogLevel.None>, ...args: [ts.Node?] | [number, MinimalSourceFile]): string;
|
113 | }
|