b049831664c24cfac6d050d2bb142b47d46bf411
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / loglevel / index.d.ts
1 // Originally from Definitely Typed, see:
2 // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/b4683d7/types/loglevel/index.d.ts
3 // Original definitions by: Stefan Profanter <https://github.com/Pro>
4 //                          Gabor Szmetanko <https://github.com/szmeti>
5 //                          Christian Rackerseder <https://github.com/screendriver>
6
7 declare const log: log.RootLogger;
8 export = log;
9
10 declare namespace log {
11     /**
12      * Log levels
13      */
14     interface LogLevel {
15         TRACE: 0;
16         DEBUG: 1;
17         INFO: 2;
18         WARN: 3;
19         ERROR: 4;
20         SILENT: 5;
21     }
22
23     /**
24      * Possible log level numbers.
25      */
26     type LogLevelNumbers = LogLevel[keyof LogLevel];
27
28     /**
29      * Possible log level descriptors, may be string, lower or upper case, or number.
30      */
31     type LogLevelDesc = LogLevelNumbers
32         | 'trace'
33         | 'debug'
34         | 'info'
35         | 'warn'
36         | 'error'
37         | 'silent'
38         | keyof LogLevel;
39
40     type LoggingMethod = (...message: any[]) => void;
41
42     type MethodFactory = (methodName: string, level: LogLevelNumbers, loggerName: string) => LoggingMethod;
43
44     interface RootLogger extends Logger {
45         /**
46          * If you're using another JavaScript library that exposes a 'log' global, you can run into conflicts with loglevel.
47          * Similarly to jQuery, you can solve this by putting loglevel into no-conflict mode immediately after it is loaded
48          * onto the page. This resets to 'log' global to its value before loglevel was loaded (typically undefined), and
49          * returns the loglevel object, which you can then bind to another name yourself.
50          */
51         noConflict(): any;
52
53         /**
54          * This gets you a new logger object that works exactly like the root log object, but can have its level and
55          * logging methods set independently. All loggers must have a name (which is a non-empty string). Calling
56          * getLogger() multiple times with the same name will return an identical logger object.
57          * In large applications, it can be incredibly useful to turn logging on and off for particular modules as you are
58          * working with them. Using the getLogger() method lets you create a separate logger for each part of your
59          * application with its own logging level. Likewise, for small, independent modules, using a named logger instead
60          * of the default root logger allows developers using your module to selectively turn on deep, trace-level logging
61          * when trying to debug problems, while logging only errors or silencing logging altogether under normal
62          * circumstances.
63          * @param name The name of the produced logger
64          */
65         getLogger(name: string): Logger;
66
67         /**
68          * This will return you the dictionary of all loggers created with getLogger, keyed off of their names.
69          */
70         getLoggers(): { [name: string]: Logger };
71     }
72
73     interface Logger {
74         /**
75          * Available log levels.
76          */
77         readonly levels: LogLevel;
78
79         /**
80          * Plugin API entry point. This will be called for each enabled method each time the level is set
81          * (including initially), and should return a MethodFactory to be used for the given log method, at the given level,
82          * for a logger with the given name. If you'd like to retain all the reliability and features of loglevel, it's
83          * recommended that this wraps the initially provided value of log.methodFactory
84          */
85         methodFactory: MethodFactory;
86
87         /**
88          * Output trace message to console.
89          * This will also include a full stack trace
90          *
91          * @param msg any data to log to the console
92          */
93         trace(...msg: any[]): void;
94
95         /**
96          * Output debug message to console including appropriate icons
97          *
98          * @param msg any data to log to the console
99          */
100         debug(...msg: any[]): void;
101
102         /**
103          * Output debug message to console including appropriate icons
104          *
105          * @param msg any data to log to the console
106          */
107         log(...msg: any[]): void;
108
109         /**
110          * Output info message to console including appropriate icons
111          *
112          * @param msg any data to log to the console
113          */
114         info(...msg: any[]): void;
115
116         /**
117          * Output warn message to console including appropriate icons
118          *
119          * @param msg any data to log to the console
120          */
121         warn(...msg: any[]): void;
122
123         /**
124          * Output error message to console including appropriate icons
125          *
126          * @param msg any data to log to the console
127          */
128         error(...msg: any[]): void;
129
130         /**
131          * This disables all logging below the given level, so that after a log.setLevel("warn") call log.warn("something")
132          * or log.error("something") will output messages, but log.info("something") will not.
133          *
134          * @param level as a string, like 'error' (case-insensitive) or as a number from 0 to 5 (or as log.levels. values)
135          * @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
136          *     back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
137          *     false as the optional 'persist' second argument, persistence will be skipped.
138          */
139         setLevel(level: LogLevelDesc, persist?: boolean): void;
140
141         /**
142          * Returns the current logging level, as a value from LogLevel.
143          * It's very unlikely you'll need to use this for normal application logging; it's provided partly to help plugin
144          * development, and partly to let you optimize logging code as below, where debug data is only generated if the
145          * level is set such that it'll actually be logged. This probably doesn't affect you, unless you've run profiling
146          * on your code and you have hard numbers telling you that your log data generation is a real performance problem.
147          */
148         getLevel(): LogLevel[keyof LogLevel];
149
150         /**
151          * This sets the current log level only if one has not been persisted and can’t be loaded. This is useful when
152          * initializing scripts; if a developer or user has previously called setLevel(), this won’t alter their settings.
153          * For example, your application might set the log level to error in a production environment, but when debugging
154          * an issue, you might call setLevel("trace") on the console to see all the logs. If that error setting was set
155          * using setDefaultLevel(), it will still say as trace on subsequent page loads and refreshes instead of resetting
156          * to error.
157          *
158          * The level argument takes is the same values that you might pass to setLevel(). Levels set using
159          * setDefaultLevel() never persist to subsequent page loads.
160          *
161          * @param level as a string, like 'error' (case-insensitive) or as a number from 0 to 5 (or as log.levels. values)
162          */
163         setDefaultLevel(level: LogLevelDesc): void;
164
165         /**
166          * This enables all log messages, and is equivalent to log.setLevel("trace").
167          *
168          * @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
169          *     back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
170          *     false as the optional 'persist' second argument, persistence will be skipped.
171          */
172         enableAll(persist?: boolean): void;
173
174         /**
175          * This disables all log messages, and is equivalent to log.setLevel("silent").
176          *
177          * @param persist Where possible the log level will be persisted. LocalStorage will be used if available, falling
178          *     back to cookies if not. If neither is available in the current environment (i.e. in Node), or if you pass
179          *     false as the optional 'persist' second argument, persistence will be skipped.
180          */
181         disableAll(persist?: boolean): void;
182     }
183 }