UNPKG

3.45 kBTypeScriptView Raw
1import * as logform from "logform";
2import * as Transport from "winston-transport";
3import { Configuration } from "../configuration";
4/**
5 * Global logger instance
6 * By default all logging to this logger will be suppressed.
7 * Call configureLogging to set up console and file transports.
8 */
9export declare const logger: Logger;
10/**
11 * Constants for the logging format
12 */
13export declare enum LoggingFormat {
14 /**
15 * Print only the message provided to the logger methods
16 */
17 None = 0,
18 /**
19 * Print level and message
20 */
21 Simple = 1,
22 /**
23 * Print the full client related metadata
24 */
25 Full = 2
26}
27/**
28 * Configuration for the logging sub-system to be passed to configureLogging
29 */
30export interface LoggingConfiguration {
31 console: {
32 /**
33 * Enable logging to console
34 */
35 enabled: boolean;
36 /**
37 * Set log level for the console
38 */
39 level?: string;
40 /**
41 * Set format of console log
42 */
43 format?: LoggingFormat;
44 /**
45 * Redirect console.log methods to logger sub-system
46 */
47 redirect?: boolean;
48 };
49 file: {
50 /**
51 * Enable file logging
52 */
53 enabled: boolean;
54 /**
55 * Set log level for file logging
56 */
57 level?: string;
58 /**
59 * Set file name and path to log into
60 */
61 filename?: string;
62 /**
63 * Set format for file logging
64 */
65 format?: LoggingFormat;
66 };
67 custom?: Transport[];
68 redact?: boolean;
69 callsites?: boolean;
70 color?: boolean;
71}
72/**
73 * Logging configuration suppress all logger logging
74 */
75export declare const NoLogging: LoggingConfiguration;
76/**
77 * Logging configuration to simply pass through log message to the console
78 */
79export declare const PlainLogging: LoggingConfiguration;
80/**
81 * CLI-style logging configuration
82 */
83export declare const MinimalLogging: LoggingConfiguration;
84/**
85 * Default logging configuration for running automation clients
86 */
87export declare const ClientLogging: LoggingConfiguration;
88/**
89 * Configure the logging sub-system with the provided LoggingConfiguration
90 * It is safe to call this method several times to re-configure the logger.
91 * @param config
92 */
93export declare function configureLogging(config: LoggingConfiguration): void;
94/**
95 * Configure the logging sub-system based on the provided Configuration object
96 * @param configuration
97 */
98export declare function clientLoggingConfiguration(configuration: Configuration): LoggingConfiguration;
99export declare function callsite(logInfo: logform.TransformableInfo): logform.TransformableInfo;
100export interface Logger {
101 log: LogMethod;
102 error: LeveledLogMethod;
103 warn: LeveledLogMethod;
104 info: LeveledLogMethod;
105 debug: LeveledLogMethod;
106 verbose: LeveledLogMethod;
107}
108export interface LogMethod {
109 (level: string, msg: string, callback: LogCallback): Logger;
110 (level: string, msg: string, meta: any, callback: LogCallback): Logger;
111 (level: string, msg: string, ...meta: any[]): Logger;
112}
113export interface LeveledLogMethod {
114 (msg: string, callback: LogCallback): Logger;
115 (msg: string, meta: any, callback: LogCallback): Logger;
116 (msg: string, ...meta: any[]): Logger;
117}
118export declare type LogCallback = (error?: any, level?: string, msg?: string, meta?: any) => void;
119//# sourceMappingURL=logger.d.ts.map
\No newline at end of file