[READ-ONLY] Mirror of https://github.com/FoxxMD/logging. A typed, opinionated, batteries-included, Pino-based logging solution for backend TS/JS projects foxxmd.github.io/logging
child-logger logging logging-library nodejs pinojs typescript-library
0

Configure Feed

Select the types of activity you want to include in your feed.

fix: Add missing trace level

* Add trace to level options/validation
* Lower min level for streams to trace
* add loggerTrace helper logger

FoxxMD (Feb 27, 2026, 4:43 PM UTC) 2e4de38f 1468f99e

+38 -14
+1
README.md
··· 75 75 76 76 These loggers are pre-defined for specific use cases: 77 77 78 + * [`loggerTrace`](https://foxxmd.github.io/logging/variables/index.loggerTrace.html) - Logs to console at the lowest minimum level, `trace`. Can be used during application startup before a logger app configuration has been parsed. 78 79 * [`loggerDebug`](https://foxxmd.github.io/logging/variables/index.loggerDebug.html) - Logs ONLY to console at minimum `debug` level. Can be used during application startup before a logger app configuration has been parsed. 79 80 * [`loggerTest`](https://foxxmd.github.io/logging/variables/index.loggerTest.html) - A noop logger (will not log anywhere) for use in tests/mockups. 80 81
+2 -2
package-lock.json
··· 1 1 { 2 2 "name": "@foxxmd/logging", 3 - "version": "0.2.5", 3 + "version": "0.2.6", 4 4 "lockfileVersion": 3, 5 5 "requires": true, 6 6 "packages": { 7 7 "": { 8 8 "name": "@foxxmd/logging", 9 - "version": "0.2.5", 9 + "version": "0.2.6", 10 10 "license": "MIT", 11 11 "dependencies": { 12 12 "pino": "^9.2.0",
+1 -1
package.json
··· 1 1 { 2 2 "name": "@foxxmd/logging", 3 3 "type": "module", 4 - "version": "0.2.5", 4 + "version": "0.2.6", 5 5 "repository": "https://github.com/foxxmd/logging", 6 6 "description": "A typed, opinionated, batteries-included, Pino-based logging solution for backend TS/JS projects", 7 7 "scripts": {
+1 -1
src/funcs.ts
··· 46 46 * */ 47 47 export const parseLogOptions = (config: LogOptions = {}, options?: FileLogPathOptions): LogOptionsParsed => { 48 48 if (!isLogOptions(config)) { 49 - throw new Error(`Logging levels were not valid. Must be one of: 'silent', 'fatal', 'error', 'warn', 'info', 'verbose', 'debug', -- 'file' may be false.`) 49 + throw new Error(`Logging levels were not valid. Must be one of: 'silent', 'fatal', 'error', 'warn', 'info', 'verbose', 'debug', 'trace' -- 'file' may be false.`) 50 50 } 51 51 52 52 const {level: configLevel} = config;
+2 -1
src/index.ts
··· 16 16 parseLogOptions, 17 17 } from './funcs.js' 18 18 19 - import {childLogger, loggerApp, loggerDebug, loggerTest, loggerAppRolling} from './loggers.js'; 19 + import {childLogger, loggerApp, loggerDebug, loggerTest, loggerTrace, loggerAppRolling} from './loggers.js'; 20 20 21 21 export type { 22 22 FileLogOptions, ··· 35 35 loggerAppRolling, 36 36 loggerDebug, 37 37 loggerTest, 38 + loggerTrace, 38 39 LOG_LEVEL_NAMES, 39 40 childLogger, 40 41 parseLogOptions,
+27 -6
src/loggers.ts
··· 20 20 * */ 21 21 export const buildLogger = (defaultLevel: LogLevel, streams: LogLevelStreamEntry[], extras: PinoLoggerOptions = {}): Logger => { 22 22 // TODO maybe implement custom levels 23 - //const { levels = {} } = extras; 23 + //const { levels: extraLevels = {} } = extras; 24 + /* 25 + pino levels are found at pino/lib/constants.js 26 + trace: 10, 27 + debug: 20, 28 + info: 30, 29 + warn: 40, 30 + error: 50, 31 + fatal: 60 32 + 33 + MS custom levels 34 + verbose: 25 35 + log: 21 36 + */ 37 + const ms = pino.multistream(streams, {levels: {...levels.values, ...CUSTOM_LEVELS}}); 24 38 25 39 const plogger = pino<"verbose" | "log">({ 26 40 // @ts-ignore ··· 59 73 }, 60 74 }, 61 75 ...extras 62 - }, pino.multistream(streams, {levels: {...levels.values, ...CUSTOM_LEVELS}})) as Logger; 76 + }, ms) as Logger; 63 77 plogger.labels = []; 64 78 65 79 plogger.addLabel = function (value) { ··· 96 110 * 97 111 * @source 98 112 * */ 99 - export const loggerTest = buildLogger('silent', [buildDestinationStdout('debug')]); 113 + export const loggerTest = buildLogger('silent', [buildDestinationStdout('trace')]); 100 114 101 115 102 116 /** ··· 104 118 * 105 119 * @source 106 120 * */ 107 - export const loggerDebug = buildLogger('debug', [buildDestinationStdout('debug')]); 121 + export const loggerDebug = buildLogger('debug', [buildDestinationStdout('trace')]); 122 + 123 + /** 124 + * A logger that logs to console at the lowest minimum level, 'trace'. Useful for logging during startup before a loggerApp has been initialized 125 + * 126 + * @source 127 + * */ 128 + export const loggerTrace = buildLogger('trace', [buildDestinationStdout('trace')]); 108 129 109 130 /** 110 131 * A Logger that logs to console and a static file ··· 135 156 } 136 157 } 137 158 138 - const logger = buildLogger('debug' as LogLevel, streams, pino); 159 + const logger = buildLogger('trace' as LogLevel, streams, pino); 139 160 if (error !== undefined) { 140 161 logger.warn(error); 141 162 } ··· 170 191 error = e; 171 192 } 172 193 } 173 - const logger = buildLogger('debug' as LogLevel, streams, pino); 194 + const logger = buildLogger('trace' as LogLevel, streams, pino); 174 195 if (error !== undefined) { 175 196 logger.warn(error); 176 197 }
+2 -1
src/types.ts
··· 7 7 * 8 8 * From lowest to highest: 9 9 * 10 + * * `trace` 10 11 * * `debug` 11 12 * * `verbose` 12 13 * * `log` ··· 48 49 49 50 const CUSTOM_LEVEL_NAMES = Object.keys(CUSTOM_LEVELS); 50 51 51 - export const LOG_LEVEL_NAMES= ['silent', 'fatal', 'error', 'warn', 'info', 'log', 'verbose', 'debug'] as const; 52 + export const LOG_LEVEL_NAMES= ['silent', 'fatal', 'error', 'warn', 'info', 'log', 'verbose', 'debug', 'trace'] as const; 52 53 53 54 /** 54 55 * Configure log levels and file options for an AppLogger.
+2 -2
tests/index.test.ts
··· 32 32 const opts = parseLogOptions(config, {logBaseDir: process.cwd()}); 33 33 const testStream = new PassThrough(); 34 34 const rawStream = new PassThrough(); 35 - const logger = buildLogger('debug', [ 35 + const logger = buildLogger('trace', [ 36 36 buildDestinationStream( 37 37 opts.console, 38 38 { ··· 53 53 const opts = parseLogOptions(config, {logBaseDir: process.cwd()}); 54 54 const testStream = new PassThrough({objectMode: true}); 55 55 const rawStream = new PassThrough(); 56 - const logger = buildLogger('debug', [ 56 + const logger = buildLogger('trace', [ 57 57 buildDestinationJsonPrettyStream( 58 58 opts.console, 59 59 {