Skip to content

Commit

Permalink
[logging] Make logger with global root
Browse files Browse the repository at this point in the history
  • Loading branch information
smialy committed Aug 2, 2021
1 parent 29b4699 commit 09c6e22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions packages/logging/src/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ILogger } from './types';
import { LoggerFactory } from './logger';

const symbol = Symbol('logger-factory');
const NAME = 'global-logger-factory';


if (!globalThis[symbol]) {
globalThis[symbol] = new LoggerFactory();
if (!globalThis[NAME]) {
globalThis[NAME] = new LoggerFactory();
}

export function getLogger(name?: string): ILogger {
return globalThis[symbol].getLogger(name);
return globalThis[NAME].getLogger(name);
}
7 changes: 4 additions & 3 deletions packages/logging/src/formaters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ export const DEFAULT_FORMATERS: TFormaters = {
}
};

const DEFAULT_TEMPLATE = '{created}::{name}::{levelName}::{msg}';
const DEFAULT_TEMPLATE = '{created}|{levelName}|{name}|{msg}{exception}';

export class SimpleFormater implements IFormater {
static BASIC = "{name}::{levelName}::{msg}{exception}";
static FULL = "{created}::{name}::{levelName}::{msg}{exception}";
static FULL = DEFAULT_TEMPLATE;
static BASIC = "{levelName}|{name}|{msg}{exception}";
static MINIMAL = "{msg}{exception}";

constructor(
private template: string = DEFAULT_TEMPLATE,
Expand Down

0 comments on commit 09c6e22

Please sign in to comment.