Skip to content

Commit

Permalink
feat: adding corret return to string on formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
eudesenv committed Mar 12, 2024
1 parent 0c9e63c commit d70cb1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { LogMessage } from './type/log-message-type';
export class Formatter implements FormatterInterface {
constructor(
private readonly serviceName: string,
private readonly isDevelopmentEnv: boolean,
private readonly isDevelopmentEnv?: boolean,
) {}

format(message: string, level: string, args: LogMessageOptions): string | void {
format(message: string, level: string, args: LogMessageOptions): string {
const formattedMessage = {
message,
level,
Expand All @@ -17,7 +17,10 @@ export class Formatter implements FormatterInterface {
...args,
} as LogMessage;

if (this.isDevelopmentEnv) console.log(formattedMessage); return null;
if (this.isDevelopmentEnv) {
console.log(formattedMessage);
return '';
}

return JSON.stringify(formattedMessage);
}
Expand Down
1 change: 1 addition & 0 deletions src/core/type/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { LogLevel } from "./log-level";
export type Config = {
level: LogLevel;
serviceName: string;
isDevelopmentEnv?: boolean;
};

0 comments on commit d70cb1d

Please sign in to comment.