UNPKG

5.38 kBTypeScriptView Raw
1/// <reference types="node" />
2/// <reference types="bunyan" />
3import * as bunyan from 'bunyan';
4export declare abstract class Logger {
5 /**
6 * Returns a boolean: is the `trace` level enabled?
7 * This is equivalent to `log.isTraceEnabled()` or `log.isEnabledFor(TRACE)` in log4j.
8 */
9 abstract trace(): boolean;
10 /**
11 * The first field can optionally be a "fields" object, which
12 * is merged into the log record.
13 * Special case to log an `Error` instance to the record.
14 * This adds an `err` field with exception details
15 * (including the stack) and sets `msg` to the exception
16 * message or you can specify the `msg`.
17 */
18 abstract trace(error: Error | Buffer | Object, format?: any, ...params: any[]): void;
19 /**
20 * Uses `util.format` for msg formatting.
21 */
22 abstract trace(format: string | number, ...params: any[]): void;
23 /**
24 * Returns a boolean: is the `debug` level enabled?
25 * This is equivalent to `log.isDebugEnabled()` or `log.isEnabledFor(DEBUG)` in log4j.
26 */
27 abstract debug(): boolean;
28 /**
29 * Special case to log an `Error` instance to the record.
30 * This adds an `err` field with exception details
31 * (including the stack) and sets `msg` to the exception
32 * message or you can specify the `msg`.
33 */
34 abstract debug(error: Error | Buffer | Object, format?: any, ...params: any[]): void;
35 /**
36 * Uses `util.format` for msg formatting.
37 */
38 abstract debug(format: string | number, ...params: any[]): void;
39 /**
40 * Returns a boolean: is the `info` level enabled?
41 * This is equivalent to `log.isInfoEnabled()` or `log.isEnabledFor(INFO)` in log4j.
42 */
43 abstract info(): boolean;
44 /**
45 * Special case to log an `Error` instance to the record.
46 * This adds an `err` field with exception details
47 * (including the stack) and sets `msg` to the exception
48 * message or you can specify the `msg`.
49 */
50 abstract info(error: Error | Buffer | Object, format?: any, ...params: any[]): void;
51 /**
52 * Uses `util.format` for msg formatting.
53 */
54 abstract info(format: string | number, ...params: any[]): void;
55 /**
56 * Returns a boolean: is the `warn` level enabled?
57 * This is equivalent to `log.isWarnEnabled()` or `log.isEnabledFor(WARN)` in log4j.
58 */
59 abstract warn(): boolean;
60 /**
61 * Special case to log an `Error` instance to the record.
62 * This adds an `err` field with exception details
63 * (including the stack) and sets `msg` to the exception
64 * message or you can specify the `msg`.
65 */
66 abstract warn(error: Error | Buffer | Object, format?: any, ...params: any[]): void;
67 /**
68 * Uses `util.format` for msg formatting.
69 */
70 abstract warn(format: string | number, ...params: any[]): void;
71 /**
72 * Returns a boolean: is the `error` level enabled?
73 * This is equivalent to `log.isErrorEnabled()` or `log.isEnabledFor(ERROR)` in log4j.
74 */
75 abstract error(): boolean;
76 /**
77 * Special case to log an `Error` instance to the record.
78 * This adds an `err` field with exception details
79 * (including the stack) and sets `msg` to the exception
80 * message or you can specify the `msg`.
81 */
82 abstract error(error: Error | Buffer | Object, format?: any, ...params: any[]): void;
83 /**
84 * Uses `util.format` for msg formatting.
85 */
86 abstract error(format: string | number, ...params: any[]): void;
87 /**
88 * Returns a boolean: is the `fatal` level enabled?
89 * This is equivalent to `log.isFatalEnabled()` or `log.isEnabledFor(FATAL)` in log4j.
90 */
91 abstract fatal(): boolean;
92 /**
93 * Special case to log an `Error` instance to the record.
94 * This adds an `err` field with exception details
95 * (including the stack) and sets `msg` to the exception
96 * message or you can specify the `msg`.
97 */
98 abstract fatal(error: Error | Buffer | Object, format?: any, ...params: any[]): void;
99 /**
100 * Uses `util.format` for msg formatting.
101 */
102 abstract fatal(format: string | number, ...params: any[]): void;
103}
104export declare class LogManagerInternal {
105 static setAppName: any;
106 static getLogger: any;
107 private static beSmartOnThePath(thePath);
108 private static getEffectiveLevel(loggerName, streamName, configuredLevel);
109 private static mkdirpSync(thePath, mode);
110 private static getRedisStream(redisConfig);
111 private static resolvePath(thePath);
112 private streamCache;
113 private appName;
114 getLogger(filePath?: string): Logger;
115 scheduleShutdown(): void;
116 closeStreams(): void;
117 setAppName(appName: string): void;
118 getAppName(): string;
119 getLoggerInternal(loggerPath: string): Logger;
120 getStreamConfig(streamName: string, level: bunyan.LogLevel): {
121 stream: bunyan.Stream;
122 level: bunyan.LogLevel;
123 name: any;
124 } | {
125 type: string;
126 stream: bunyan.Stream;
127 closeOnExit: boolean;
128 level: bunyan.LogLevel;
129 } | {
130 type: string;
131 level: bunyan.LogLevel;
132 stream: bunyan.Stream;
133 };
134 getUnderlyingStream(streamName: string): bunyan.Stream;
135}
136export declare const LogManager: LogManagerInternal;