2.1.2 • Published 9 months ago
@dimjs/sentry v2.1.2
@dimjs/sentry
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.1
1 year ago
2.0.0
1 year ago
2.0.0-next.2
1 year ago
2.0.0-next.1
2 years ago