@zthun/lumberjacky-log 2.3.0 → 3.0.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.
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/log-entry/log-entry.spec.d.ts +1 -0
- package/dist/logger/logger-composite.spec.d.ts +1 -0
- package/dist/logger/logger-console.spec.d.ts +1 -0
- package/dist/logger/logger-context.spec.d.ts +1 -0
- package/dist/logger/logger-silent.spec.d.ts +1 -0
- package/package.json +6 -5
- /package/dist/{index.d.ts → index.d.mts} +0 -0
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/log-entry/log-entry.mts","../src/logger/logger-composite.mts","../src/logger/logger-console.mts","../src/logger/logger-context.mts","../src/logger/logger-silent.mts"],"sourcesContent":["/**\n * The log level.\n */\nexport enum ZLogLevel {\n /**\n * A fatal error.\n *\n * Someone's pager is going off at 2:00 in the\n * morning because the nuclear codes have gone off\n * and missiles have been launched.\n */\n CATASTROPHE = 0,\n\n /**\n * A normal error that cause usually be recovered from.\n *\n * May require a fire being put out or some immediate\n * response, but it is not world ending.\n */\n ERROR = 1,\n\n /**\n * Nothing is really wrong.\n *\n * Should probably not be ignored and\n * action should be taken, but it's not\n * serious enough to call the fire\n * department.\n */\n WARNING = 2,\n\n /**\n * Some information that's good to know.\n *\n * Analytic logs are in this zone and general\n * information goes in this zone. Debug as\n * well, goes into this zone.\n *\n * It is normally best to avoid this log level\n * unless it's really important to display.\n */\n INFO = 3,\n}\n\n/**\n * Represents a log entry.\n */\nexport interface IZLogEntry {\n /**\n * The log context.\n *\n * This will usually be a friendly name of a function\n * or class where this log took place.\n */\n context?: string;\n\n /**\n * The log level.\n */\n level: ZLogLevel;\n\n /**\n * The creation of this entry.\n */\n created: Date | string;\n\n /**\n * The log message.\n */\n message: string;\n}\n\n/**\n * Represents a builder for a log entry\n */\nexport class ZLogEntryBuilder {\n private _entry: IZLogEntry;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._entry = {\n level: ZLogLevel.ERROR,\n message: \"\",\n created: new Date().toJSON(),\n };\n }\n\n /**\n * Sets the log level.\n *\n * @param level -\n * The log level.\n *\n * @returns\n * This object.\n */\n public level(level: ZLogLevel) {\n this._entry.level = level;\n return this;\n }\n\n /**\n * Sets the log level to catastrophe.\n *\n * @returns\n * This object.\n */\n public catastrophe = this.level.bind(this, ZLogLevel.CATASTROPHE);\n\n /**\n * Sets the log level to error.\n *\n * @returns\n * This object.\n */\n public error = this.level.bind(this, ZLogLevel.ERROR);\n\n /**\n * Sets the log level to warning.\n *\n * @returns\n * This object.\n */\n public warning = this.level.bind(this, ZLogLevel.WARNING);\n\n /**\n * Sets the log level to info.\n *\n * @returns\n * This object.\n */\n public info = this.level.bind(this, ZLogLevel.INFO);\n\n /**\n * Sets the context of the entry.\n *\n * @param ctx -\n * The entry context.\n *\n * @returns\n * This object.\n */\n public context(ctx: string | undefined): this {\n this._entry.context = ctx;\n return this;\n }\n\n /**\n * Sets the message.\n *\n * @param msg -\n * The message to log.\n *\n * @returns\n * This object.\n */\n public message(msg: string): this {\n this._entry.message = msg;\n return this;\n }\n\n /**\n * Copies the other entry into the current entry.\n *\n * @param other -\n * The entry to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZLogEntry): this {\n this._entry = structuredClone(other);\n return this;\n }\n\n /**\n * Returns a copy of the built log entry.\n *\n * @returns\n * The built log entry.\n */\n public build(): IZLogEntry {\n return { ...this._entry };\n }\n}\n","import { IZLogEntry } from \"../log-entry/log-entry.mjs\";\nimport { IZLogger } from \"./logger.mjs\";\n\n/**\n * Represents a logger that logs to multiple sources.\n */\nexport class ZLoggerComposite implements IZLogger {\n /**\n * Initializes a new instance of this object.\n *\n * @param _children -\n * The collection of child loggers to log to.\n */\n public constructor(private readonly _children: IZLogger[]) {}\n\n /**\n * Logs the entry into every one of the child loggers.\n *\n * @param entry -\n * The entry to log.\n */\n public log(entry: IZLogEntry): void {\n this._children.forEach((logger) => logger.log(entry));\n }\n}\n","import { IZLogEntry
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/log-entry/log-entry.mts","../src/logger/logger-composite.mts","../src/logger/logger-console.mts","../src/logger/logger-context.mts","../src/logger/logger-silent.mts"],"sourcesContent":["/**\n * The log level.\n */\nexport enum ZLogLevel {\n /**\n * A fatal error.\n *\n * Someone's pager is going off at 2:00 in the\n * morning because the nuclear codes have gone off\n * and missiles have been launched.\n */\n CATASTROPHE = 0,\n\n /**\n * A normal error that cause usually be recovered from.\n *\n * May require a fire being put out or some immediate\n * response, but it is not world ending.\n */\n ERROR = 1,\n\n /**\n * Nothing is really wrong.\n *\n * Should probably not be ignored and\n * action should be taken, but it's not\n * serious enough to call the fire\n * department.\n */\n WARNING = 2,\n\n /**\n * Some information that's good to know.\n *\n * Analytic logs are in this zone and general\n * information goes in this zone. Debug as\n * well, goes into this zone.\n *\n * It is normally best to avoid this log level\n * unless it's really important to display.\n */\n INFO = 3,\n}\n\n/**\n * Represents a log entry.\n */\nexport interface IZLogEntry {\n /**\n * The log context.\n *\n * This will usually be a friendly name of a function\n * or class where this log took place.\n */\n context?: string;\n\n /**\n * The log level.\n */\n level: ZLogLevel;\n\n /**\n * The creation of this entry.\n */\n created: Date | string;\n\n /**\n * The log message.\n */\n message: string;\n}\n\n/**\n * Represents a builder for a log entry\n */\nexport class ZLogEntryBuilder {\n private _entry: IZLogEntry;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._entry = {\n level: ZLogLevel.ERROR,\n message: \"\",\n created: new Date().toJSON(),\n };\n }\n\n /**\n * Sets the log level.\n *\n * @param level -\n * The log level.\n *\n * @returns\n * This object.\n */\n public level(level: ZLogLevel) {\n this._entry.level = level;\n return this;\n }\n\n /**\n * Sets the log level to catastrophe.\n *\n * @returns\n * This object.\n */\n public catastrophe = this.level.bind(this, ZLogLevel.CATASTROPHE);\n\n /**\n * Sets the log level to error.\n *\n * @returns\n * This object.\n */\n public error = this.level.bind(this, ZLogLevel.ERROR);\n\n /**\n * Sets the log level to warning.\n *\n * @returns\n * This object.\n */\n public warning = this.level.bind(this, ZLogLevel.WARNING);\n\n /**\n * Sets the log level to info.\n *\n * @returns\n * This object.\n */\n public info = this.level.bind(this, ZLogLevel.INFO);\n\n /**\n * Sets the context of the entry.\n *\n * @param ctx -\n * The entry context.\n *\n * @returns\n * This object.\n */\n public context(ctx: string | undefined): this {\n this._entry.context = ctx;\n return this;\n }\n\n /**\n * Sets the message.\n *\n * @param msg -\n * The message to log.\n *\n * @returns\n * This object.\n */\n public message(msg: string): this {\n this._entry.message = msg;\n return this;\n }\n\n /**\n * Copies the other entry into the current entry.\n *\n * @param other -\n * The entry to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZLogEntry): this {\n this._entry = structuredClone(other);\n return this;\n }\n\n /**\n * Returns a copy of the built log entry.\n *\n * @returns\n * The built log entry.\n */\n public build(): IZLogEntry {\n return { ...this._entry };\n }\n}\n","import type { IZLogEntry } from \"../log-entry/log-entry.mjs\";\nimport type { IZLogger } from \"./logger.mjs\";\n\n/**\n * Represents a logger that logs to multiple sources.\n */\nexport class ZLoggerComposite implements IZLogger {\n /**\n * Initializes a new instance of this object.\n *\n * @param _children -\n * The collection of child loggers to log to.\n */\n public constructor(private readonly _children: IZLogger[]) {}\n\n /**\n * Logs the entry into every one of the child loggers.\n *\n * @param entry -\n * The entry to log.\n */\n public log(entry: IZLogEntry): void {\n this._children.forEach((logger) => logger.log(entry));\n }\n}\n","import type { IZLogEntry } from \"../log-entry/log-entry.mjs\";\nimport { ZLogLevel } from \"../log-entry/log-entry.mjs\";\nimport type { IZLogger } from \"./logger.mjs\";\n\n/**\n * Represents a logger that logs to the console.\n */\nexport class ZLoggerConsole implements IZLogger {\n public static readonly FATAL = \"!!FATAL!!\";\n private _logFnMap: any;\n\n /**\n * Initializes a new instance of this object.\n *\n * @param _console -\n * The console to log to.\n */\n public constructor(private _console: Console) {\n this._logFnMap = {\n [ZLogLevel.CATASTROPHE]: (msg: string) => _console.error(msg),\n [ZLogLevel.ERROR]: (msg: string) => _console.error(msg),\n [ZLogLevel.WARNING]: (msg: string) => _console.warn(msg),\n };\n }\n\n /**\n * Logs the entry to the console.\n *\n * @param entry -\n * The entry to log.\n */\n public log(entry: IZLogEntry): void {\n const fn =\n this._logFnMap[entry.level] || ((msg: string) => this._console.log(msg));\n\n const timestamp = `[${entry.created.toLocaleString()}]`;\n const payload =\n entry.level === ZLogLevel.CATASTROPHE\n ? `: ${ZLoggerConsole.FATAL} - ${entry.message}`\n : `: ${entry.message}`;\n fn(`${timestamp}${payload}`);\n }\n}\n","import type { IZLogEntry } from \"../log-entry/log-entry.mjs\";\nimport { ZLogEntryBuilder } from \"../log-entry/log-entry.mjs\";\nimport type { IZLogger } from \"./logger.mjs\";\n\n/**\n * A logger that sets up a default context in the case that one is not given in the entry.\n */\nexport class ZLoggerContext implements IZLogger {\n /**\n * Initializes a new instance of this object.\n *\n * @param _context -\n * The default context if one is not provided in the entry.\n * @param _forward -\n * The logger to forward to.\n */\n public constructor(\n private _context: string,\n private _forward: IZLogger,\n ) {}\n\n public log(entry: IZLogEntry): void {\n const clone = new ZLogEntryBuilder()\n .copy(entry)\n .context(entry.context || this._context)\n .build();\n return this._forward.log(clone);\n }\n}\n","import { noop } from \"lodash-es\";\nimport type { IZLogEntry } from \"../log-entry/log-entry.mjs\";\nimport type { IZLogger } from \"./logger.mjs\";\n\n/**\n * A silent logger. This logger does nothing.\n */\nexport class ZLoggerSilent implements IZLogger {\n public log: (_: IZLogEntry) => void = noop;\n}\n"],"names":["ZLogLevel","noop"],"mappings":";;;AAGY,IAAA,8BAAAA,eAAL;AAQLA,aAAAA,WAAA,iBAAc,CAAd,IAAA;AAQAA,aAAAA,WAAA,WAAQ,CAAR,IAAA;AAUAA,aAAAA,WAAA,aAAU,CAAV,IAAA;AAYAA,aAAAA,WAAA,UAAO,CAA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AA,KAAK,SAAS,IAAI,KAAK;AAAA,EAAA;AAElC;ACrBO,MAAM,cAAkC;AAAA,EAAxC,cAAA;AACL,SAAO,MAA+BC,SAAA;AAAA,EAAA;AACxC;;;;;;;"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/log-entry/log-entry.mts","../src/logger/logger-composite.mts","../src/logger/logger-console.mts","../src/logger/logger-context.mts","../src/logger/logger-silent.mts"],"sourcesContent":["/**\n * The log level.\n */\nexport enum ZLogLevel {\n /**\n * A fatal error.\n *\n * Someone's pager is going off at 2:00 in the\n * morning because the nuclear codes have gone off\n * and missiles have been launched.\n */\n CATASTROPHE = 0,\n\n /**\n * A normal error that cause usually be recovered from.\n *\n * May require a fire being put out or some immediate\n * response, but it is not world ending.\n */\n ERROR = 1,\n\n /**\n * Nothing is really wrong.\n *\n * Should probably not be ignored and\n * action should be taken, but it's not\n * serious enough to call the fire\n * department.\n */\n WARNING = 2,\n\n /**\n * Some information that's good to know.\n *\n * Analytic logs are in this zone and general\n * information goes in this zone. Debug as\n * well, goes into this zone.\n *\n * It is normally best to avoid this log level\n * unless it's really important to display.\n */\n INFO = 3,\n}\n\n/**\n * Represents a log entry.\n */\nexport interface IZLogEntry {\n /**\n * The log context.\n *\n * This will usually be a friendly name of a function\n * or class where this log took place.\n */\n context?: string;\n\n /**\n * The log level.\n */\n level: ZLogLevel;\n\n /**\n * The creation of this entry.\n */\n created: Date | string;\n\n /**\n * The log message.\n */\n message: string;\n}\n\n/**\n * Represents a builder for a log entry\n */\nexport class ZLogEntryBuilder {\n private _entry: IZLogEntry;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._entry = {\n level: ZLogLevel.ERROR,\n message: \"\",\n created: new Date().toJSON(),\n };\n }\n\n /**\n * Sets the log level.\n *\n * @param level -\n * The log level.\n *\n * @returns\n * This object.\n */\n public level(level: ZLogLevel) {\n this._entry.level = level;\n return this;\n }\n\n /**\n * Sets the log level to catastrophe.\n *\n * @returns\n * This object.\n */\n public catastrophe = this.level.bind(this, ZLogLevel.CATASTROPHE);\n\n /**\n * Sets the log level to error.\n *\n * @returns\n * This object.\n */\n public error = this.level.bind(this, ZLogLevel.ERROR);\n\n /**\n * Sets the log level to warning.\n *\n * @returns\n * This object.\n */\n public warning = this.level.bind(this, ZLogLevel.WARNING);\n\n /**\n * Sets the log level to info.\n *\n * @returns\n * This object.\n */\n public info = this.level.bind(this, ZLogLevel.INFO);\n\n /**\n * Sets the context of the entry.\n *\n * @param ctx -\n * The entry context.\n *\n * @returns\n * This object.\n */\n public context(ctx: string | undefined): this {\n this._entry.context = ctx;\n return this;\n }\n\n /**\n * Sets the message.\n *\n * @param msg -\n * The message to log.\n *\n * @returns\n * This object.\n */\n public message(msg: string): this {\n this._entry.message = msg;\n return this;\n }\n\n /**\n * Copies the other entry into the current entry.\n *\n * @param other -\n * The entry to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZLogEntry): this {\n this._entry = structuredClone(other);\n return this;\n }\n\n /**\n * Returns a copy of the built log entry.\n *\n * @returns\n * The built log entry.\n */\n public build(): IZLogEntry {\n return { ...this._entry };\n }\n}\n","import { IZLogEntry } from \"../log-entry/log-entry.mjs\";\nimport { IZLogger } from \"./logger.mjs\";\n\n/**\n * Represents a logger that logs to multiple sources.\n */\nexport class ZLoggerComposite implements IZLogger {\n /**\n * Initializes a new instance of this object.\n *\n * @param _children -\n * The collection of child loggers to log to.\n */\n public constructor(private readonly _children: IZLogger[]) {}\n\n /**\n * Logs the entry into every one of the child loggers.\n *\n * @param entry -\n * The entry to log.\n */\n public log(entry: IZLogEntry): void {\n this._children.forEach((logger) => logger.log(entry));\n }\n}\n","import { IZLogEntry
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/log-entry/log-entry.mts","../src/logger/logger-composite.mts","../src/logger/logger-console.mts","../src/logger/logger-context.mts","../src/logger/logger-silent.mts"],"sourcesContent":["/**\n * The log level.\n */\nexport enum ZLogLevel {\n /**\n * A fatal error.\n *\n * Someone's pager is going off at 2:00 in the\n * morning because the nuclear codes have gone off\n * and missiles have been launched.\n */\n CATASTROPHE = 0,\n\n /**\n * A normal error that cause usually be recovered from.\n *\n * May require a fire being put out or some immediate\n * response, but it is not world ending.\n */\n ERROR = 1,\n\n /**\n * Nothing is really wrong.\n *\n * Should probably not be ignored and\n * action should be taken, but it's not\n * serious enough to call the fire\n * department.\n */\n WARNING = 2,\n\n /**\n * Some information that's good to know.\n *\n * Analytic logs are in this zone and general\n * information goes in this zone. Debug as\n * well, goes into this zone.\n *\n * It is normally best to avoid this log level\n * unless it's really important to display.\n */\n INFO = 3,\n}\n\n/**\n * Represents a log entry.\n */\nexport interface IZLogEntry {\n /**\n * The log context.\n *\n * This will usually be a friendly name of a function\n * or class where this log took place.\n */\n context?: string;\n\n /**\n * The log level.\n */\n level: ZLogLevel;\n\n /**\n * The creation of this entry.\n */\n created: Date | string;\n\n /**\n * The log message.\n */\n message: string;\n}\n\n/**\n * Represents a builder for a log entry\n */\nexport class ZLogEntryBuilder {\n private _entry: IZLogEntry;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._entry = {\n level: ZLogLevel.ERROR,\n message: \"\",\n created: new Date().toJSON(),\n };\n }\n\n /**\n * Sets the log level.\n *\n * @param level -\n * The log level.\n *\n * @returns\n * This object.\n */\n public level(level: ZLogLevel) {\n this._entry.level = level;\n return this;\n }\n\n /**\n * Sets the log level to catastrophe.\n *\n * @returns\n * This object.\n */\n public catastrophe = this.level.bind(this, ZLogLevel.CATASTROPHE);\n\n /**\n * Sets the log level to error.\n *\n * @returns\n * This object.\n */\n public error = this.level.bind(this, ZLogLevel.ERROR);\n\n /**\n * Sets the log level to warning.\n *\n * @returns\n * This object.\n */\n public warning = this.level.bind(this, ZLogLevel.WARNING);\n\n /**\n * Sets the log level to info.\n *\n * @returns\n * This object.\n */\n public info = this.level.bind(this, ZLogLevel.INFO);\n\n /**\n * Sets the context of the entry.\n *\n * @param ctx -\n * The entry context.\n *\n * @returns\n * This object.\n */\n public context(ctx: string | undefined): this {\n this._entry.context = ctx;\n return this;\n }\n\n /**\n * Sets the message.\n *\n * @param msg -\n * The message to log.\n *\n * @returns\n * This object.\n */\n public message(msg: string): this {\n this._entry.message = msg;\n return this;\n }\n\n /**\n * Copies the other entry into the current entry.\n *\n * @param other -\n * The entry to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZLogEntry): this {\n this._entry = structuredClone(other);\n return this;\n }\n\n /**\n * Returns a copy of the built log entry.\n *\n * @returns\n * The built log entry.\n */\n public build(): IZLogEntry {\n return { ...this._entry };\n }\n}\n","import type { IZLogEntry } from \"../log-entry/log-entry.mjs\";\nimport type { IZLogger } from \"./logger.mjs\";\n\n/**\n * Represents a logger that logs to multiple sources.\n */\nexport class ZLoggerComposite implements IZLogger {\n /**\n * Initializes a new instance of this object.\n *\n * @param _children -\n * The collection of child loggers to log to.\n */\n public constructor(private readonly _children: IZLogger[]) {}\n\n /**\n * Logs the entry into every one of the child loggers.\n *\n * @param entry -\n * The entry to log.\n */\n public log(entry: IZLogEntry): void {\n this._children.forEach((logger) => logger.log(entry));\n }\n}\n","import type { IZLogEntry } from \"../log-entry/log-entry.mjs\";\nimport { ZLogLevel } from \"../log-entry/log-entry.mjs\";\nimport type { IZLogger } from \"./logger.mjs\";\n\n/**\n * Represents a logger that logs to the console.\n */\nexport class ZLoggerConsole implements IZLogger {\n public static readonly FATAL = \"!!FATAL!!\";\n private _logFnMap: any;\n\n /**\n * Initializes a new instance of this object.\n *\n * @param _console -\n * The console to log to.\n */\n public constructor(private _console: Console) {\n this._logFnMap = {\n [ZLogLevel.CATASTROPHE]: (msg: string) => _console.error(msg),\n [ZLogLevel.ERROR]: (msg: string) => _console.error(msg),\n [ZLogLevel.WARNING]: (msg: string) => _console.warn(msg),\n };\n }\n\n /**\n * Logs the entry to the console.\n *\n * @param entry -\n * The entry to log.\n */\n public log(entry: IZLogEntry): void {\n const fn =\n this._logFnMap[entry.level] || ((msg: string) => this._console.log(msg));\n\n const timestamp = `[${entry.created.toLocaleString()}]`;\n const payload =\n entry.level === ZLogLevel.CATASTROPHE\n ? `: ${ZLoggerConsole.FATAL} - ${entry.message}`\n : `: ${entry.message}`;\n fn(`${timestamp}${payload}`);\n }\n}\n","import type { IZLogEntry } from \"../log-entry/log-entry.mjs\";\nimport { ZLogEntryBuilder } from \"../log-entry/log-entry.mjs\";\nimport type { IZLogger } from \"./logger.mjs\";\n\n/**\n * A logger that sets up a default context in the case that one is not given in the entry.\n */\nexport class ZLoggerContext implements IZLogger {\n /**\n * Initializes a new instance of this object.\n *\n * @param _context -\n * The default context if one is not provided in the entry.\n * @param _forward -\n * The logger to forward to.\n */\n public constructor(\n private _context: string,\n private _forward: IZLogger,\n ) {}\n\n public log(entry: IZLogEntry): void {\n const clone = new ZLogEntryBuilder()\n .copy(entry)\n .context(entry.context || this._context)\n .build();\n return this._forward.log(clone);\n }\n}\n","import { noop } from \"lodash-es\";\nimport type { IZLogEntry } from \"../log-entry/log-entry.mjs\";\nimport type { IZLogger } from \"./logger.mjs\";\n\n/**\n * A silent logger. This logger does nothing.\n */\nexport class ZLoggerSilent implements IZLogger {\n public log: (_: IZLogEntry) => void = noop;\n}\n"],"names":["ZLogLevel"],"mappings":";AAGY,IAAA,8BAAAA,eAAL;AAQLA,aAAAA,WAAA,iBAAc,CAAd,IAAA;AAQAA,aAAAA,WAAA,WAAQ,CAAR,IAAA;AAUAA,aAAAA,WAAA,aAAU,CAAV,IAAA;AAYAA,aAAAA,WAAA,UAAO,CAAP,IAAA;AAtCUA,SAAAA;AAAA,GAAA,aAAA,CAAA,CAAA;AAwEL,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAMrB,cAAc;AA4BrB,SAAO,cAAc,KAAK,MAAM;AAAA,MAAK;AAAA,MAAM;AAAA;AAAA,IAAqB;AAQhE,SAAO,QAAQ,KAAK,MAAM;AAAA,MAAK;AAAA,MAAM;A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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zthun/lumberjacky-log",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A standard log interface between different logging standards.",
|
|
5
5
|
"author": "Anthony Bonta",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"log",
|
|
16
16
|
"console"
|
|
17
17
|
],
|
|
18
|
-
"types": "./dist/index.d.
|
|
18
|
+
"types": "./dist/index.d.mts",
|
|
19
19
|
"main": "./dist/index.cjs",
|
|
20
20
|
"module": "./dist/index.js",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
23
|
-
"types": "./dist/index.d.
|
|
23
|
+
"types": "./dist/index.d.mts",
|
|
24
24
|
"require": "./dist/index.cjs",
|
|
25
25
|
"import": "./dist/index.js"
|
|
26
26
|
},
|
|
@@ -34,14 +34,15 @@
|
|
|
34
34
|
"lodash-es": "^4.17.21"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
+
"@zthun/janitor-build-config": "^19.1.5",
|
|
37
38
|
"typescript": "~5.8.3",
|
|
38
39
|
"vite": "^6.3.5",
|
|
39
|
-
"vitest": "^3.
|
|
40
|
+
"vitest": "^3.2.3",
|
|
40
41
|
"vitest-mock-extended": "^3.1.0"
|
|
41
42
|
},
|
|
42
43
|
"files": [
|
|
43
44
|
"dist"
|
|
44
45
|
],
|
|
45
46
|
"sideEffects": false,
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "e8e2a6fd682560f860727fda1de350659a9af1e5"
|
|
47
48
|
}
|
|
File without changes
|