Skip to content

Commit

Permalink
feat: add isDev prop options on logger instance
Browse files Browse the repository at this point in the history
  • Loading branch information
demmorou committed Apr 30, 2024
1 parent a7e3d7b commit acd9550
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@demmorou/logger",
"version": "1.0.6",
"version": "1.0.7",
"author": "Deusimar (@demmorou)",
"description": "Custom logger implementation with winston",
"main": "dist/index.js",
Expand Down
8 changes: 6 additions & 2 deletions packages/logger/src/implementations/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ export class Logger {

this.logger = winston.createLogger({
level: "debug",
defaultMeta: { ...this.options },
defaultMeta: {
env: this.options.env,
app_name: this.options.app_name,
version: this.options.version,
},
format: winston.format.combine(
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
winston.format.metadata({
Expand All @@ -28,7 +32,7 @@ export class Logger {
winston.format.json()
),
transports: [
this.options.env === "develop"
this.options.isDev
? new winston.transports.Console({
format: winston.format.combine(
winston.format.colorize({ all: true }),
Expand Down
3 changes: 2 additions & 1 deletion packages/logger/src/interfaces/logger.interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export type LoggerOptions = {
app_name: string;
version: string;
env?: string;
isDev: boolean;
env: string;
};

0 comments on commit acd9550

Please sign in to comment.