|
| 1 | +/** |
| 2 | + * Generate a verbosity console |
| 3 | + * @param {object} options - Configuration options. |
| 4 | + * @param {stream.writable} options.outStream - Stream to write normal output |
| 5 | + * @param {stream.writable} options.errorStream - Stream to write error output |
| 6 | + * @param {number} options.verbosity - The verboseness of output: |
| 7 | + * 0: Mute |
| 8 | + * 1: Errors |
| 9 | + * 2: Notice |
| 10 | + * 3: Log |
| 11 | + * 4: Info |
| 12 | + * 5: Debug |
| 13 | + * @param {string} options.timestamp - Timestamp format. |
| 14 | + * @param {string} options.namespace - Sparkles namespace to emit events to. |
| 15 | + * @param {boolean} options.global - Should changes to verbosity be made globally? |
| 16 | + * @param {string} options.prefix - Logging message prefix. |
| 17 | + * @return {Verbosity} Verbosity's console object. |
| 18 | + */ |
| 19 | +export class Verbosity extends Console { |
| 20 | + constructor({ outStream, errorStream, verbosity, timestamp, namespace, global, prefix, }?: { |
| 21 | + outStream: any; |
| 22 | + errorStream: any; |
| 23 | + verbosity?: number; |
| 24 | + timestamp: any; |
| 25 | + namespace: any; |
| 26 | + global: any; |
| 27 | + prefix: any; |
| 28 | + }); |
| 29 | + willEmit: boolean; |
| 30 | + globalControl: boolean; |
| 31 | + timeFormatter: () => string; |
| 32 | + prefixFormatter: () => string; |
| 33 | + _stdout: any; |
| 34 | + _stderr: any; |
| 35 | + threshold: number; |
| 36 | + globalVerbosityController: any; |
| 37 | + emitter: any; |
| 38 | + matrix: any; |
| 39 | + /** |
| 40 | + * Set the current verbosity. |
| 41 | + * @param {number|string} level - The current level (0 to 5) or level name. |
| 42 | + * @return {number} The current verboseness (0 to 5). |
| 43 | + */ |
| 44 | + verbosity(level: number | string): number; |
| 45 | + /** |
| 46 | + * Can the requested logging level be written at this time. |
| 47 | + * @param {number} level - The requested level (0 to 5). |
| 48 | + * @return {boolean} `true` if ok to write. |
| 49 | + */ |
| 50 | + canWrite(level: number): boolean; |
| 51 | + /** |
| 52 | + * Route message and emit if required. |
| 53 | + * @private |
| 54 | + * @param {number} level Source logging level |
| 55 | + * @param {string} message Message to log |
| 56 | + * @param {...string} a Additional arguments to log |
| 57 | + */ |
| 58 | + private route; |
| 59 | + /** |
| 60 | + * Log a critical error message, if something breaks. (Level 1) |
| 61 | + * @param {string} message The critical error message to log. |
| 62 | + * @param {...string} args Additional arguments to log. |
| 63 | + */ |
| 64 | + critical(message: string, ...args: string[]): void; |
| 65 | + /** |
| 66 | + * Log a panic error message if something unexpected happens. (Level 1) |
| 67 | + * @param {string} message The panic message to log. |
| 68 | + * @param {...string} args Additional arguments to log. |
| 69 | + */ |
| 70 | + panic(message: string, ...args: string[]): void; |
| 71 | + /** |
| 72 | + * Log a emergency message, for when something needs emergency attention. (Level 1) |
| 73 | + * @param {string} message The debug message to log. |
| 74 | + * @param {...string} args Additional arguments to log. |
| 75 | + */ |
| 76 | + emergency(message: string, ...args: string[]): void; |
| 77 | + /** |
| 78 | + * Pretty prints object, similar to OS X's plutil -p. Defaults to zero depth. |
| 79 | + * @param {object} object The Object to print. |
| 80 | + * @param {number} depth How many object levels to print. |
| 81 | + * @param {boolean} color Print output in color, if supported. |
| 82 | + * @example |
| 83 | + * console.pretty(console) |
| 84 | + * |
| 85 | + * // Outputs: |
| 86 | + * Object: VerbosityMatrix |
| 87 | + * critical ▸ [Function] |
| 88 | + * error ▸ [Function ▸ bound ] |
| 89 | + * warn ▸ [Function ▸ bound ] |
| 90 | + * log ▸ [Function ▸ bound ] |
| 91 | + * info ▸ [Function ▸ bound ] |
| 92 | + * debug ▸ [Function] |
| 93 | + * canWrite ▸ [Function] |
| 94 | + * ... |
| 95 | + */ |
| 96 | + pretty(object: object, depth?: number, color?: boolean): void; |
| 97 | + /** |
| 98 | + * Helper function for pretty printing a summary of the current 'yargs' options. |
| 99 | + * |
| 100 | + * Only prints 'long options', `._` as 'arguments' and `$0` as 'self'. |
| 101 | + * @param {object} object The Yargs argv object to print. |
| 102 | + * @param {boolean} color Print output in color, if supported. |
| 103 | + * @example |
| 104 | + * console.yargs(yargs) |
| 105 | + * |
| 106 | + * // Outputs: |
| 107 | + * Object (yargs): |
| 108 | + * left ▸ 2 |
| 109 | + * right ▸ 2 |
| 110 | + * mode ▸ 'hard' |
| 111 | + * encoding ▸ 'utf8' |
| 112 | + * ... |
| 113 | + * self ▸ '/usr/local/bin/truwrap' |
| 114 | + */ |
| 115 | + yargs(object: object, color?: boolean): void; |
| 116 | +} |
| 117 | +/** |
| 118 | + * Create a new Verbosity object. |
| 119 | + * @param {object} options Options to pass to the factory. |
| 120 | + * @return {Verbosity} Verbosity's console object. |
| 121 | + */ |
| 122 | +export function createConsole(options: object): Verbosity; |
| 123 | +/** |
| 124 | + * Return the modules version metadata. |
| 125 | + * @function |
| 126 | + * @param {number} level Version format required. |
| 127 | + * @return {string} The version string. |
| 128 | + */ |
| 129 | +export function getVersion(level: number): string; |
0 commit comments