@nx-ddd/logging 19.35.0 → 19.36.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.
@@ -1 +1 @@
1
- {"version":3,"file":"nx-ddd-logging.mjs","sources":["../../../../../packages/@nx-ddd/logging/src/lib/base/interfaces.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/base.logger.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/log-filter.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/providers.ts","../../../../../packages/@nx-ddd/logging/src/lib/logging.service.ts","../../../../../packages/@nx-ddd/logging/src/lib/global-logging.ts","../../../../../packages/@nx-ddd/logging/src/lib/nx-ddd-logging.ts"],"sourcesContent":["/**\n * LoggingService interfaces\n *\n * Provides structured logging with different log levels and file output\n */\n\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3,\n FATAL = 4,\n}\n\nexport interface LogContext {\n component?: string;\n sessionId?: string;\n clientId?: string;\n [key: string]: any;\n}\n\nexport interface ILoggingService {\n /**\n * Log debug message (for development/troubleshooting)\n */\n debug(message: string, context?: LogContext): void;\n\n /**\n * Log informational message\n */\n info(message: string, context?: LogContext): void;\n\n /**\n * Log warning message\n */\n warn(message: string, context?: LogContext): void;\n\n /**\n * Log error message\n */\n error(message: string, error?: Error, context?: LogContext): void;\n\n /**\n * Log fatal error message (application cannot continue)\n */\n fatal(message: string, error?: Error, context?: LogContext): void;\n\n /**\n * Set log level filter\n */\n setLogLevel(level: LogLevel): void;\n\n /**\n * Set component name for this logger\n */\n setComponent(component: string): void;\n\n /**\n * Close logger and flush buffers\n */\n close(): void;\n}\n","/**\n * Base Logger class for multi-provider logging system\n */\n\nimport { Injectable, InjectionToken, Provider } from '@angular/core';\nimport { LogLevel, LogContext } from './interfaces';\n\nexport const LOGGER = new InjectionToken<BaseLogger>('Logger');\n\n@Injectable()\nexport abstract class BaseLogger {\n /**\n * Main log method that all loggers must implement\n */\n abstract log(\n level: LogLevel,\n message: string,\n context?: LogContext,\n error?: Error\n ): void;\n\n /**\n * Close logger and flush buffers\n */\n abstract close(): void;\n\n // Convenience methods\n debug(message: string, context?: LogContext): void {\n this.log(LogLevel.DEBUG, message, context);\n }\n\n info(message: string, context?: LogContext): void {\n this.log(LogLevel.INFO, message, context);\n }\n\n warn(message: string, context?: LogContext): void {\n this.log(LogLevel.WARN, message, context);\n }\n\n error(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.ERROR, message, context, error);\n }\n\n fatal(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.FATAL, message, context, error);\n }\n}\n\nexport function provideLogger(useFactory: () => BaseLogger): Provider {\n return {\n provide: LOGGER,\n multi: true,\n useFactory,\n };\n}\n","/**\n * LogFilter - Simple function-based log filtering\n */\n\nimport { InjectionToken } from '@angular/core';\nimport { LogLevel, LogContext } from './interfaces';\n\n/**\n * Log filter function type\n * @param level - The log level\n * @param context - Optional log context (component name, etc.)\n * @returns true if the log should be output, false to suppress\n */\nexport type LogFilterFn = (level: LogLevel, context?: LogContext) => boolean;\n\nexport const LOG_FILTER = new InjectionToken<LogFilterFn>('LogFilter');\n","/**\n * Provider functions for log filtering\n */\n\nimport { Provider } from '@angular/core';\nimport { LogLevel } from './interfaces';\nimport { LOG_FILTER, LogFilterFn } from './log-filter';\n\n/**\n * Provide a log filter function\n *\n * @example\n * // Filter by log level\n * provideLogFilter((level) => level >= LogLevel.WARN)\n *\n * @example\n * // Filter by component\n * provideLogFilter((level, context) => context?.component?.startsWith('My'))\n *\n * @example\n * // Allow all logs\n * provideLogFilter(() => true)\n */\nexport function provideLogFilter(filter: LogFilterFn): Provider {\n return { provide: LOG_FILTER, useValue: filter };\n}\n\n/**\n * Configuration for log filtering\n */\nexport interface LogFilterConfig {\n minLevel?: LogLevel;\n componentPattern?: string;\n}\n\n/**\n * Provide a log filter with explicit configuration\n * @param config - Filter configuration (minLevel defaults to WARN)\n */\nexport function provideLogFilterWithConfig(config?: LogFilterConfig): Provider {\n const minLevel = config?.minLevel ?? LogLevel.WARN;\n const componentRegex = config?.componentPattern ? new RegExp(config.componentPattern) : null;\n\n return provideLogFilter((level, context) => {\n if (level < minLevel) return false;\n if (componentRegex && context?.component && !componentRegex.test(context.component)) {\n return false;\n }\n return true;\n });\n}\n\n/**\n * @deprecated Use provideLogFilterWithConfig() instead.\n * This function directly accesses process.env which violates the rule\n * that packages should not access environment variables directly.\n *\n * Migration example:\n * ```typescript\n * // Before (in packages)\n * provideLogFilterFromEnv()\n *\n * // After (in application layer)\n * provideLogFilterWithConfig({\n * minLevel: process.env['LOG_LEVEL'] ? LogLevel[process.env['LOG_LEVEL'].toUpperCase()] : undefined,\n * componentPattern: process.env['LOG_COMPONENTS']\n * })\n * ```\n */\nexport function provideLogFilterFromEnv(): Provider {\n console.warn('[DEPRECATED] provideLogFilterFromEnv() is deprecated. Use provideLogFilterWithConfig() instead.');\n return provideLogFilterWithConfig();\n}\n","import { inject, Injectable, InjectionToken } from \"@angular/core\";\nimport { BaseLogger, ILoggingService, LogContext, LOGGER, LogLevel, LOG_FILTER, LogFilterFn } from \"@nx-ddd/logging/base\";\n\nexport const LOGGING_SERVICE = new InjectionToken<ILoggingService>('LoggingService');\n\nexport interface Logger {\n log: (...args: Parameters<typeof console['log']>) => void;\n debug: (...args: Parameters<typeof console['debug']>) => void;\n info: (...args: Parameters<typeof console['info']>) => void;\n warn: (...args: Parameters<typeof console['warn']>) => void;\n error: (...args: Parameters<typeof console['error']>) => void;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class LoggingService implements ILoggingService {\n private loggers = inject<BaseLogger[]>(LOGGER, { optional: true }) ?? [];\n private filter = inject<LogFilterFn>(LOG_FILTER, { optional: true });\n\n getLogger(name: string): Logger {\n const format = (...args: Parameters<typeof console['log']>) => {\n return args.map(arg => {\n if (typeof arg === 'string') return arg;\n if (arg === undefined) return 'undefined';\n if (arg === null) return 'null';\n const serialized = JSON.stringify(arg);\n return serialized !== undefined ? serialized : String(arg);\n }).join(' ');\n };\n\n return {\n log: (...args) => this.log(LogLevel.DEBUG, format(`[${name}]`, ...args)),\n debug: (...args) => this.log(LogLevel.DEBUG, format(`[${name}]`, ...args)),\n info: (...args) => this.log(LogLevel.INFO, format(`[${name}]`, ...args)),\n warn: (...args) => this.log(LogLevel.WARN, format(`[${name}]`, ...args)),\n error: (...args) => this.log(LogLevel.ERROR, format(`[${name}]`, ...args)),\n };\n }\n\n log(level: LogLevel, message: string, context?: LogContext, error?: Error): void {\n // Apply filtering at service level if LogFilter is provided\n if (this.filter && !this.filter(level, context)) return;\n\n this.loggers.forEach(logger => logger.log(level, message, context, error));\n }\n\n close(): void {\n this.loggers.forEach(logger => logger.close());\n }\n\n debug(message: string, context?: LogContext): void {\n this.log(LogLevel.DEBUG, message, context);\n }\n\n info(message: string, context?: LogContext): void {\n this.log(LogLevel.INFO, message, context);\n }\n\n warn(message: string, context?: LogContext): void {\n this.log(LogLevel.WARN, message, context);\n }\n\n error(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.ERROR, message, context, error);\n }\n\n fatal(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.FATAL, message, context, error);\n }\n\n setLogLevel(_level: LogLevel): void {\n // this.loggers.forEach(logger => logger.setLogLevel(level));\n }\n\n setComponent(_component: string): void {\n // this.loggers.forEach(logger => logger.setComponent(component));\n }\n}\n","import { EnvironmentProviders, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';\nimport { ILoggingService } from '@nx-ddd/logging/base';\nimport { Logger, LoggingService } from './logging.service';\n\nlet globalLogging: LoggingService | null = null;\nexport { globalLogging as logging };\n\nexport function setGlobalLogging(logging: LoggingService): void {\n globalLogging = logging;\n}\n\nexport function getGlobalLogging(): LoggingService | null {\n return globalLogging;\n}\n\nexport function createLogger(name: any): ILoggingService {\n return globalLogging;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\nconst noopLogger: Logger = { log: noop, debug: noop, info: noop, warn: noop, error: noop };\n\nexport function getLogger(name: string): Logger {\n return globalLogging?.getLogger(name) ?? noopLogger;\n}\n\nexport function provideGlobalLogging(): EnvironmentProviders {\n return makeEnvironmentProviders([\n provideAppInitializer(() => {\n return setGlobalLogging(inject(LoggingService));\n })\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["LOGGER","LOG_FILTER","LogLevel"],"mappings":";;;;AAAA;;;;AAIG;IAES;AAAZ,CAAA,UAAY,QAAQ,EAAA;AAClB,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACT,IAAA,QAAA,CAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,QAAA,CAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACT,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACX,CAAC,EANW,QAAQ,KAAR,QAAQ,GAAA,EAAA,CAAA,CAAA;;ACNpB;;AAEG;MAKU,MAAM,GAAG,IAAI,cAAc,CAAa,QAAQ;MAGvC,UAAU,CAAA;;IAiB9B,KAAK,CAAC,OAAe,EAAE,OAAoB,EAAA;QACzC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC;IAC5C;IAEA,IAAI,CAAC,OAAe,EAAE,OAAoB,EAAA;QACxC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;IAC3C;IAEA,IAAI,CAAC,OAAe,EAAE,OAAoB,EAAA;QACxC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,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aAAa;AACtB;AAEM,SAAU,YAAY,CAAC,IAAS,EAAA;AACpC,IAAA,OAAO,aAAa;AACtB;AAEA;AACA,MAAM,IAAI,GAAG,MAAK,EAAE,CAAC;AACrB,MAAM,UAAU,GAAW,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AAEpF,SAAU,SAAS,CAAC,IAAY,EAAA;IACpC,OAAO,aAAa,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,UAAU;AACrD;SAEgB,oBAAoB,GAAA;AAClC,IAAA,OAAO,wBAAwB,CAAC;QAC9B,qBAAqB,CAAC,MAAK;AACzB,YAAA,OAAO,gBAAgB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AACjD,QAAA,CAAC;AACF,KAAA,CAAC;AACJ;;ACjCA;;AAEG;;;;"}
1
+ {"version":3,"file":"nx-ddd-logging.mjs","sources":["../../../../../packages/@nx-ddd/logging/src/lib/base/interfaces.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/base.logger.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/log-filter.ts","../../../../../packages/@nx-ddd/logging/src/lib/base/providers.ts","../../../../../packages/@nx-ddd/logging/src/lib/logging.service.ts","../../../../../packages/@nx-ddd/logging/src/lib/global-logging.ts","../../../../../packages/@nx-ddd/logging/src/lib/nx-ddd-logging.ts"],"sourcesContent":["/**\n * LoggingService interfaces\n *\n * Provides structured logging with different log levels and file output\n */\n\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3,\n FATAL = 4,\n}\n\nexport interface LogContext {\n component?: string;\n sessionId?: string;\n clientId?: string;\n [key: string]: any;\n}\n\nexport interface ILoggingService {\n /**\n * Log debug message (for development/troubleshooting)\n */\n debug(message: string, context?: LogContext): void;\n\n /**\n * Log informational message\n */\n info(message: string, context?: LogContext): void;\n\n /**\n * Log warning message\n */\n warn(message: string, context?: LogContext): void;\n\n /**\n * Log error message\n */\n error(message: string, error?: Error, context?: LogContext): void;\n\n /**\n * Log fatal error message (application cannot continue)\n */\n fatal(message: string, error?: Error, context?: LogContext): void;\n\n /**\n * Set log level filter\n */\n setLogLevel(level: LogLevel): void;\n\n /**\n * Set component name for this logger\n */\n setComponent(component: string): void;\n\n /**\n * Close logger and flush buffers\n */\n close(): void;\n}\n","/**\n * Base Logger class for multi-provider logging system\n */\n\nimport { Injectable, InjectionToken, Provider } from '@angular/core';\nimport { LogLevel, LogContext } from './interfaces';\n\nexport const LOGGER = new InjectionToken<BaseLogger>('Logger');\n\n@Injectable()\nexport abstract class BaseLogger {\n /**\n * Main log method that all loggers must implement\n */\n abstract log(\n level: LogLevel,\n message: string,\n context?: LogContext,\n error?: Error\n ): void;\n\n /**\n * Close logger and flush buffers\n */\n abstract close(): void;\n\n // Convenience methods\n debug(message: string, context?: LogContext): void {\n this.log(LogLevel.DEBUG, message, context);\n }\n\n info(message: string, context?: LogContext): void {\n this.log(LogLevel.INFO, message, context);\n }\n\n warn(message: string, context?: LogContext): void {\n this.log(LogLevel.WARN, message, context);\n }\n\n error(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.ERROR, message, context, error);\n }\n\n fatal(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.FATAL, message, context, error);\n }\n}\n\nexport function provideLogger(useFactory: () => BaseLogger): Provider {\n return {\n provide: LOGGER,\n multi: true,\n useFactory,\n };\n}\n","/**\n * LogFilter - Simple function-based log filtering\n */\n\nimport { InjectionToken } from '@angular/core';\nimport { LogLevel, LogContext } from './interfaces';\n\n/**\n * Log filter function type\n * @param level - The log level\n * @param context - Optional log context (component name, etc.)\n * @returns true if the log should be output, false to suppress\n */\nexport type LogFilterFn = (level: LogLevel, context?: LogContext) => boolean;\n\nexport const LOG_FILTER = new InjectionToken<LogFilterFn>('LogFilter');\n","/**\n * Provider functions for log filtering\n */\n\nimport { Provider } from '@angular/core';\nimport { LogLevel } from './interfaces';\nimport { LOG_FILTER, LogFilterFn } from './log-filter';\n\n/**\n * Provide a log filter function\n *\n * @example\n * // Filter by log level\n * provideLogFilter((level) => level >= LogLevel.WARN)\n *\n * @example\n * // Filter by component\n * provideLogFilter((level, context) => context?.component?.startsWith('My'))\n *\n * @example\n * // Allow all logs\n * provideLogFilter(() => true)\n */\nexport function provideLogFilter(filter: LogFilterFn): Provider {\n return { provide: LOG_FILTER, useValue: filter };\n}\n\n/**\n * Configuration for log filtering\n */\nexport interface LogFilterConfig {\n minLevel?: LogLevel;\n componentPattern?: string;\n}\n\n/**\n * Provide a log filter with explicit configuration\n * @param config - Filter configuration (minLevel defaults to WARN)\n */\nexport function provideLogFilterWithConfig(config?: LogFilterConfig): Provider {\n const minLevel = config?.minLevel ?? LogLevel.WARN;\n const componentRegex = config?.componentPattern ? new RegExp(config.componentPattern) : null;\n\n return provideLogFilter((level, context) => {\n if (level < minLevel) return false;\n if (componentRegex && context?.component && !componentRegex.test(context.component)) {\n return false;\n }\n return true;\n });\n}\n\n/**\n * @deprecated Use provideLogFilterWithConfig() instead.\n * This function directly accesses process.env which violates the rule\n * that packages should not access environment variables directly.\n *\n * Migration example:\n * ```typescript\n * // Before (in packages)\n * provideLogFilterFromEnv()\n *\n * // After (in application layer)\n * provideLogFilterWithConfig({\n * minLevel: process.env['LOG_LEVEL'] ? LogLevel[process.env['LOG_LEVEL'].toUpperCase()] : undefined,\n * componentPattern: process.env['LOG_COMPONENTS']\n * })\n * ```\n */\nexport function provideLogFilterFromEnv(): Provider {\n console.warn('[DEPRECATED] provideLogFilterFromEnv() is deprecated. Use provideLogFilterWithConfig() instead.');\n return provideLogFilterWithConfig();\n}\n","import { inject, Injectable, InjectionToken } from \"@angular/core\";\nimport { BaseLogger, ILoggingService, LogContext, LOGGER, LogLevel, LOG_FILTER, LogFilterFn } from \"@nx-ddd/logging/base\";\n\nexport const LOGGING_SERVICE = new InjectionToken<ILoggingService>('LoggingService');\n\nexport interface Logger {\n log: (...args: Parameters<typeof console['log']>) => void;\n debug: (...args: Parameters<typeof console['debug']>) => void;\n info: (...args: Parameters<typeof console['info']>) => void;\n warn: (...args: Parameters<typeof console['warn']>) => void;\n error: (...args: Parameters<typeof console['error']>) => void;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class LoggingService implements ILoggingService {\n private loggers = inject<BaseLogger[]>(LOGGER, { optional: true }) ?? [];\n private filter = inject<LogFilterFn>(LOG_FILTER, { optional: true });\n\n getLogger(name: string): Logger {\n const format = (...args: Parameters<typeof console['log']>) => {\n return args.map(arg => {\n if (typeof arg === 'string') return arg;\n if (arg === undefined) return 'undefined';\n if (arg === null) return 'null';\n const serialized = JSON.stringify(arg);\n return serialized !== undefined ? serialized : String(arg);\n }).join(' ');\n };\n\n return {\n log: (...args) => this.log(LogLevel.DEBUG, format(`[${name}]`, ...args)),\n debug: (...args) => this.log(LogLevel.DEBUG, format(`[${name}]`, ...args)),\n info: (...args) => this.log(LogLevel.INFO, format(`[${name}]`, ...args)),\n warn: (...args) => this.log(LogLevel.WARN, format(`[${name}]`, ...args)),\n error: (...args) => this.log(LogLevel.ERROR, format(`[${name}]`, ...args)),\n };\n }\n\n log(level: LogLevel, message: string, context?: LogContext, error?: Error): void {\n // Apply filtering at service level if LogFilter is provided\n if (this.filter && !this.filter(level, context)) return;\n\n this.loggers.forEach(logger => logger.log(level, message, context, error));\n }\n\n close(): void {\n this.loggers.forEach(logger => logger.close());\n }\n\n debug(message: string, context?: LogContext): void {\n this.log(LogLevel.DEBUG, message, context);\n }\n\n info(message: string, context?: LogContext): void {\n this.log(LogLevel.INFO, message, context);\n }\n\n warn(message: string, context?: LogContext): void {\n this.log(LogLevel.WARN, message, context);\n }\n\n error(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.ERROR, message, context, error);\n }\n\n fatal(message: string, error?: Error, context?: LogContext): void {\n this.log(LogLevel.FATAL, message, context, error);\n }\n\n setLogLevel(_level: LogLevel): void {\n // this.loggers.forEach(logger => logger.setLogLevel(level));\n }\n\n setComponent(_component: string): void {\n // this.loggers.forEach(logger => logger.setComponent(component));\n }\n}\n","import { EnvironmentProviders, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';\nimport { ILoggingService } from '@nx-ddd/logging/base';\nimport { Logger, LoggingService } from './logging.service';\n\nlet globalLogging: LoggingService | null = null;\nexport { globalLogging as logging };\n\nexport function setGlobalLogging(logging: LoggingService): void {\n globalLogging = logging;\n}\n\nexport function getGlobalLogging(): LoggingService | null {\n return globalLogging;\n}\n\nexport function createLogger(name: any): ILoggingService | null {\n return globalLogging;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\nconst noopLogger: Logger = { log: noop, debug: noop, info: noop, warn: noop, error: noop };\n\nexport function getLogger(name: string): Logger {\n return globalLogging?.getLogger(name) ?? noopLogger;\n}\n\nexport function provideGlobalLogging(): EnvironmentProviders {\n return makeEnvironmentProviders([\n provideAppInitializer(() => {\n return setGlobalLogging(inject(LoggingService));\n })\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["LOGGER","LOG_FILTER","LogLevel"],"mappings":";;;;AAAA;;;;AAIG;IAES;AAAZ,CAAA,UAAY,QAAQ,EAAA;AAClB,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACT,IAAA,QAAA,CAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,QAAA,CAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACT,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACX,CAAC,EANW,QAAQ,KAAR,QAAQ,GAAA,E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AA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAd,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,cAAc,cADD,MAAM,EAAA,CAAA;;2FACnB,cAAc,EAAA,UAAA,EAAA,CAAA;kBAD1B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACTlC,IAAI,aAAa,GAA0B;AAGrC,SAAU,gBAAgB,CAAC,OAAuB,EAAA;IACtD,aAAa,GAAG,OAAO;AACzB;SAEgB,gBAAgB,GAAA;AAC9B,IAAA,OAAO,aAAa;AACtB;AAEM,SAAU,YAAY,CAAC,IAAS,EAAA;AACpC,IAAA,OAAO,aAAa;AACtB;AAEA;AACA,MAAM,IAAI,GAAG,MAAK,EAAE,CAAC;AACrB,MAAM,UAAU,GAAW,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AAEpF,SAAU,SAAS,CAAC,IAAY,EAAA;IACpC,OAAO,aAAa,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,UAAU;AACrD;SAEgB,oBAAoB,GAAA;AAClC,IAAA,OAAO,wBAAwB,CAAC;QAC9B,qBAAqB,CAAC,MAAK;AACzB,YAAA,OAAO,gBAAgB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;AACjD,QAAA,CAAC;AACF,KAAA,CAAC;AACJ;;ACjCA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx-ddd/logging",
3
- "version": "19.35.0",
3
+ "version": "19.36.0",
4
4
  "license": "MIT",
5
5
  "peerDependencies": {
6
6
  "@angular/core": "19.1.4"
@@ -172,7 +172,7 @@ declare let globalLogging: LoggingService | null;
172
172
 
173
173
  declare function setGlobalLogging(logging: LoggingService): void;
174
174
  declare function getGlobalLogging(): LoggingService | null;
175
- declare function createLogger(name: any): ILoggingService$1;
175
+ declare function createLogger(name: any): ILoggingService$1 | null;
176
176
  declare function getLogger(name: string): Logger;
177
177
  declare function provideGlobalLogging(): EnvironmentProviders;
178
178