@larvit/log 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@larvit/log",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
+ "license": "MIT",
5
6
  "packageManager": "yarn@3.2.3",
6
7
  "scripts": {
7
8
  "build": "rm -f index.js index.d.ts index.js.map && tsc && uglifyjs index.js -o index.js",
@@ -13,11 +14,15 @@
13
14
  "@types/tape": "4.13.2",
14
15
  "tape": "5.6.1",
15
16
  "ts-node": "10.9.1",
16
- "typescript": "4.8.3",
17
- "uglify-js": "3.17.1"
17
+ "typescript": "4.8.4",
18
+ "uglify-js": "3.17.2"
18
19
  },
19
20
  "publishConfig": {
20
21
  "access": "public",
21
22
  "registry": "https://registry.npmjs.org/"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/larvit/log.git"
22
27
  }
23
28
  }
package/yarn.lock CHANGED
@@ -47,8 +47,8 @@ __metadata:
47
47
  "@types/tape": 4.13.2
48
48
  tape: 5.6.1
49
49
  ts-node: 10.9.1
50
- typescript: 4.8.3
51
- uglify-js: 3.17.1
50
+ typescript: 4.8.4
51
+ uglify-js: 3.17.2
52
52
  languageName: unknown
53
53
  linkType: soft
54
54
 
@@ -1102,32 +1102,32 @@ __metadata:
1102
1102
  languageName: node
1103
1103
  linkType: hard
1104
1104
 
1105
- "typescript@npm:4.8.3":
1106
- version: 4.8.3
1107
- resolution: "typescript@npm:4.8.3"
1105
+ "typescript@npm:4.8.4":
1106
+ version: 4.8.4
1107
+ resolution: "typescript@npm:4.8.4"
1108
1108
  bin:
1109
1109
  tsc: bin/tsc
1110
1110
  tsserver: bin/tsserver
1111
- checksum: 8286a5edcaf3d68e65c451aa1e7150ad1cf53ee0813c07ec35b7abdfdb10f355ecaa13c6a226a694ae7a67785fd7eeebf89f845da0b4f7e4a35561ddc459aba0
1111
+ checksum: 3e4f061658e0c8f36c820802fa809e0fd812b85687a9a2f5430bc3d0368e37d1c9605c3ce9b39df9a05af2ece67b1d844f9f6ea8ff42819f13bcb80f85629af0
1112
1112
  languageName: node
1113
1113
  linkType: hard
1114
1114
 
1115
- "typescript@patch:typescript@4.8.3#~builtin<compat/typescript>":
1116
- version: 4.8.3
1117
- resolution: "typescript@patch:typescript@npm%3A4.8.3#~builtin<compat/typescript>::version=4.8.3&hash=a1c5e5"
1115
+ "typescript@patch:typescript@4.8.4#~builtin<compat/typescript>":
1116
+ version: 4.8.4
1117
+ resolution: "typescript@patch:typescript@npm%3A4.8.4#~builtin<compat/typescript>::version=4.8.4&hash=a1c5e5"
1118
1118
  bin:
1119
1119
  tsc: bin/tsc
1120
1120
  tsserver: bin/tsserver
1121
- checksum: 2222d2382fb3146089b1d27ce2b55e9d1f99cc64118f1aba75809b693b856c5d3c324f052f60c75b577947fc538bc1c27bad0eb76cbdba9a63a253489504ba7e
1121
+ checksum: 563a0ef47abae6df27a9a3ab38f75fc681f633ccf1a3502b1108e252e187787893de689220f4544aaf95a371a4eb3141e4a337deb9895de5ac3c1ca76430e5f0
1122
1122
  languageName: node
1123
1123
  linkType: hard
1124
1124
 
1125
- "uglify-js@npm:3.17.1":
1126
- version: 3.17.1
1127
- resolution: "uglify-js@npm:3.17.1"
1125
+ "uglify-js@npm:3.17.2":
1126
+ version: 3.17.2
1127
+ resolution: "uglify-js@npm:3.17.2"
1128
1128
  bin:
1129
1129
  uglifyjs: bin/uglifyjs
1130
- checksum: 5e24ad48e096d309e77a462fa0508a9bfe33e2ab00e1bd21dc8bd5d035cf0b58063914bef1c6d6aca78e9e5bbe619714b142ffc646165702e3714f4cfbc7151c
1130
+ checksum: 128233638176abe6cc0ec0f1dbae7bcb3f02edd78eb5c7752b4f379ec9d29032cd2edf06b2522dbeba0a1f05afb25f6eaffe638581da6d8554bd4c060d6622b1
1131
1131
  languageName: node
1132
1132
  linkType: hard
1133
1133
 
