Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add metrics #102

Merged
merged 28 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/logger/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { ConfigServiceInterface, EnvironmentVariablesService } from './config';
import {
Environment,
HandlerMethodDecorator,
PowertoolLogData,
LambdaFunctionContext,
LogAttributes,
ClassThatLogs,
LoggerOptions,
LogItemExtraInput,
LogItemMessage,
LogLevel,
LogLevelThresholds,
LambdaFunctionContext,
LogItemMessage,
LogItemExtraInput,
PowertoolLogData,
} from '../types';
import { LogFormatterInterface, PowertoolLogFormatter } from './formatter';

Expand All @@ -33,7 +33,7 @@ class Logger implements ClassThatLogs {
private logLevel?: LogLevel;

private readonly logLevelThresholds: LogLevelThresholds = {
'DEBUG' : 8,
'DEBUG': 8,
'INFO': 12,
'WARN': 16,
'ERROR': 20
Expand Down Expand Up @@ -99,7 +99,7 @@ class Logger implements ClassThatLogs {
}

public injectLambdaContext(): HandlerMethodDecorator {
return (target, propertyKey, descriptor ) => {
return (target, propertyKey, descriptor) => {
const originalMethod = descriptor.value;

descriptor.value = (event, context, callback) => {
Expand Down Expand Up @@ -166,7 +166,7 @@ class Logger implements ClassThatLogs {
const attributes = (item instanceof Error) ? { error: item } : item;
logItem.addAttributes(attributes);
});

return logItem;
}

Expand Down Expand Up @@ -228,7 +228,7 @@ class Logger implements ClassThatLogs {
}

private setCustomConfigService(customConfigService?: ConfigServiceInterface): void {
this.customConfigService = customConfigService? customConfigService : undefined;
this.customConfigService = customConfigService ? customConfigService : undefined;
}

private setEnvVarsService(): void {
Expand Down Expand Up @@ -298,7 +298,7 @@ class Logger implements ClassThatLogs {
sampleRateValue: this.getSampleRateValue(),
serviceName: serviceName || this.getCustomConfigService()?.getServiceName() || this.getEnvVarsService().getServiceName(),
xRayTraceId: this.getEnvVarsService().getXrayTraceId(),
}, persistentLogAttributes );
}, persistentLogAttributes);
}

private shouldPrint(logLevel: LogLevel): boolean {
Expand Down
Loading