@niceties/logger 1.1.6 → 1.1.8
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/core.d.ts +1 -1
- package/dist/core.umd.js.map +1 -1
- package/dist/simple.cjs +1 -1
- package/dist/simple.mjs +1 -1
- package/dist/simple.umd.js +1 -1
- package/dist/simple.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/core.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export declare const createLogger: <ErrorContext = Error>(...args: [
|
|
|
5
5
|
update(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
|
|
6
6
|
finish(message: string, loglevel?: LogLevel | undefined, context?: ErrorContext | undefined): void;
|
|
7
7
|
appender(appender?: Appender<ErrorContext> | undefined): (message: LogMessage<ErrorContext>) => void;
|
|
8
|
-
};
|
|
8
|
+
} & Identity;
|
package/dist/core.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.umd.js","sources":["../src/core.ts"],"sourcesContent":["import { globalAppender } from './global-appender';\nimport { Action, Appender, LogLevel, LogMessage, Identity } from './types';\n\nlet globalInputId = 0;\n\nconst getOptions = (options: [] | [string | Identity | undefined] | [string, Identity]): { tag?: string, parentId?: number } => {\n let parentId, tag;\n if (options.length === 1) {\n if (typeof options[0] === 'string') {\n tag = options[0];\n } else {\n parentId = options[0]?.id;\n }\n } else if (options.length === 2) {\n tag = options[0];\n parentId = options[1]?.id;\n }\n return { parentId, tag };\n};\n\nexport const createLogger = <ErrorContext = Error>(...args: [] | [string | Identity | undefined] | [string, Identity]) => {\n let initialLogLevel: number = LogLevel.info;\n\n let myAppender = (message: LogMessage<ErrorContext>) => { globalAppender && globalAppender(message); };\n \n const inputId = globalInputId++;\n \n const { tag, parentId } = getOptions(args);\n \n const append = (message: string, action: Action, loglevel: LogLevel, context?: ErrorContext) => {\n myAppender && myAppender({\n action,\n inputId,\n message,\n loglevel,\n tag,\n parentId,\n ref,\n context\n } as LogMessage<ErrorContext>);\n };\n\n const loggerInstance = Object.assign(\n (message: string, loglevel: LogLevel = LogLevel.info, context?: ErrorContext) => {\n append(message, Action.log, loglevel, context);\n }, {\n // Fine to be started multiple times\n start(message: string, loglevel?: LogLevel, context?: ErrorContext) {\n if (loglevel !== undefined) {\n initialLogLevel = loglevel;\n }\n append(message, Action.start, initialLogLevel, context);\n },\n // Fine to be updated multiple times\n update(message: string, loglevel?: LogLevel, context?: ErrorContext) {\n append(message, Action.update, loglevel ?? initialLogLevel, context);\n },\n // Fine to be finished multiple times\n finish(message: string, loglevel?: LogLevel, context?: ErrorContext) {\n append(message, Action.finish, loglevel ?? initialLogLevel, context);\n },\n appender(appender?: Appender<ErrorContext>) {\n if (appender !== undefined) {\n myAppender = appender;\n }\n return myAppender;\n }\n }\n );\n\n Object.defineProperty(loggerInstance, 'id', {\n value: inputId,\n writable: false\n });\n\n const ref = new WeakRef(loggerInstance);\n\n return loggerInstance;\n};\n"],"names":["globalInputId","args","initialLogLevel","myAppender","message","globalAppender","inputId","tag","parentId","options","length","_a","id","_b","getOptions","append","action","loglevel","context","ref","loggerInstance","Object","assign","start","undefined","update","finish","appender","defineProperty","value","writable","WeakRef"],"mappings":"4UAGA,IAAIA,EAAgB,iBAiBQ,IAA0BC,KAClD,IAAIC,IAEAC,EAAcC,IAAwCC,EAAcA,gBAAIA,iBAAeD,IAE3F,MAAME,EAAUN,KAEVO,IAAEA,EAAGC,SAAEA,GAtBE,CAACC,YAChB,IAAID,EAAUD,EAWd,OAVuB,IAAnBE,EAAQC,OACkB,iBAAfD,EAAQ,GACfF,EAAME,EAAQ,GAEdD,EAAqB,UAAVC,EAAQ,UAAE,IAAAE,OAAA,EAAAA,EAAEC,GAED,IAAnBH,EAAQC,SACfH,EAAME,EAAQ,GACdD,EAAqB,UAAVC,EAAQ,UAAE,IAAAI,OAAA,EAAAA,EAAED,IAEpB,CAAEJ,SAAAA,EAAUD,IAAAA,IAUOO,CAAWb,GAE/Bc,EAAS,CAACX,EAAiBY,EAAgBC,EAAoBC,KACjEf,GAAcA,EAAW,CACrBa,OAAAA,EACAV,QAAAA,EACAF,QAAAA,EACAa,SAAAA,EACAV,IAAAA,EACAC,SAAAA,EACAW,IAAAA,EACAD,QAAAA,KAIFE,EAAiBC,OAAOC,QAC1B,CAAClB,EAAiBa,EAAA,EAAoCC,KAClDH,EAAOX,EAAO,EAAca,EAAUC,KACvC,CAECK,MAAMnB,EAAiBa,EAAqBC,QACvBM,IAAbP,IACAf,EAAkBe,GAEtBF,EAAOX,EAAO,EAAgBF,EAAiBgB,IAGnDO,OAAOrB,EAAiBa,EAAqBC,GACzCH,EAAOX,EAAwB,EAAAa,MAAAA,EAAAA,EAAYf,EAAiBgB,IAGhEQ,OAAOtB,EAAiBa,EAAqBC,GACzCH,EAAOX,EAAwB,EAAAa,MAAAA,EAAAA,EAAYf,EAAiBgB,IAEhES,SAASA,SACYH,IAAbG,IACAxB,EAAawB,GAEVxB,KAKnBkB,OAAOO,eAAeR,EAAgB,KAAM,CACxCS,MAAOvB,EACPwB,UAAU,IAGd,MAAMX,EAAM,IAAIY,QAAQX,GAExB,OAAOA"}
|
|
1
|
+
{"version":3,"file":"core.umd.js","sources":["../src/core.ts"],"sourcesContent":["import { globalAppender } from './global-appender';\nimport { Action, Appender, LogLevel, LogMessage, Identity } from './types';\n\nlet globalInputId = 0;\n\nconst getOptions = (options: [] | [string | Identity | undefined] | [string, Identity]): { tag?: string, parentId?: number } => {\n let parentId, tag;\n if (options.length === 1) {\n if (typeof options[0] === 'string') {\n tag = options[0];\n } else {\n parentId = options[0]?.id;\n }\n } else if (options.length === 2) {\n tag = options[0];\n parentId = options[1]?.id;\n }\n return { parentId, tag };\n};\n\nexport const createLogger = <ErrorContext = Error>(...args: [] | [string | Identity | undefined] | [string, Identity]) => {\n let initialLogLevel: number = LogLevel.info;\n\n let myAppender = (message: LogMessage<ErrorContext>) => { globalAppender && globalAppender(message); };\n \n const inputId = globalInputId++;\n \n const { tag, parentId } = getOptions(args);\n \n const append = (message: string, action: Action, loglevel: LogLevel, context?: ErrorContext) => {\n myAppender && myAppender({\n action,\n inputId,\n message,\n loglevel,\n tag,\n parentId,\n ref,\n context\n } as LogMessage<ErrorContext>);\n };\n\n const loggerInstance = Object.assign(\n (message: string, loglevel: LogLevel = LogLevel.info, context?: ErrorContext) => {\n append(message, Action.log, loglevel, context);\n }, {\n // Fine to be started multiple times\n start(message: string, loglevel?: LogLevel, context?: ErrorContext) {\n if (loglevel !== undefined) {\n initialLogLevel = loglevel;\n }\n append(message, Action.start, initialLogLevel, context);\n },\n // Fine to be updated multiple times\n update(message: string, loglevel?: LogLevel, context?: ErrorContext) {\n append(message, Action.update, loglevel ?? initialLogLevel, context);\n },\n // Fine to be finished multiple times\n finish(message: string, loglevel?: LogLevel, context?: ErrorContext) {\n append(message, Action.finish, loglevel ?? initialLogLevel, context);\n },\n appender(appender?: Appender<ErrorContext>) {\n if (appender !== undefined) {\n myAppender = appender;\n }\n return myAppender;\n }\n }\n );\n\n Object.defineProperty(loggerInstance, 'id', {\n value: inputId,\n writable: false\n });\n\n const ref = new WeakRef(loggerInstance);\n\n return loggerInstance as typeof loggerInstance & Identity;\n};\n"],"names":["globalInputId","args","initialLogLevel","myAppender","message","globalAppender","inputId","tag","parentId","options","length","_a","id","_b","getOptions","append","action","loglevel","context","ref","loggerInstance","Object","assign","start","undefined","update","finish","appender","defineProperty","value","writable","WeakRef"],"mappings":"4UAGA,IAAIA,EAAgB,iBAiBQ,IAA0BC,KAClD,IAAIC,IAEAC,EAAcC,IAAwCC,EAAcA,gBAAIA,iBAAeD,IAE3F,MAAME,EAAUN,KAEVO,IAAEA,EAAGC,SAAEA,GAtBE,CAACC,YAChB,IAAID,EAAUD,EAWd,OAVuB,IAAnBE,EAAQC,OACkB,iBAAfD,EAAQ,GACfF,EAAME,EAAQ,GAEdD,EAAqB,UAAVC,EAAQ,UAAE,IAAAE,OAAA,EAAAA,EAAEC,GAED,IAAnBH,EAAQC,SACfH,EAAME,EAAQ,GACdD,EAAqB,UAAVC,EAAQ,UAAE,IAAAI,OAAA,EAAAA,EAAED,IAEpB,CAAEJ,SAAAA,EAAUD,IAAAA,IAUOO,CAAWb,GAE/Bc,EAAS,CAACX,EAAiBY,EAAgBC,EAAoBC,KACjEf,GAAcA,EAAW,CACrBa,OAAAA,EACAV,QAAAA,EACAF,QAAAA,EACAa,SAAAA,EACAV,IAAAA,EACAC,SAAAA,EACAW,IAAAA,EACAD,QAAAA,KAIFE,EAAiBC,OAAOC,QAC1B,CAAClB,EAAiBa,EAAA,EAAoCC,KAClDH,EAAOX,EAAO,EAAca,EAAUC,KACvC,CAECK,MAAMnB,EAAiBa,EAAqBC,QACvBM,IAAbP,IACAf,EAAkBe,GAEtBF,EAAOX,EAAO,EAAgBF,EAAiBgB,IAGnDO,OAAOrB,EAAiBa,EAAqBC,GACzCH,EAAOX,EAAwB,EAAAa,MAAAA,EAAAA,EAAYf,EAAiBgB,IAGhEQ,OAAOtB,EAAiBa,EAAqBC,GACzCH,EAAOX,EAAwB,EAAAa,MAAAA,EAAAA,EAAYf,EAAiBgB,IAEhES,SAASA,SACYH,IAAbG,IACAxB,EAAawB,GAEVxB,KAKnBkB,OAAOO,eAAeR,EAAgB,KAAM,CACxCS,MAAOvB,EACPwB,UAAU,IAGd,MAAMX,EAAM,IAAIY,QAAQX,GAExB,OAAOA"}
|
package/dist/simple.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var globalAppender = require('./global-appender.cjs');
|
|
|
4
4
|
|
|
5
5
|
const createLogger = (tag) => {
|
|
6
6
|
let myAppender = (message) => { globalAppender.globalAppender && globalAppender.globalAppender(message); };
|
|
7
|
-
return Object.assign(
|
|
7
|
+
return Object.assign((message, loglevel = 1 /* info */, context) => {
|
|
8
8
|
myAppender && myAppender({
|
|
9
9
|
action: 3 /* log */,
|
|
10
10
|
message,
|
package/dist/simple.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { globalAppender } from './global-appender.mjs';
|
|
|
2
2
|
|
|
3
3
|
const createLogger = (tag) => {
|
|
4
4
|
let myAppender = (message) => { globalAppender && globalAppender(message); };
|
|
5
|
-
return Object.assign(
|
|
5
|
+
return Object.assign((message, loglevel = 1 /* info */, context) => {
|
|
6
6
|
myAppender && myAppender({
|
|
7
7
|
action: 3 /* log */,
|
|
8
8
|
message,
|
package/dist/simple.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("./global-appender")):"function"==typeof define&&define.amd?define(["exports","./global-appender"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).nicetiesLoggerSimple={},e.nicetiesLoggerGlobalAppender)}(this,(function(e,t){"use strict";e.createLogger=e=>{let
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("./global-appender")):"function"==typeof define&&define.amd?define(["exports","./global-appender"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).nicetiesLoggerSimple={},e.nicetiesLoggerGlobalAppender)}(this,(function(e,t){"use strict";e.createLogger=e=>{let o=e=>{t.globalAppender&&t.globalAppender(e)};return Object.assign(((t,n=1,i)=>{o&&o({action:3,message:t,loglevel:n,tag:e,context:i})}),{appender:e=>(void 0!==e&&(o=e),o)})}}));
|
|
2
2
|
//# sourceMappingURL=simple.umd.js.map
|
package/dist/simple.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple.umd.js","sources":["../src/simple.ts"],"sourcesContent":["import { globalAppender } from './global-appender';\nimport { Action, Appender, LogLevel, LogMessage } from './types';\n\nexport const createLogger = <ErrorContext = Error>(tag?: string) => {\n let myAppender = (message: LogMessage<ErrorContext>) => { globalAppender && globalAppender(message); };\n\n return Object.assign(\n
|
|
1
|
+
{"version":3,"file":"simple.umd.js","sources":["../src/simple.ts"],"sourcesContent":["import { globalAppender } from './global-appender';\nimport { Action, Appender, LogLevel, LogMessage } from './types';\n\nexport const createLogger = <ErrorContext = Error>(tag?: string) => {\n let myAppender = (message: LogMessage<ErrorContext>) => { globalAppender && globalAppender(message); };\n\n return Object.assign(\n (message: string, loglevel: LogLevel = LogLevel.info, context?: ErrorContext) => {\n myAppender && myAppender({\n action: Action.log,\n message,\n loglevel,\n tag,\n context\n } as LogMessage<ErrorContext>);\n }, {\n appender(appender?: Appender<ErrorContext>) {\n if (appender !== undefined) {\n myAppender = appender;\n }\n return myAppender;\n }\n }\n );\n};\n"],"names":["tag","myAppender","message","globalAppender","Object","assign","loglevel","context","action","appender","undefined"],"mappings":"6VAGmDA,IAC/C,IAAIC,EAAcC,IAAwCC,EAAcA,gBAAIA,iBAAeD,IAE3F,OAAOE,OAAOC,QACV,CAACH,EAAiBI,EAAkC,EAAEC,KAClDN,GAAcA,EAAW,CACrBO,OAAkB,EAClBN,QAAAA,EACAI,SAAAA,EACAN,IAAAA,EACAO,QAAAA,MAEL,CACCE,SAASA,SACYC,IAAbD,IACAR,EAAaQ,GAEVR"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.1.
|
|
2
|
+
"version": "1.1.8",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "@niceties/logger",
|
|
5
5
|
"author": "Konstantin Shutkin",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"ts-jest": "27.1.2",
|
|
92
92
|
"tslib": "2.3.1",
|
|
93
93
|
"typescript": "4.6.x",
|
|
94
|
-
"pkgbld-internal": "1.0.
|
|
94
|
+
"pkgbld-internal": "1.0.4"
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
97
|
"kleur": "^4.1.4"
|