UNPKG

3.3 kBTypeScriptView Raw
1import { Config } from './config';
2export declare enum LogLevel {
3 ERROR = 0,
4 WARN = 1,
5 INFO = 2,
6 DEBUG = 3,
7}
8export declare enum WriteTo {
9 CONSOLE = 0,
10 FILE = 1,
11 BOTH = 2,
12 NONE = 3,
13}
14/**
15 * Logger class adds timestamp output, log levels, and identifiers to help
16 * when debugging. Also could write to console, file, both, or none.
17 */
18export declare class Logger {
19 private id;
20 static logLevel: LogLevel;
21 static showTimestamp: boolean;
22 static showId: boolean;
23 static writeTo: WriteTo;
24 static fd: any;
25 static firstWrite: boolean;
26 /**
27 * Set up the logging configuration from the protractor configuration file.
28 * @param config The protractor configuration
29 */
30 static set(config: Config): void;
31 /**
32 * Set up the write location. If writing to a file, get the file descriptor.
33 * @param writeTo The enum for where to write the logs.
34 * @param opt_logFile An optional parameter to override the log file location.
35 */
36 static setWrite(writeTo: WriteTo, opt_logFile?: string): void;
37 /**
38 * Creates a logger instance with an ID for the logger.
39 * @constructor
40 */
41 constructor(id: string);
42 /**
43 * Log INFO
44 * @param ...msgs multiple arguments to be logged.
45 */
46 info(...msgs: any[]): void;
47 /**
48 * Log DEBUG
49 * @param ...msgs multiple arguments to be logged.
50 */
51 debug(...msgs: any[]): void;
52 /**
53 * Log WARN
54 * @param ...msgs multiple arguments to be logged.
55 */
56 warn(...msgs: any[]): void;
57 /**
58 * Log ERROR
59 * @param ...msgs multiple arguments to be logged.
60 */
61 error(...msgs: any[]): void;
62 /**
63 * For the log level set, check to see if the messages should be logged.
64 * @param logLevel The log level of the message.
65 * @param msgs The messages to be logged
66 */
67 log_(logLevel: LogLevel, msgs: any[]): void;
68 /**
69 * Format with timestamp, log level, identifier, and message and log to
70 * specified medium (console, file, both, none).
71 * @param logLevel The log level of the message.
72 * @param msgs The messages to be logged.
73 */
74 print_(logLevel: LogLevel, msgs: any[]): void;
75 /**
76 * Get a timestamp formatted with [hh:mm:ss]
77 * @param writeTo The enum for where to write the logs.
78 * @return The string of the formatted timestamp
79 */
80 static timestamp_(writeTo: WriteTo): string;
81 /**
82 * Get the identifier of the logger as '/<id>'
83 * @param logLevel The log level of the message.
84 * @param writeTo The enum for where to write the logs.
85 * @return The string of the formatted id
86 */
87 static id_(logLevel: LogLevel, id: string, writeTo: WriteTo): string;
88 /**
89 * Get the log level formatted with the first letter. For info, it is I.
90 * @param logLevel The log level of the message.
91 * @param writeTo The enum for where to write the logs.
92 * @return The string of the formatted log level
93 */
94 static level_(logLevel: LogLevel, id: string, writeTo: WriteTo): string;
95 /**
96 * Convert the list of messages to a single string message.
97 * @param msgs The list of messages.
98 * @return The string of the formatted messages
99 */
100 static msgToFile_(msgs: any[]): string;
101}