Skip to content

Commit

Permalink
chore: fix simple-logger defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Zorkaltsev committed Oct 10, 2023
1 parent a6e76a5 commit 213cbbb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/__tests__/utils/simple-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,17 @@ describe('logger', () => {

switch (env) {
case false:
logger = conf.level === undefined ? new SimpleLogger() : new SimpleLogger({ level: conf.level });
logger = conf.level === undefined
? new SimpleLogger({ showLevel: false, showTimestamp: false })
: new SimpleLogger({ level: conf.level, showLevel: false, showTimestamp: false });
break;
case true:
process.env.LOG_LEVEL = conf.level;
logger = new SimpleLogger();
logger = new SimpleLogger({ showLevel: false, showTimestamp: false });
break;
default:
process.env[env] = conf.level;
logger = new SimpleLogger({ envKey: env });
logger = new SimpleLogger({ envKey: env, showLevel: false, showTimestamp: false });
delete process.env[env];
}

Expand Down Expand Up @@ -110,7 +112,7 @@ describe('logger', () => {
}

it('different parameters of log method', () => {
const logger = new SimpleLogger();
const logger = new SimpleLogger({ showLevel: false, showTimestamp: false });

const a = {
b: {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/simple-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ export class SimpleLogger implements SimpleLogger.Logger {
} = options;

if (prefix) this.prefix = prefix;
this.showTimestamp = showTimestamp ?? false;
this.showLevel = showLevel ?? false;
this.showTimestamp = showTimestamp ?? true;
this.showLevel = showLevel ?? true;

const envKey = options.envKey ?? DEFAULT_ENV_KEY;
const envLevel = process.env[envKey];
Expand Down

0 comments on commit 213cbbb

Please sign in to comment.