90dc-core 1.2.3 → 1.2.4

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.
@@ -3,6 +3,7 @@ declare class Logger {
3
3
  private static _serviceName;
4
4
  static get serviceName(): string;
5
5
  static set serviceName(value: string);
6
+ constructor(name: string);
6
7
  static getLogger(): winston.Logger;
7
8
  }
8
9
  export default Logger;
@@ -7,6 +7,9 @@ class Logger {
7
7
  static set serviceName(value) {
8
8
  this._serviceName = value;
9
9
  }
10
+ constructor(name) {
11
+ Logger._serviceName = name;
12
+ }
10
13
  static getLogger() {
11
14
  const levels = {
12
15
  error: 0,
@@ -30,7 +33,7 @@ class Logger {
30
33
  winston.addColors(colors);
31
34
  const format = winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss:ms' }), winston.format.colorize({ all: true }), winston.format.printf(
32
35
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
33
- (info) => `${info.timestamp}@${this._serviceName} ${info.level}: ${info.message}`));
36
+ (info) => `${info.timestamp}@${this._serviceName}/${info.level}: ${info.message}`));
34
37
  const transports = [
35
38
  new winston.transports.Console(),
36
39
  new winston.transports.File({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/utils/Logger.ts"],"sourcesContent":["import winston from 'winston'\n\nclass Logger {\n\n private static _serviceName = \"\";\n\n static get serviceName(): string {\n return this._serviceName;\n }\n\n static set serviceName(value: string) {\n this._serviceName = value;\n }\n\n public static getLogger(){\n const levels = {\n error: 0,\n warn: 1,\n info: 2,\n http: 3,\n debug: 4,\n }\n\n const level = () => {\n const env = process.env.NODE_ENV || 'development'\n const isDevelopment = env === 'development'\n return isDevelopment ? 'debug' : 'warn'\n }\n\n const colors = {\n error: 'red',\n warn: 'yellow',\n info: 'green',\n http: 'magenta',\n debug: 'white',\n }\n\n winston.addColors(colors)\n\n const format: winston.Logform.Format = winston.format.combine(\n winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss:ms' }),\n winston.format.colorize({ all: true }),\n winston.format.printf(\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n (info) => `${info.timestamp}@${this._serviceName} ${info.level}: ${info.message}`,\n ),\n )\n\n const transports = [\n new winston.transports.Console(),\n new winston.transports.File({\n filename: 'logs/error.log',\n level: 'error',\n }),\n new winston.transports.File({ filename: 'logs/all.log' }),\n ]\n return winston.createLogger({\n level: level(),\n levels,\n format,\n transports,\n })\n\n }\n}\n\n\nexport default Logger"],"names":["winston","Logger","_serviceName","serviceName","value","getLogger","levels","error","warn","info","http","debug","level","env","process","NODE_ENV","isDevelopment","colors","addColors","format","combine","timestamp","colorize","all","printf","message","transports","Console","File","filename","createLogger"],"mappings":"AAAA,OAAOA,aAAa,UAAS;AAE7B,MAAMC;IAEJ,OAAeC,eAAe,GAAG;IAEjC,WAAWC,cAAsB;QAC/B,OAAO,IAAI,CAACD,YAAY;IAC1B;IAEA,WAAWC,YAAYC,KAAa,EAAE;QACpC,IAAI,CAACF,YAAY,GAAGE;IACtB;IAEA,OAAcC,YAAW;QACvB,MAAMC,SAAS;YACbC,OAAO;YACPC,MAAM;YACNC,MAAM;YACNC,MAAM;YACNC,OAAO;QACT;QAEA,MAAMC,QAAQ,IAAM;YAClB,MAAMC,MAAMC,QAAQD,GAAG,CAACE,QAAQ,IAAI;YACpC,MAAMC,gBAAgBH,QAAQ;YAC9B,OAAOG,gBAAgB,UAAU,MAAM;QACzC;QAEA,MAAMC,SAAS;YACbV,OAAO;YACPC,MAAM;YACNC,MAAM;YACNC,MAAM;YACNC,OAAO;QACT;QAEAX,QAAQkB,SAAS,CAACD;QAElB,MAAME,SAAiCnB,QAAQmB,MAAM,CAACC,OAAO,CAC3DpB,QAAQmB,MAAM,CAACE,SAAS,CAAC;YAAEF,QAAQ;QAAyB,IAC5DnB,QAAQmB,MAAM,CAACG,QAAQ,CAAC;YAAEC,KAAK,IAAI;QAAC,IACpCvB,QAAQmB,MAAM,CAACK,MAAM,CACnB,4EAA4E;QAC5E,CAACf,OAAS,CAAC,EAAEA,KAAKY,SAAS,CAAC,CAAC,EAAE,IAAI,CAACnB,YAAY,CAAC,CAAC,EAAEO,KAAKG,KAAK,CAAC,EAAE,EAAEH,KAAKgB,OAAO,CAAC,CAAC;QAIrF,MAAMC,aAAa;YACjB,IAAI1B,QAAQ0B,UAAU,CAACC,OAAO;YAC9B,IAAI3B,QAAQ0B,UAAU,CAACE,IAAI,CAAC;gBAC1BC,UAAU;gBACVjB,OAAO;YACT;YACA,IAAIZ,QAAQ0B,UAAU,CAACE,IAAI,CAAC;gBAAEC,UAAU;YAAe;SACxD;QACD,OAAO7B,QAAQ8B,YAAY,CAAC;YAC1BlB,OAAOA;YACPN;YACAa;YACAO;QACF;IAEF;AACF;AAGA,eAAezB,OAAM"}
1
+ {"version":3,"sources":["../../../src/lib/utils/Logger.ts"],"sourcesContent":["import winston from 'winston'\n\nclass Logger {\n\n private static _serviceName = \"\";\n\n static get serviceName(): string {\n return this._serviceName;\n }\n\n static set serviceName(value: string) {\n this._serviceName = value;\n }\n\n constructor(name: string) {\n Logger._serviceName = name;\n }\n\n public static getLogger(){\n const levels = {\n error: 0,\n warn: 1,\n info: 2,\n http: 3,\n debug: 4,\n }\n\n const level = () => {\n const env = process.env.NODE_ENV || 'development'\n const isDevelopment = env === 'development'\n return isDevelopment ? 'debug' : 'warn'\n }\n\n const colors = {\n error: 'red',\n warn: 'yellow',\n info: 'green',\n http: 'magenta',\n debug: 'white',\n }\n\n winston.addColors(colors)\n\n const format: winston.Logform.Format = winston.format.combine(\n winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss:ms' }),\n winston.format.colorize({ all: true }),\n winston.format.printf(\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n (info) => `${info.timestamp}@${this._serviceName}/${info.level}: ${info.message}`,\n ),\n )\n\n const transports = [\n new winston.transports.Console(),\n new winston.transports.File({\n filename: 'logs/error.log',\n level: 'error',\n }),\n new winston.transports.File({ filename: 'logs/all.log' }),\n ]\n return winston.createLogger({\n level: level(),\n levels,\n format,\n transports,\n })\n\n }\n}\n\n\nexport default Logger"],"names":["winston","Logger","_serviceName","serviceName","value","constructor","name","getLogger","levels","error","warn","info","http","debug","level","env","process","NODE_ENV","isDevelopment","colors","addColors","format","combine","timestamp","colorize","all","printf","message","transports","Console","File","filename","createLogger"],"mappings":"AAAA,OAAOA,aAAa,UAAS;AAE7B,MAAMC;IAEJ,OAAeC,eAAe,GAAG;IAEjC,WAAWC,cAAsB;QAC/B,OAAO,IAAI,CAACD,YAAY;IAC1B;IAEA,WAAWC,YAAYC,KAAa,EAAE;QACpC,IAAI,CAACF,YAAY,GAAGE;IACtB;IAEAC,YAAYC,IAAY,CAAE;QACxBL,OAAOC,YAAY,GAAGI;IACxB;IAEA,OAAcC,YAAW;QACvB,MAAMC,SAAS;YACbC,OAAO;YACPC,MAAM;YACNC,MAAM;YACNC,MAAM;YACNC,OAAO;QACT;QAEA,MAAMC,QAAQ,IAAM;YAClB,MAAMC,MAAMC,QAAQD,GAAG,CAACE,QAAQ,IAAI;YACpC,MAAMC,gBAAgBH,QAAQ;YAC9B,OAAOG,gBAAgB,UAAU,MAAM;QACzC;QAEA,MAAMC,SAAS;YACbV,OAAO;YACPC,MAAM;YACNC,MAAM;YACNC,MAAM;YACNC,OAAO;QACT;QAEAb,QAAQoB,SAAS,CAACD;QAElB,MAAME,SAAiCrB,QAAQqB,MAAM,CAACC,OAAO,CAC3DtB,QAAQqB,MAAM,CAACE,SAAS,CAAC;YAAEF,QAAQ;QAAyB,IAC5DrB,QAAQqB,MAAM,CAACG,QAAQ,CAAC;YAAEC,KAAK,IAAI;QAAC,IACpCzB,QAAQqB,MAAM,CAACK,MAAM,CACnB,4EAA4E;QAC5E,CAACf,OAAS,CAAC,EAAEA,KAAKY,SAAS,CAAC,CAAC,EAAE,IAAI,CAACrB,YAAY,CAAC,CAAC,EAAES,KAAKG,KAAK,CAAC,EAAE,EAAEH,KAAKgB,OAAO,CAAC,CAAC;QAIrF,MAAMC,aAAa;YACjB,IAAI5B,QAAQ4B,UAAU,CAACC,OAAO;YAC9B,IAAI7B,QAAQ4B,UAAU,CAACE,IAAI,CAAC;gBAC1BC,UAAU;gBACVjB,OAAO;YACT;YACA,IAAId,QAAQ4B,UAAU,CAACE,IAAI,CAAC;gBAAEC,UAAU;YAAe;SACxD;QACD,OAAO/B,QAAQgC,YAAY,CAAC;YAC1BlB,OAAOA;YACPN;YACAa;YACAO;QACF;IAEF;AACF;AAGA,eAAe3B,OAAM"}
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "90dc-core",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "A package that contains utils and interfaces used to create 90dc",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "devDependencies": {
8
8
  "@swc/cli": "^0.1.62",
9
9
  "@swc/core": "^1.3.36",
10
- "@types/jest": "^29.2.6",
11
- "@types/node": "^18.13.0",
10
+ "@types/jest": "^29.4.0",
11
+ "@types/node": "^18.14.1",
12
12
  "@types/validator": "^13.7.12",
13
13
  "@typescript-eslint/eslint-plugin": "^5.53.0",
14
- "jest": "^29.3.1",
15
- "prettier": "^2.8.3",
14
+ "jest": "^29.4.3",
15
+ "prettier": "^2.8.4",
16
16
  "ts-jest": "^29.0.5",
17
17
  "ts-node": "^10.9.1",
18
18
  "ts-node-dev": "^2.0.0",
19
- "typescript": "^4.9.4"
19
+ "typescript": "^4.9.5"
20
20
  },
21
21
  "dependencies": {
22
22
  "@typescript-eslint/parser": "^5.53.0",
@@ -12,6 +12,10 @@ class Logger {
12
12
  this._serviceName = value;
13
13
  }
14
14
 
15
+ constructor(name: string) {
16
+ Logger._serviceName = name;
17
+ }
18
+
15
19
  public static getLogger(){
16
20
  const levels = {
17
21
  error: 0,
@@ -42,7 +46,7 @@ class Logger {
42
46
  winston.format.colorize({ all: true }),
43
47
  winston.format.printf(
44
48
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
45
- (info) => `${info.timestamp}@${this._serviceName} ${info.level}: ${info.message}`,
49
+ (info) => `${info.timestamp}@${this._serviceName}/${info.level}: ${info.message}`,
46
50
  ),
47
51
  )
48
52