Skip to content

Commit

Permalink
Merge pull request #3 from JayPaulinCodes/develop
Browse files Browse the repository at this point in the history
RELEASE v0.1.1
  • Loading branch information
JayPaulinCodes authored Mar 4, 2024
2 parents a1d2cc3 + e8686e6 commit 0bca965
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devjacob/logger",
"version": "0.1.0",
"version": "0.1.1",
"description": "A simple logger package",
"author": "Jacob Paulin",
"license": "MPL-2.0",
Expand Down
44 changes: 28 additions & 16 deletions src/enums/LogFormatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,25 @@ export const LogFormatting: { [index: string]: (this: Logger, data: { [index: st

const unfilledString = data.err === undefined
? this.options.timestamp
? "'['HH:MM:ss.l Z'] %s: %s'"
? "%s %s: %s"
: "%s: %s"
: this.options.timestamp
? "'['HH:MM:ss.l Z'] %s: %s\n%s'"
? "%s %s: %s\n%s"
: "%s: %s\n%s";

const filledString = data.err === undefined
? format(unfilledString, level, msg)
: format(unfilledString, level, msg, stack);
const timestamp = this.options.timestamp
? dateFormat(data.time, "'['HH:MM:ss.l Z']'", this.options.output.useZuluTime)
: null;

return this.options.timestamp
? dateFormat(data.time, filledString, this.options.output.useZuluTime)
: filledString;
const formatParams = data.err === undefined
? this.options.timestamp
? [ timestamp, level, msg ]
: [ level, msg ]
: this.options.timestamp
? [ timestamp, level, msg, stack ]
: [ level, msg, stack ];

return format(unfilledString, ...formatParams);
},
["standard-full-date"]: function(this: Logger, data: { [index: string]: any }): string {
const level = String(data.level).toUpperCase();
Expand All @@ -46,18 +52,24 @@ export const LogFormatting: { [index: string]: (this: Logger, data: { [index: st

const unfilledString = data.err === undefined
? this.options.timestamp
? "'['yyyy-mm-dd HH:MM:ss.l Z'] %s: %s'"
? "%s %s: %s"
: "%s: %s"
: this.options.timestamp
? "'['yyyy-mm-dd HH:MM:ss.l Z'] %s: %s\n%s'"
? "%s %s: %s\n%s"
: "%s: %s\n%s";

const filledString = data.err === undefined
? format(unfilledString, level, msg)
: format(unfilledString, level, msg, stack);
const timestamp = this.options.timestamp
? dateFormat(data.time, "'['yyyy-mm-dd HH:MM:ss.l Z']'", this.options.output.useZuluTime)
: null;

const formatParams = data.err === undefined
? this.options.timestamp
? [ timestamp, level, msg ]
: [ level, msg ]
: this.options.timestamp
? [ timestamp, level, msg, stack ]
: [ level, msg, stack ];

return this.options.timestamp
? dateFormat(data.time, filledString, this.options.output.useZuluTime)
: filledString;
return format(unfilledString, ...formatParams);
}
} as const;

0 comments on commit 0bca965

Please sign in to comment.