@ejfdelgado/ejflab-back 1.30.12 → 1.31.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/srv/ConsoleSrv.mjs +30 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-back",
3
- "version": "1.30.12",
3
+ "version": "1.31.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ejfdelgado/ejflab-back.git"
@@ -0,0 +1,30 @@
1
+ export class consoleSrv {
2
+ static getLogLevel() {
3
+ let current = process.env.LOGLEVEL;
4
+ if (!current) {
5
+ current = "error";
6
+ }
7
+ return current;
8
+ }
9
+ static info(...args) {
10
+ this.log(...args);
11
+ }
12
+ static log(...args) {
13
+ const level = consoleSrv.getLogLevel();
14
+ if (["info"].indexOf(level) >= 0) {
15
+ console.log(...args);
16
+ }
17
+ }
18
+ static warning(...args) {
19
+ const level = consoleSrv.getLogLevel();
20
+ if (["warning", "info"].indexOf(level) >= 0) {
21
+ console.warn(...args);
22
+ }
23
+ }
24
+ static error(...args) {
25
+ const level = consoleSrv.getLogLevel();
26
+ if (["error", "warning", "info"].indexOf(level) >= 0) {
27
+ console.error(...args);
28
+ }
29
+ }
30
+ }