@geekmidas/logger 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +114 -7
  2. package/dist/console.cjs +75 -17
  3. package/dist/console.cjs.map +1 -1
  4. package/dist/console.d.cts +31 -7
  5. package/dist/console.d.mts +31 -7
  6. package/dist/console.mjs +76 -18
  7. package/dist/console.mjs.map +1 -1
  8. package/dist/index.d.cts +2 -2
  9. package/dist/index.d.mts +2 -2
  10. package/dist/pino.cjs +42 -1
  11. package/dist/pino.cjs.map +1 -1
  12. package/dist/pino.d.cts +23 -3
  13. package/dist/pino.d.mts +23 -3
  14. package/dist/pino.mjs +42 -2
  15. package/dist/pino.mjs.map +1 -1
  16. package/dist/redact-paths-Br-tI2GZ.d.cts +18 -0
  17. package/dist/redact-paths-CIsuxHH7.d.mts +18 -0
  18. package/dist/redact-paths-D0m0DIuQ.cjs +73 -0
  19. package/dist/redact-paths-D0m0DIuQ.cjs.map +1 -0
  20. package/dist/redact-paths-DQoIXhkS.mjs +67 -0
  21. package/dist/redact-paths-DQoIXhkS.mjs.map +1 -0
  22. package/dist/redact-paths.cjs +3 -0
  23. package/dist/redact-paths.d.cts +2 -0
  24. package/dist/redact-paths.d.mts +2 -0
  25. package/dist/redact-paths.mjs +3 -0
  26. package/dist/{types-C1RfRbo6.d.mts → types-Bga8WDuP.d.mts} +86 -2
  27. package/dist/{types-DXdmn7h5.d.cts → types-JxCFymH0.d.cts} +86 -2
  28. package/dist/types-ag_0Cvbg.cjs.map +1 -1
  29. package/dist/types-yQ6XOihF.mjs.map +1 -1
  30. package/dist/types.d.cts +2 -2
  31. package/dist/types.d.mts +2 -2
  32. package/package.json +10 -1
  33. package/src/__tests__/console.spec.ts +277 -140
  34. package/src/__tests__/pino-redaction.integration.spec.ts +307 -0
  35. package/src/__tests__/pino.spec.ts +199 -0
  36. package/src/console.ts +95 -23
  37. package/src/index.ts +1 -0
  38. package/src/pino.ts +105 -2
  39. package/src/redact-paths.ts +71 -0
  40. package/src/types.ts +87 -0
