1 | export declare type DiagLogFunction = (message: string, ...args: unknown[]) => void;
|
2 | /**
|
3 | * Defines an internal diagnostic logger interface which is used to log internal diagnostic
|
4 | * messages, you can set the default diagnostic logger via the {@link DiagAPI} setLogger function.
|
5 | * API provided implementations include :-
|
6 | * - a No-Op {@link createNoopDiagLogger}
|
7 | * - a {@link DiagLogLevel} filtering wrapper {@link createLogLevelDiagLogger}
|
8 | * - a general Console {@link DiagConsoleLogger} version.
|
9 | */
|
10 | export interface DiagLogger {
|
11 | /** Log an error scenario that was not expected and caused the requested operation to fail. */
|
12 | error: DiagLogFunction;
|
13 | /**
|
14 | * Log a warning scenario to inform the developer of an issues that should be investigated.
|
15 | * The requested operation may or may not have succeeded or completed.
|
16 | */
|
17 | warn: DiagLogFunction;
|
18 | /**
|
19 | * Log a general informational message, this should not affect functionality.
|
20 | * This is also the default logging level so this should NOT be used for logging
|
21 | * debugging level information.
|
22 | */
|
23 | info: DiagLogFunction;
|
24 | /**
|
25 | * Log a general debug message that can be useful for identifying a failure.
|
26 | * Information logged at this level may include diagnostic details that would
|
27 | * help identify a failure scenario.
|
28 | * For example: Logging the order of execution of async operations.
|
29 | */
|
30 | debug: DiagLogFunction;
|
31 | /**
|
32 | * Log a detailed (verbose) trace level logging that can be used to identify failures
|
33 | * where debug level logging would be insufficient, this level of tracing can include
|
34 | * input and output parameters and as such may include PII information passing through
|
35 | * the API. As such it is recommended that this level of tracing should not be enabled
|
36 | * in a production environment.
|
37 | */
|
38 | verbose: DiagLogFunction;
|
39 | }
|
40 | /**
|
41 | * Defines the available internal logging levels for the diagnostic logger, the numeric values
|
42 | * of the levels are defined to match the original values from the initial LogLevel to avoid
|
43 | * compatibility/migration issues for any implementation that assume the numeric ordering.
|
44 | */
|
45 | export declare enum DiagLogLevel {
|
46 | /** Diagnostic Logging level setting to disable all logging (except and forced logs) */
|
47 | NONE = 0,
|
48 | /** Identifies an error scenario */
|
49 | ERROR = 30,
|
50 | /** Identifies a warning scenario */
|
51 | WARN = 50,
|
52 | /** General informational log message */
|
53 | INFO = 60,
|
54 | /** General debug log message */
|
55 | DEBUG = 70,
|
56 | /**
|
57 | * Detailed trace level logging should only be used for development, should only be set
|
58 | * in a development environment.
|
59 | */
|
60 | VERBOSE = 80,
|
61 | /** Used to set the logging level to include all logging */
|
62 | ALL = 9999
|
63 | }
|
64 | /**
|
65 | * Defines options for ComponentLogger
|
66 | */
|
67 | export interface ComponentLoggerOptions {
|
68 | namespace: string;
|
69 | }
|
70 | export interface DiagLoggerOptions {
|
71 | /**
|
72 | * The {@link DiagLogLevel} used to filter logs sent to the logger.
|
73 | *
|
74 | * @defaultValue DiagLogLevel.INFO
|
75 | */
|
76 | logLevel?: DiagLogLevel;
|
77 | /**
|
78 | * Setting this value to `true` will suppress the warning message normally emitted when registering a logger when another logger is already registered.
|
79 | */
|
80 | suppressOverrideMessage?: boolean;
|
81 | }
|
82 | export interface DiagLoggerApi {
|
83 | /**
|
84 | * Set the global DiagLogger and DiagLogLevel.
|
85 | * If a global diag logger is already set, this will override it.
|
86 | *
|
87 | * @param logger - The {@link DiagLogger} instance to set as the default logger.
|
88 | * @param options - A {@link DiagLoggerOptions} object. If not provided, default values will be set.
|
89 | * @returns `true` if the logger was successfully registered, else `false`
|
90 | */
|
91 | setLogger(logger: DiagLogger, options?: DiagLoggerOptions): boolean;
|
92 | /**
|
93 | *
|
94 | * @param logger - The {@link DiagLogger} instance to set as the default logger.
|
95 | * @param logLevel - The {@link DiagLogLevel} used to filter logs sent to the logger. If not provided it will default to {@link DiagLogLevel.INFO}.
|
96 | * @returns `true` if the logger was successfully registered, else `false`
|
97 | */
|
98 | setLogger(logger: DiagLogger, logLevel?: DiagLogLevel): boolean;
|
99 | }
|
100 | //# sourceMappingURL=types.d.ts.map |
\ | No newline at end of file |