package/index.d.ts DELETED
@@ -1,40 +0,0 @@
1
- declare type Metadata = {
2
- [key: string]: string;
3
- };
4
- declare type LogShorthand = (msg: string, metadata?: Metadata) => void;
5
- interface LogInt {
6
- error: LogShorthand;
7
- warn: LogShorthand;
8
- info: LogShorthand;
9
- verbose: LogShorthand;
10
- debug: LogShorthand;
11
- silly: LogShorthand;
12
- }
13
- declare type LogLevel = keyof LogInt;
14
- declare type EntryFormatterConf = {
15
- logLevel: LogLevel;
16
- metadata?: Metadata;
17
- msg: string;
18
- };
19
- declare type LogConf = {
20
- context?: Metadata;
21
- format?: "text" | "json";
22
- logLevel?: LogLevel | "none";
23
- entryFormatter?: (conf: EntryFormatterConf) => string;
24
- stdout?: (msg: string) => void;
25
- stderr?: (msg: string) => void;
26
- };
27
- export declare function msgJsonFormatter(conf: EntryFormatterConf): string;
28
- export declare function msgTextFormatter(conf: EntryFormatterConf): string;
29
- export declare class Log implements LogInt {
30
- #private;
31
- context: Metadata;
32
- constructor(conf?: LogConf | LogLevel | "none");
33
- error(msg: string, metadata?: Metadata): void;
34
- warn(msg: string, metadata?: Metadata): void;
35
- info(msg: string, metadata?: Metadata): void;
36
- verbose(msg: string, metadata?: Metadata): void;
37
- debug(msg: string, metadata?: Metadata): void;
38
- silly(msg: string, metadata?: Metadata): void;
39
- }
40
- export {};
package/index.js DELETED
@@ -1 +0,0 @@
1
- export function msgJsonFormatter(conf){const payload=Object.assign(conf.metadata,{time:(new Date).toISOString(),logLevel:conf.logLevel,msg:conf.msg});return JSON.stringify(payload)}export function msgTextFormatter(conf){let levelOut="";if(conf.logLevel==="silly"){levelOut="sil"}else if(conf.logLevel==="debug"){levelOut="deb"}else if(conf.logLevel==="verbose"){levelOut="ver"}else if(conf.logLevel==="info"){levelOut="inf"}else if(conf.logLevel==="warn"){levelOut="war"}else if(conf.logLevel==="error"){levelOut="err"}else{throw new Error(`Invalid conf.logLevel: "${conf.logLevel}"`)}let str=`${(new Date).toISOString().substring(0,19)}Z [${levelOut}] ${conf.msg}`;const metadataStr=JSON.stringify(conf.metadata);if(metadataStr!=="{}"){str+=` ${JSON.stringify(conf.metadata)}`}return str}export class Log{context;#logLevel;#entryFormatter;#stderr;#stdout;constructor(conf){if(conf===undefined){conf={}}else if(typeof conf==="string"){conf={logLevel:conf}}if(conf.logLevel===undefined){conf.logLevel="info"}if(conf.entryFormatter!==undefined){conf.entryFormatter=conf.entryFormatter}else if(conf.format==="json"){conf.entryFormatter=msgJsonFormatter}else{conf.entryFormatter=msgTextFormatter}if(conf.stderr===undefined){conf.stderr=console.error}if(conf.stdout===undefined){conf.stdout=console.log}this.#logLevel=conf.logLevel;this.#entryFormatter=conf.entryFormatter;this.#stderr=conf.stderr;this.#stdout=conf.stdout;this.context=conf.context||{}}error(msg,metadata){if(this.#logLevel==="none")return;this.#stderr(this.#entryFormatter({logLevel:"error",msg:msg,metadata:Object.assign(metadata||{},this.context)}))}warn(msg,metadata){if(["none","error"].includes(this.#logLevel))return;this.#stderr(this.#entryFormatter({logLevel:"warn",msg:msg,metadata:Object.assign(metadata||{},this.context)}))}info(msg,metadata){if(["none","error","warn"].includes(this.#logLevel))return;this.#stdout(this.#entryFormatter({logLevel:"info",msg:msg,metadata:Object.assign(metadata||{},this.context)}))}verbose(msg,metadata){if(["none","error","warn","info"].includes(this.#logLevel))return;this.#stdout(this.#entryFormatter({logLevel:"verbose",msg:msg,metadata:Object.assign(metadata||{},this.context)}))}debug(msg,metadata){if(["none","error","warn","info","verbose"].includes(this.#logLevel))return;this.#stdout(this.#entryFormatter({logLevel:"debug",msg:msg,metadata:Object.assign(metadata||{},this.context)}))}silly(msg,metadata){if(["none","error","warn","info","verbose","debug"].includes(this.#logLevel))return;this.#stdout(this.#entryFormatter({logLevel:"silly",msg:msg,metadata:Object.assign(metadata||{},this.context)}))}}
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAgCA,MAAM,UAAU,gBAAgB,CAAC,IAAwB;IACxD,MAAM,OAAO,GAA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