1 | /// <reference types="node" />
|
2 |
|
3 | declare namespace signale {
|
4 | type DefaultMethods =
|
5 | | "await"
|
6 | | "complete"
|
7 | | "error"
|
8 | | "debug"
|
9 | | "fatal"
|
10 | | "fav"
|
11 | | "info"
|
12 | | "note"
|
13 | | "pause"
|
14 | | "pending"
|
15 | | "star"
|
16 | | "start"
|
17 | | "success"
|
18 | | "warn"
|
19 | | "watch"
|
20 | | "log";
|
21 |
|
22 | interface CommandType {
|
23 | /** The icon corresponding to the logger. */
|
24 | badge: string;
|
25 | /**
|
26 | * The color of the label, can be any of the foreground colors supported by
|
27 | * [chalk](https://github.com/chalk/chalk#colors).
|
28 | */
|
29 | color: string;
|
30 | /** The label used to identify the type of the logger. */
|
31 | label: string;
|
32 | logLevel?: string | undefined;
|
33 | stream?: NodeJS.WriteStream | NodeJS.WriteStream[] | undefined;
|
34 | }
|
35 |
|
36 | interface SignaleConfig {
|
37 | /** Display the scope name of the logger. */
|
38 | displayScope?: boolean | undefined;
|
39 | /** Display the badge of the logger. */
|
40 | displayBadge?: boolean | undefined;
|
41 | /** Display the current local date in `YYYY-MM-DD` format. */
|
42 | displayDate?: boolean | undefined;
|
43 | /** Display the name of the file that the logger is reporting from. */
|
44 | displayFilename?: boolean | undefined;
|
45 | /** Display the label of the logger. */
|
46 | displayLabel?: boolean | undefined;
|
47 | /** Display the current local time in `HH:MM:SS` format. */
|
48 | displayTimestamp?: boolean | undefined;
|
49 | /** Underline the logger label. */
|
50 | underlineLabel?: boolean | undefined;
|
51 | /** Underline the logger message. */
|
52 | underlineMessage?: boolean | undefined;
|
53 | underlinePrefix?: boolean | undefined;
|
54 | underlineSuffix?: boolean | undefined;
|
55 | uppercaseLabel?: boolean | undefined;
|
56 | }
|
57 |
|
58 | interface SignaleOptions<TTypes extends string = DefaultMethods> {
|
59 | /** Sets the configuration of an instance overriding any existing global or local configuration. */
|
60 | config?: SignaleConfig | undefined;
|
61 | disabled?: boolean | undefined;
|
62 | /**
|
63 | * Name of the scope.
|
64 | */
|
65 | scope?: string | undefined;
|
66 | /**
|
67 | * Holds the configuration of the custom and default loggers.
|
68 | */
|
69 | types?: Partial<Record<TTypes, CommandType>> | undefined;
|
70 | interactive?: boolean | undefined;
|
71 | logLevel?: string | undefined;
|
72 | timers?: Map<string, Date> | undefined;
|
73 | /**
|
74 | * Destination to which the data is written, can be any valid
|
75 | * [Writable stream](https://nodejs.org/api/stream.html#stream_writable_streams).
|
76 | */
|
77 | stream?: NodeJS.WriteStream | NodeJS.WriteStream[] | undefined;
|
78 | secrets?: Array<string | number> | undefined;
|
79 | }
|
80 |
|
81 | interface SignaleConstructor {
|
82 | new<TTypes extends string = DefaultMethods>(options?: SignaleOptions<TTypes>): Signale<TTypes>;
|
83 | }
|
84 |
|
85 | interface SignaleBase<TTypes extends string = DefaultMethods> {
|
86 | /**
|
87 | * Sets the configuration of an instance overriding any existing global or local configuration.
|
88 | *
|
89 | * @param configObj Can hold any of the documented options.
|
90 | */
|
91 | config(configObj: SignaleConfig): Signale<TTypes>;
|
92 | /**
|
93 | * Defines the scope name of the logger.
|
94 | *
|
95 | * @param name Can be one or more comma delimited strings.
|
96 | */
|
97 | scope(...name: string[]): Signale<TTypes>;
|
98 | /** Clears the scope name of the logger. */
|
99 | unscope(): void;
|
100 | /**
|
101 | * Sets a timers and accepts an optional label. If none provided the timer will receive a unique label automatically.
|
102 | *
|
103 | * @param label Label corresponding to the timer. Each timer must have its own unique label.
|
104 | * @returns a string corresponding to the timer label.
|
105 | */
|
106 | time(label?: string): string;
|
107 | /**
|
108 | * Deactivates the timer to which the given label corresponds. If no label
|
109 | * is provided the most recent timer, that was created without providing a
|
110 | * label, will be deactivated.
|
111 | *
|
112 | * @param label Label corresponding to the timer, each timer has its own unique label.
|
113 | * @param span Total running time.
|
114 | */
|
115 | timeEnd(label?: string, span?: number): { label: string; span?: number | undefined };
|
116 | /**
|
117 | * Disables the logging functionality of all loggers belonging to a specific instance.
|
118 | */
|
119 | disable(): void;
|
120 | /**
|
121 | * Enables the logging functionality of all loggers belonging to a specific instance.
|
122 | */
|
123 | enable(): void;
|
124 | /**
|
125 | * Checks whether the logging functionality of a specific instance is enabled.
|
126 | *
|
127 | * @returns a boolean that describes whether or not the logger is enabled.
|
128 | */
|
129 | isEnabled(): boolean;
|
130 | /**
|
131 | * Adds new secrets/sensitive-information to the targeted Signale instance.
|
132 | *
|
133 | * @param secrets Array holding the secrets/sensitive-information to be filtered out.
|
134 | */
|
135 | addSecrets(secrets: string[] | number[]): void;
|
136 | /**
|
137 | * Removes all secrets/sensitive-information from the targeted Signale instance.
|
138 | */
|
139 | clearSecrets(): void;
|
140 | }
|
141 |
|
142 | type LoggerFunc = (message?: any, ...optionalArgs: any[]) => void;
|
143 | type Signale<TTypes extends string = DefaultMethods> =
|
144 | & SignaleBase<TTypes>
|
145 | & Record<TTypes, LoggerFunc>
|
146 | & Record<DefaultMethods, LoggerFunc>;
|
147 | }
|
148 |
|
149 | declare const signale: signale.Signale<signale.DefaultMethods> & {
|
150 | Signale: signale.SignaleConstructor;
|
151 | SignaleConfig: signale.SignaleConfig;
|
152 | SignaleOptions: signale.SignaleOptions;
|
153 | DefaultMethods: signale.DefaultMethods;
|
154 | };
|
155 |
|
156 | export = signale;
|