@@ -1 +1 @@
1
- {"version":3,"file":"types-ag_0Cvbg.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Logging function type that supports both structured and simple logging.\n * Can be called with an object for structured logging or just a message string.\n *\n * @example\n * ```typescript\n * // Structured logging with context object\n * logger.info({ userId: 123, action: 'login' }, 'User logged in');\n *\n * // Simple string logging\n * logger.info('Application started');\n * ```\n */\nexport type LogFn = {\n /** Structured logging with context object, optional message, and additional arguments */\n <T extends object>(obj: T, msg?: string, ...args: any[]): void;\n /** Simple string logging */\n (msg: string): void;\n};\n\n/**\n * Standard logger interface with multiple log levels and child logger support.\n * Follows common logging patterns with structured logging capabilities.\n *\n * @interface Logger\n */\nexport interface Logger {\n /** Debug level logging - verbose information for debugging */\n debug: LogFn;\n /** Info level logging - general informational messages */\n info: LogFn;\n /** Warning level logging - potentially harmful situations */\n warn: LogFn;\n /** Error level logging - error events that might still allow the application to continue */\n error: LogFn;\n /** Fatal level logging - severe errors that will likely cause the application to abort */\n fatal: LogFn;\n /** Trace level logging - most detailed information */\n trace: LogFn;\n /**\n * Creates a child logger with additional context.\n * Child loggers inherit parent context and add their own.\n *\n * @param obj - Additional context to include in all child logger calls\n * @returns A new Logger instance with merged context\n */\n child: (obj: object) => Logger;\n}\n\n/**\n * Console-based logger implementation that outputs to standard console methods.\n * Supports structured logging with automatic timestamp injection and context inheritance.\n *\n * @implements {Logger}\n *\n * @example\n * ```typescript\n * const logger = new ConsoleLogger({ app: 'myApp', version: '1.0.0' });\n * logger.info({ userId: 123 }, 'User action performed');\n * // Output: { app: 'myApp', version: '1.0.0', userId: 123, ts: 1234567890 } User action performed\n *\n * const childLogger = logger.child({ module: 'auth' });\n * childLogger.debug({ action: 'validate' }, 'Validating token');\n * // Output: { app: 'myApp', version: '1.0.0', module: 'auth', action: 'validate', ts: 1234567891 } Validating token\n * ```\n */\nexport enum LogLevel {\n Trace = 'trace',\n Debug = 'debug',\n Info = 'info',\n Warn = 'warn',\n Error = 'error',\n Fatal = 'fatal',\n Silent = 'silent',\n}\n\nexport type CreateLoggerOptions = {\n pretty?: boolean;\n level?: LogLevel;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkEA,IAAY,gDAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
1
+ {"version":3,"file":"types-ag_0Cvbg.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Logging function type that supports both structured and simple logging.\n * Can be called with an object for structured logging or just a message string.\n *\n * @example\n * ```typescript\n * // Structured logging with context object\n * logger.info({ userId: 123, action: 'login' }, 'User logged in');\n *\n * // Simple string logging\n * logger.info('Application started');\n * ```\n */\nexport type LogFn = {\n /** Structured logging with context object, optional message, and additional arguments */\n <T extends object>(obj: T, msg?: string, ...args: any[]): void;\n /** Simple string logging */\n (msg: string): void;\n};\n\n/**\n * Standard logger interface with multiple log levels and child logger support.\n * Follows common logging patterns with structured logging capabilities.\n *\n * @interface Logger\n */\nexport interface Logger {\n /** Debug level logging - verbose information for debugging */\n debug: LogFn;\n /** Info level logging - general informational messages */\n info: LogFn;\n /** Warning level logging - potentially harmful situations */\n warn: LogFn;\n /** Error level logging - error events that might still allow the application to continue */\n error: LogFn;\n /** Fatal level logging - severe errors that will likely cause the application to abort */\n fatal: LogFn;\n /** Trace level logging - most detailed information */\n trace: LogFn;\n /**\n * Creates a child logger with additional context.\n * Child loggers inherit parent context and add their own.\n *\n * @param obj - Additional context to include in all child logger calls\n * @returns A new Logger instance with merged context\n */\n child: (obj: object) => Logger;\n}\n\n/**\n * Console-based logger implementation that outputs to standard console methods.\n * Supports structured logging with automatic timestamp injection and context inheritance.\n *\n * @implements {Logger}\n *\n * @example\n * ```typescript\n * const logger = new ConsoleLogger({ app: 'myApp', version: '1.0.0' });\n * logger.info({ userId: 123 }, 'User action performed');\n * // Output: { app: 'myApp', version: '1.0.0', userId: 123, ts: 1234567890 } User action performed\n *\n * const childLogger = logger.child({ module: 'auth' });\n * childLogger.debug({ action: 'validate' }, 'Validating token');\n * // Output: { app: 'myApp', version: '1.0.0', module: 'auth', action: 'validate', ts: 1234567891 } Validating token\n * ```\n */\nexport enum LogLevel {\n Trace = 'trace',\n Debug = 'debug',\n Info = 'info',\n Warn = 'warn',\n Error = 'error',\n Fatal = 'fatal',\n Silent = 'silent',\n}\n\n/**\n * Redaction configuration for masking sensitive data in logs.\n * Uses pino's fast-redact library under the hood.\n *\n * By default, custom paths are merged with the default sensitive paths.\n * Use `resolution: 'override'` to use only your custom paths.\n *\n * @example\n * ```typescript\n * // Simple path array (merges with defaults)\n * redact: ['user.ssn', 'custom.field']\n *\n * // Override defaults completely\n * redact: {\n * paths: ['only.these.paths'],\n * resolution: 'override',\n * }\n *\n * // With custom censor\n * redact: {\n * paths: ['extra.secret'],\n * censor: '***',\n * }\n *\n * // Remove fields entirely\n * redact: {\n * paths: ['temporary.data'],\n * remove: true,\n * }\n * ```\n */\nexport type RedactOptions =\n | string[]\n | {\n /** Paths to redact using dot notation or bracket notation for special chars */\n paths: string[];\n /** Custom replacement text (default: '[REDACTED]') */\n censor?: string | ((value: unknown, path: string[]) => unknown);\n /** Remove the field entirely instead of replacing (default: false) */\n remove?: boolean;\n /**\n * How to combine custom paths with default sensitive paths.\n * - 'merge': Custom paths are added to default paths (default)\n * - 'override': Only custom paths are used, defaults are ignored\n */\n resolution?: 'merge' | 'override';\n };\n\nexport type CreateLoggerOptions = {\n /** Enable pretty printing with colors (disabled in production) */\n pretty?: boolean;\n /** Minimum log level to output */\n level?: LogLevel;\n /**\n * Redaction configuration for masking sensitive data.\n *\n * - `true`: Uses default sensitive paths (password, token, secret, etc.)\n * - `false` or `undefined`: No redaction applied\n * - `string[]`: Custom paths merged with defaults\n * - `object`: Advanced config with paths, censor, remove, and resolution options\n *\n * By default, custom paths are **merged** with the default sensitive paths.\n * Use `resolution: 'override'` to disable defaults and use only your paths.\n *\n * @example\n * ```typescript\n * // Use defaults only\n * createLogger({ redact: true });\n *\n * // Add custom paths (merged with defaults)\n * createLogger({ redact: ['user.ssn', 'custom.field'] });\n *\n * // Override defaults completely\n * createLogger({\n * redact: {\n * paths: ['only.these.paths'],\n * resolution: 'override',\n * }\n * });\n *\n * // Merge with custom censor\n * createLogger({\n * redact: {\n * paths: ['extra.secret'],\n * censor: '***',\n * }\n * });\n * ```\n */\n redact?: boolean | RedactOptions;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkEA,IAAY,gDAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"types-yQ6XOihF.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Logging function type that supports both structured and simple logging.\n * Can be called with an object for structured logging or just a message string.\n *\n * @example\n * ```typescript\n * // Structured logging with context object\n * logger.info({ userId: 123, action: 'login' }, 'User logged in');\n *\n * // Simple string logging\n * logger.info('Application started');\n * ```\n */\nexport type LogFn = {\n /** Structured logging with context object, optional message, and additional arguments */\n <T extends object>(obj: T, msg?: string, ...args: any[]): void;\n /** Simple string logging */\n (msg: string): void;\n};\n\n/**\n * Standard logger interface with multiple log levels and child logger support.\n * Follows common logging patterns with structured logging capabilities.\n *\n * @interface Logger\n */\nexport interface Logger {\n /** Debug level logging - verbose information for debugging */\n debug: LogFn;\n /** Info level logging - general informational messages */\n info: LogFn;\n /** Warning level logging - potentially harmful situations */\n warn: LogFn;\n /** Error level logging - error events that might still allow the application to continue */\n error: LogFn;\n /** Fatal level logging - severe errors that will likely cause the application to abort */\n fatal: LogFn;\n /** Trace level logging - most detailed information */\n trace: LogFn;\n /**\n * Creates a child logger with additional context.\n * Child loggers inherit parent context and add their own.\n *\n * @param obj - Additional context to include in all child logger calls\n * @returns A new Logger instance with merged context\n */\n child: (obj: object) => Logger;\n}\n\n/**\n * Console-based logger implementation that outputs to standard console methods.\n * Supports structured logging with automatic timestamp injection and context inheritance.\n *\n * @implements {Logger}\n *\n * @example\n * ```typescript\n * const logger = new ConsoleLogger({ app: 'myApp', version: '1.0.0' });\n * logger.info({ userId: 123 }, 'User action performed');\n * // Output: { app: 'myApp', version: '1.0.0', userId: 123, ts: 1234567890 } User action performed\n *\n * const childLogger = logger.child({ module: 'auth' });\n * childLogger.debug({ action: 'validate' }, 'Validating token');\n * // Output: { app: 'myApp', version: '1.0.0', module: 'auth', action: 'validate', ts: 1234567891 } Validating token\n * ```\n */\nexport enum LogLevel {\n Trace = 'trace',\n Debug = 'debug',\n Info = 'info',\n Warn = 'warn',\n Error = 'error',\n Fatal = 'fatal',\n Silent = 'silent',\n}\n\nexport type CreateLoggerOptions = {\n pretty?: boolean;\n level?: LogLevel;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkEA,IAAY,gDAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
1
+ {"version":3,"file":"types-yQ6XOihF.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["/**\n * Logging function type that supports both structured and simple logging.\n * Can be called with an object for structured logging or just a message string.\n *\n * @example\n * ```typescript\n * // Structured logging with context object\n * logger.info({ userId: 123, action: 'login' }, 'User logged in');\n *\n * // Simple string logging\n * logger.info('Application started');\n * ```\n */\nexport type LogFn = {\n /** Structured logging with context object, optional message, and additional arguments */\n <T extends object>(obj: T, msg?: string, ...args: any[]): void;\n /** Simple string logging */\n (msg: string): void;\n};\n\n/**\n * Standard logger interface with multiple log levels and child logger support.\n * Follows common logging patterns with structured logging capabilities.\n *\n * @interface Logger\n */\nexport interface Logger {\n /** Debug level logging - verbose information for debugging */\n debug: LogFn;\n /** Info level logging - general informational messages */\n info: LogFn;\n /** Warning level logging - potentially harmful situations */\n warn: LogFn;\n /** Error level logging - error events that might still allow the application to continue */\n error: LogFn;\n /** Fatal level logging - severe errors that will likely cause the application to abort */\n fatal: LogFn;\n /** Trace level logging - most detailed information */\n trace: LogFn;\n /**\n * Creates a child logger with additional context.\n * Child loggers inherit parent context and add their own.\n *\n * @param obj - Additional context to include in all child logger calls\n * @returns A new Logger instance with merged context\n */\n child: (obj: object) => Logger;\n}\n\n/**\n * Console-based logger implementation that outputs to standard console methods.\n * Supports structured logging with automatic timestamp injection and context inheritance.\n *\n * @implements {Logger}\n *\n * @example\n * ```typescript\n * const logger = new ConsoleLogger({ app: 'myApp', version: '1.0.0' });\n * logger.info({ userId: 123 }, 'User action performed');\n * // Output: { app: 'myApp', version: '1.0.0', userId: 123, ts: 1234567890 } User action performed\n *\n * const childLogger = logger.child({ module: 'auth' });\n * childLogger.debug({ action: 'validate' }, 'Validating token');\n * // Output: { app: 'myApp', version: '1.0.0', module: 'auth', action: 'validate', ts: 1234567891 } Validating token\n * ```\n */\nexport enum LogLevel {\n Trace = 'trace',\n Debug = 'debug',\n Info = 'info',\n Warn = 'warn',\n Error = 'error',\n Fatal = 'fatal',\n Silent = 'silent',\n}\n\n/**\n * Redaction configuration for masking sensitive data in logs.\n * Uses pino's fast-redact library under the hood.\n *\n * By default, custom paths are merged with the default sensitive paths.\n * Use `resolution: 'override'` to use only your custom paths.\n *\n * @example\n * ```typescript\n * // Simple path array (merges with defaults)\n * redact: ['user.ssn', 'custom.field']\n *\n * // Override defaults completely\n * redact: {\n * paths: ['only.these.paths'],\n * resolution: 'override',\n * }\n *\n * // With custom censor\n * redact: {\n * paths: ['extra.secret'],\n * censor: '***',\n * }\n *\n * // Remove fields entirely\n * redact: {\n * paths: ['temporary.data'],\n * remove: true,\n * }\n * ```\n */\nexport type RedactOptions =\n | string[]\n | {\n /** Paths to redact using dot notation or bracket notation for special chars */\n paths: string[];\n /** Custom replacement text (default: '[REDACTED]') */\n censor?: string | ((value: unknown, path: string[]) => unknown);\n /** Remove the field entirely instead of replacing (default: false) */\n remove?: boolean;\n /**\n * How to combine custom paths with default sensitive paths.\n * - 'merge': Custom paths are added to default paths (default)\n * - 'override': Only custom paths are used, defaults are ignored\n */\n resolution?: 'merge' | 'override';\n };\n\nexport type CreateLoggerOptions = {\n /** Enable pretty printing with colors (disabled in production) */\n pretty?: boolean;\n /** Minimum log level to output */\n level?: LogLevel;\n /**\n * Redaction configuration for masking sensitive data.\n *\n * - `true`: Uses default sensitive paths (password, token, secret, etc.)\n * - `false` or `undefined`: No redaction applied\n * - `string[]`: Custom paths merged with defaults\n * - `object`: Advanced config with paths, censor, remove, and resolution options\n *\n * By default, custom paths are **merged** with the default sensitive paths.\n * Use `resolution: 'override'` to disable defaults and use only your paths.\n *\n * @example\n * ```typescript\n * // Use defaults only\n * createLogger({ redact: true });\n *\n * // Add custom paths (merged with defaults)\n * createLogger({ redact: ['user.ssn', 'custom.field'] });\n *\n * // Override defaults completely\n * createLogger({\n * redact: {\n * paths: ['only.these.paths'],\n * resolution: 'override',\n * }\n * });\n *\n * // Merge with custom censor\n * createLogger({\n * redact: {\n * paths: ['extra.secret'],\n * censor: '***',\n * }\n * });\n * ```\n */\n redact?: boolean | RedactOptions;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkEA,IAAY,gDAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;;AACD"}
package/dist/types.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types-DXdmn7h5.cjs";
2
- export { CreateLoggerOptions, LogFn, LogLevel, Logger };
1
+ import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types-JxCFymH0.cjs";
2
+ export { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions };
package/dist/types.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types-C1RfRbo6.mjs";
2
- export { CreateLoggerOptions, LogFn, LogLevel, Logger };
1
+ import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types-Bga8WDuP.mjs";
2
+ export { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/logger",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "description": "A simple and flexible logging library for Node.js and the browser",
5
5
  "private": false,
6
6
  "type": "module",
@@ -19,8 +19,17 @@
19
19
  "types": "./dist/console.d.ts",
20
20
  "import": "./dist/console.mjs",
21
21
  "require": "./dist/console.cjs"
22
+ },
23
+ "./redact": {
24
+ "types": "./dist/redact-paths.d.ts",
25
+ "import": "./dist/redact-paths.mjs",
26
+ "require": "./dist/redact-paths.cjs"
22
27
  }
23
28
  },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/geekmidas/toolbox"
32
+ },
24
33
  "publishConfig": {
25
34
  "registry": "https://registry.npmjs.org/",
26
35
  "access": "public"