jet-logger 1.1.1 → 1.1.5

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/lib/index.d.ts CHANGED
@@ -8,58 +8,36 @@ export declare enum Formats {
8
8
  Line = "LINE",
9
9
  Json = "JSON"
10
10
  }
11
- declare const levels: {
12
- info: {
13
- color: string;
14
- prefix: string;
15
- };
16
- imp: {
17
- color: string;
18
- prefix: string;
19
- };
20
- warn: {
21
- color: string;
22
- prefix: string;
23
- };
24
- err: {
25
- color: string;
26
- prefix: string;
27
- };
28
- };
29
- declare const _default: Readonly<{
30
- settings: {
31
- mode: LoggerModes;
32
- filePath: string;
33
- timestamp: boolean;
34
- format: Formats;
35
- customLogger: TCustomLogger | undefined;
36
- };
37
- info: typeof info;
38
- imp: typeof imp;
39
- warn: typeof warn;
40
- err: typeof err;
41
- printLogHelper: typeof printLogHelper;
42
- }>;
43
- export default _default;
44
- declare type TLevelProp = typeof levels[keyof typeof levels];
45
11
  declare type TJetLogger = ReturnType<typeof JetLogger>;
46
12
  export declare type TCustomLogger = (timestamp: Date, prefix: string, content: any) => void;
47
- export declare function JetLogger(mode?: LoggerModes, filePath?: string, timestamp?: boolean, format?: Formats, customLogger?: TCustomLogger): Readonly<{
48
- settings: {
49
- mode: LoggerModes;
50
- filePath: string;
51
- timestamp: boolean;
52
- format: Formats;
53
- customLogger: TCustomLogger | undefined;
13
+ export declare function JetLogger(mode?: LoggerModes, filePath?: string, timestamp?: boolean, format?: Formats, customLogger?: TCustomLogger): {
14
+ readonly settings: {
15
+ readonly mode: LoggerModes;
16
+ readonly filePath: string;
17
+ readonly timestamp: boolean;
18
+ readonly format: Formats;
19
+ readonly customLogger: TCustomLogger | undefined;
54
20
  };
55
- info: typeof info;
56
- imp: typeof imp;
57
- warn: typeof warn;
58
- err: typeof err;
59
- printLogHelper: typeof printLogHelper;
60
- }>;
21
+ readonly info: typeof info;
22
+ readonly imp: typeof imp;
23
+ readonly warn: typeof warn;
24
+ readonly err: typeof err;
25
+ };
61
26
  declare function info(this: TJetLogger, content: any, printFull?: boolean): void;
62
27
  declare function imp(this: TJetLogger, content: any, printFull?: boolean): void;
63
28
  declare function warn(this: TJetLogger, content: any, printFull?: boolean): void;
64
29
  declare function err(this: TJetLogger, content: any, printFull?: boolean): void;
65
- declare function printLogHelper(this: TJetLogger, content: any, printFull: boolean, level: TLevelProp): void;
30
+ declare const _default: {
31
+ readonly settings: {
32
+ readonly mode: LoggerModes;
33
+ readonly filePath: string;
34
+ readonly timestamp: boolean;
35
+ readonly format: Formats;
36
+ readonly customLogger: TCustomLogger | undefined;
37
+ };
38
+ readonly info: typeof info;
39
+ readonly imp: typeof imp;
40
+ readonly warn: typeof warn;
41
+ readonly err: typeof err;
42
+ };
43
+ export default _default;
package/lib/index.js CHANGED
@@ -48,16 +48,14 @@ var defaults = {
48
48
  timestamp: true,
49
49
  format: Formats.Line,
50
50
  };
51
- exports.default = JetLogger();
52
51
  function JetLogger(mode, filePath, timestamp, format, customLogger) {
53
- return Object.freeze({
52
+ return {
54
53
  settings: getSettings(mode, filePath, timestamp, format, customLogger),
55
54
  info: info,
56
55
  imp: imp,
57
56
  warn: warn,
58
57
  err: err,
59
- printLogHelper: printLogHelper,
60
- });
58
+ };
61
59
  }
62
60
  exports.JetLogger = JetLogger;
63
61
  function getSettings(mode, filePath, timestamp, format, customLogger) {
@@ -102,21 +100,19 @@ function getSettings(mode, filePath, timestamp, format, customLogger) {
102
100
  };
103
101
  }
104
102
  function info(content, printFull) {
105
- return this.printLogHelper(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.info);
103
+ return printLog(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.info, this.settings);
106
104
  }
107
105
  function imp(content, printFull) {
108
- return this.printLogHelper(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.imp);
106
+ return printLog(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.imp, this.settings);
109
107
  }
110
108
  function warn(content, printFull) {
111
- return this.printLogHelper(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.warn);
109
+ return printLog(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.warn, this.settings);
112
110
  }
113
111
  function err(content, printFull) {
114
- return this.printLogHelper(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.err);
115
- }
116
- function printLogHelper(content, printFull, level) {
117
- return printLog(content, printFull, level, this.settings.mode, this.settings.timestamp, this.settings.format, this.settings.filePath, this.settings.customLogger);
112
+ return printLog(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.err, this.settings);
118
113
  }
119
- function printLog(content, printFull, level, mode, timestamp, format, filePath, customLogger) {
114
+ function printLog(content, printFull, level, settings) {
115
+ var mode = settings.mode, format = settings.format, timestamp = settings.timestamp, filePath = settings.filePath, customLogger = settings.customLogger;
120
116
  if (mode === LoggerModes.Off) {
121
117
  return;
122
118
  }
@@ -175,3 +171,4 @@ function writeToFile(content, filePath) {
175
171
  });
176
172
  });
177
173
  }
174
+ exports.default = JetLogger();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jet-logger",
3
- "version": "1.1.1",
3
+ "version": "1.1.5",
4
4
  "description": "A super quick, easy to setup logging tool for NodeJS/TypeScript.",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "./lib/index.d.ts",