@sera4/essentia 1.0.31 → 1.0.32

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.
@@ -5,6 +5,22 @@ const colorizer = winston.format.colorize();
5
5
 
6
6
  require('winston-logstash');
7
7
 
8
+ // IETF RFC5424:
9
+ // Severity of all levels is assumed to be numerically ascending from most important to least important.
10
+ const levels = {
11
+ error: 0,
12
+ warn: 1,
13
+ info: 2,
14
+ debug: 3,
15
+ trace: 4,
16
+ }
17
+
18
+ // These colors are not used, however if colors are not defined for custom levels
19
+ // then winston will throw an exception.
20
+ winston.addColors({
21
+ trace: 'white'
22
+ })
23
+
8
24
  const devFormat = {
9
25
  transform(info) {
10
26
  const { message } = info;
@@ -17,10 +33,12 @@ const devFormat = {
17
33
  };
18
34
 
19
35
  const defaultTransport = new winston.transports.Console({
20
- format: devFormat
36
+ format: devFormat,
37
+ level: 'trace'
21
38
  });
22
39
 
23
40
  const logger = winston.createLogger({
41
+ levels: levels,
24
42
  level: 'debug',
25
43
  defaultMeta: { },
26
44
  transports: [defaultTransport]
@@ -32,9 +50,7 @@ class S4Logger {
32
50
  return;
33
51
  }
34
52
 
35
- if (options.level && ["debug", "info", "error", "warn"].indexOf(options.level.toLowerCase())) {
36
- logger.level = options.level;
37
- }
53
+ this.setLevel(options.level)
38
54
 
39
55
  logger.defaultMeta.service = options.service;
40
56
  switch(options.format.toLowerCase()) {
@@ -51,7 +67,7 @@ class S4Logger {
51
67
  }
52
68
 
53
69
  setLevel(level) {
54
- if (level && ["debug", "info", "error", "warn"].indexOf(level.toLowerCase())) {
70
+ if (level && ["trace", "debug", "info", "error", "warn"].indexOf(level.toLowerCase())) {
55
71
  logger.level = level;
56
72
  }
57
73
  }
@@ -68,6 +84,10 @@ class S4Logger {
68
84
  });
69
85
  }
70
86
 
87
+ trace(...args) {
88
+ logger.trace(util.format(...args));
89
+ }
90
+
71
91
  debug(...args) {
72
92
  logger.debug(util.format(...args));
73
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sera4/essentia",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "description": "A library of utilities for Teleporte Web Services",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/package.tar.gz CHANGED
Binary file