2.1.2 • Published 9 months ago

@dimjs/logger v2.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

@dimjs/logger

Simple, pretty and powerful logger for nodejs

Setup

Initialize

import { logger } from '@dimjs/logger';
logger.debug('hello', 'context');

And customized adapter with builtin sentry

import {
  createLogger,
  SentryAdapter,
  SentryFormatStrategy,
} from '@dimjs/logger';

const logger = createLogger({
  logLevel: LogLevel.Warn,
  adapter: new SentryAdapter({
    formatStrategy: new SentryFormatStrategy(),
  }),
});

logger.debug('hello', 'context');

And customized adapters

// customize custom adapter
export class CustomAdapter<T> implements LogAdapter<T> {
  isLoggable(priority: LogLevel, context?: string | undefined): boolean {
    throw new Error('Method not implemented.');
  }
  config(config?: LogAdapterConfig | undefined): LogAdapter {
    throw new Error('Method not implemented.');
  }
  print(priority: LogLevel, context: string, message: T, trace?: any): void {
    throw new Error('Method not implemented.');
  }
}
// customize custom format strategy for `CustomAdapter`
export class CustomFormatStrategy<T> implements FormatStrategy<T> {
  print(priority: LogLevel, context: string, message: T, trace?: any): void {
    throw new Error('Method not implemented.');
  }
}
// create new logger
const logger = createLogger({
  logLevel: LogLevel.Warn,
  adapter: new SentryAdapter({
    formatStrategy: new SentryFormatStrategy(),
  }),
});

// attach new adapter
logger.addLogAdapter(
  new SentryAdapter({
    formatStrategy: new SentryFormatStrategy(),
  })
);

logger.debug('print multi messages', 'demo');
2.1.2

9 months ago

2.0.3

1 year ago

2.1.1

10 months ago

2.0.5

12 months ago

2.0.4

12 months ago

2.0.11

10 months ago

2.0.7

12 months ago

2.0.12

10 months ago

2.0.6

12 months ago

2.0.9

11 months ago

2.0.10

10 months ago

2.1.0

10 months ago

2.0.2

1 year ago

2.0.0-next.2

1 year ago

2.0.0-next.1

2 years ago

2.0.1

1 year ago

2.0.0

1 year ago

1.5.6

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.5.0

2 years ago

1.4.8

2 years ago

1.4.6

2 years ago

1.4.5

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.3.10

2 years ago

1.3.8

2 years ago

1.3.11

2 years ago

1.3.7

3 years ago

1.3.4

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.41

3 years ago

1.2.42

3 years ago

1.2.40

3 years ago

1.2.39

3 years ago

1.2.37

3 years ago

1.2.36

3 years ago

1.2.33

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago