UNPKG

2.54 kBTypeScriptView Raw
1export * from "./listeners.js";
2/**
3 * A set of logging levels
4 */
5export declare enum LogLevel {
6 Verbose = 0,
7 Info = 1,
8 Warning = 2,
9 Error = 3,
10 Off = 99
11}
12/**
13 * Interface that defines a log entry
14 *
15 */
16export interface ILogEntry {
17 /**
18 * The main message to be logged
19 */
20 message: string;
21 /**
22 * The level of information this message represents
23 */
24 level: LogLevel;
25 /**
26 * Any associated data that a given logging listener may choose to log or ignore
27 */
28 data?: any;
29}
30/**
31 * Interface that defines a log listener
32 *
33 */
34export interface ILogListener {
35 /**
36 * Any associated data that a given logging listener may choose to log or ignore
37 *
38 * @param entry The information to be logged
39 */
40 log(entry: ILogEntry): void;
41}
42/**
43 * Class used to subscribe ILogListener and log messages throughout an application
44 *
45 */
46export declare class Logger {
47 /**
48 * Gets or sets the active log level to apply for log filtering
49 */
50 static get activeLogLevel(): LogLevel;
51 static set activeLogLevel(value: LogLevel);
52 /**
53 * Adds ILogListener instances to the set of subscribed listeners
54 *
55 * @param listeners One or more listeners to subscribe to this log
56 */
57 static subscribe(...listeners: ILogListener[]): void;
58 /**
59 * Clears the subscribers collection, returning the collection before modification
60 */
61 static clearSubscribers(): ILogListener[];
62 /**
63 * Gets the current subscriber count
64 */
65 static get count(): number;
66 /**
67 * Writes the supplied string to the subscribed listeners
68 *
69 * @param message The message to write
70 * @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
71 */
72 static write(message: string, level?: LogLevel): void;
73 /**
74 * Writes the supplied string to the subscribed listeners
75 *
76 * @param json The json object to stringify and write
77 * @param level [Optional] if supplied will be used as the level of the entry (Default: LogLevel.Info)
78 */
79 static writeJSON(json: any, level?: LogLevel): void;
80 /**
81 * Logs the supplied entry to the subscribed listeners
82 *
83 * @param entry The message to log
84 */
85 static log(entry: ILogEntry): void;
86 /**
87 * Logs an error object to the subscribed listeners
88 *
89 * @param err The error object
90 */
91 static error(err: Error): void;
92}
93export declare function PnPLogging<T>(activeLevel: LogLevel): (o: T) => T;
94//# sourceMappingURL=index.d.ts.map
\No newline at end of file