jet-logger 1.1.0 → 1.1.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.
package/README.md CHANGED
@@ -114,7 +114,7 @@ const customSend: TCustomLogger = (timestamp: Date, level: string, content: any)
114
114
  }
115
115
 
116
116
  router.get('api/users', async (req: Request, res: Reponse) => {
117
- const logger = new Logger(LoggerModes.CUSTOM, '', true, customSend);
117
+ const logger = JetLogger(LoggerModes.CUSTOM, '', true, customSend);
118
118
  logger.rmTimestamp = true;
119
119
  logger.info(req.params.msg);
120
120
  return res.status(OK).json({
package/lib/index.d.ts CHANGED
@@ -26,40 +26,40 @@ declare const levels: {
26
26
  prefix: string;
27
27
  };
28
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
29
  declare type TLevelProp = typeof levels[keyof typeof levels];
45
30
  declare type TJetLogger = ReturnType<typeof JetLogger>;
46
31
  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;
32
+ export declare function JetLogger(mode?: LoggerModes, filePath?: string, timestamp?: boolean, format?: Formats, customLogger?: TCustomLogger): {
33
+ readonly settings: {
34
+ readonly mode: LoggerModes;
35
+ readonly filePath: string;
36
+ readonly timestamp: boolean;
37
+ readonly format: Formats;
38
+ readonly customLogger: TCustomLogger | undefined;
54
39
  };
55
- info: typeof info;
56
- imp: typeof imp;
57
- warn: typeof warn;
58
- err: typeof err;
59
- printLogHelper: typeof printLogHelper;
60
- }>;
40
+ readonly info: typeof info;
41
+ readonly imp: typeof imp;
42
+ readonly warn: typeof warn;
43
+ readonly err: typeof err;
44
+ readonly printLog: typeof printLog;
45
+ };
61
46
  declare function info(this: TJetLogger, content: any, printFull?: boolean): void;
62
47
  declare function imp(this: TJetLogger, content: any, printFull?: boolean): void;
63
48
  declare function warn(this: TJetLogger, content: any, printFull?: boolean): void;
64
49
  declare function err(this: TJetLogger, content: any, printFull?: boolean): void;
65
- declare function printLogHelper(this: TJetLogger, content: any, printFull: boolean, level: TLevelProp): void;
50
+ declare function printLog(this: TJetLogger, content: any, printFull: boolean, level: TLevelProp): void;
51
+ declare const _default: {
52
+ readonly settings: {
53
+ readonly mode: LoggerModes;
54
+ readonly filePath: string;
55
+ readonly timestamp: boolean;
56
+ readonly format: Formats;
57
+ readonly customLogger: TCustomLogger | undefined;
58
+ };
59
+ readonly info: typeof info;
60
+ readonly imp: typeof imp;
61
+ readonly warn: typeof warn;
62
+ readonly err: typeof err;
63
+ readonly printLog: typeof printLog;
64
+ };
65
+ export default _default;
package/lib/index.js CHANGED
@@ -48,16 +48,15 @@ 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
+ printLog: printLog,
59
+ };
61
60
  }
62
61
  exports.JetLogger = JetLogger;
63
62
  function getSettings(mode, filePath, timestamp, format, customLogger) {
@@ -102,21 +101,19 @@ function getSettings(mode, filePath, timestamp, format, customLogger) {
102
101
  };
103
102
  }
104
103
  function info(content, printFull) {
105
- return this.printLogHelper(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.info);
104
+ return this.printLog(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.info);
106
105
  }
107
106
  function imp(content, printFull) {
108
- return this.printLogHelper(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.imp);
107
+ return this.printLog(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.imp);
109
108
  }
110
109
  function warn(content, printFull) {
111
- return this.printLogHelper(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.warn);
110
+ return this.printLog(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.warn);
112
111
  }
113
112
  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);
113
+ return this.printLog(content, printFull !== null && printFull !== void 0 ? printFull : false, levels.err);
118
114
  }
119
- function printLog(content, printFull, level, mode, timestamp, format, filePath, customLogger) {
115
+ function printLog(content, printFull, level) {
116
+ var _a = this.settings, mode = _a.mode, format = _a.format, timestamp = _a.timestamp, filePath = _a.filePath, customLogger = _a.customLogger;
120
117
  if (mode === LoggerModes.Off) {
121
118
  return;
122
119
  }
@@ -175,3 +172,4 @@ function writeToFile(content, filePath) {
175
172
  });
176
173
  });
177
174
  }
175
+ exports.default = JetLogger();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jet-logger",
3
- "version": "1.1.0",
3
+ "version": "1.1.4",
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",