Skip to content

Instantly share code, notes, and snippets.

@lazywithclass
Last active December 4, 2018 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazywithclass/c8ff480ff812fb5498cf7feda6416f98 to your computer and use it in GitHub Desktop.
Save lazywithclass/c8ff480ff812fb5498cf7feda6416f98 to your computer and use it in GitHub Desktop.
winston-cloudwatch-type-definition
import * as winston from 'winston';
import * as Transport from 'winston-transport';
import { CloudWatch, CloudWatchLogs } from 'aws-sdk';
export namespace WinstonCloudWatch {
export type LogObject = {level: string, msg: string, meta?: any};
export interface CloudWatchIntegration {
upload(aws: CloudWatchLogs, groupName: string, streamName: string, logEvents: any[], retentionInDays: number, cb: ((err: Error, data: any) => void)): void;
getToken(aws: CloudWatchLogs, groupName: string, streamName: string, retentionInDays: number, cb: ((err: Error, data: string) => void)): void;
ensureGroupPresent(aws: CloudWatchLogs, name: string, retentionInDays: number, cb: ((err: Error, data: boolean) => void)): void;
getStream(aws: CloudWatchLogs, groupName: string, streamName: string, cb: ((err: Error, data: CloudWatchLogs.Types.DescribeLogStreamsResponse) => void)): void;
ignoreInProgress(cb: ((err: Error) => void)): void;
new(options?: CloudwatchTransportOptions): winston.Logger;
}
export interface CloudwatchTransportOptions {
level?: string;
logGroupName?: string | (() => string);
logStreamName?: string | (() => string);
awsAccessKeyId?: string;
awsSecretKey?: string;
awsRegion?: string;
awsOptions?: CloudWatch.Types.ClientConfiguration;
jsonMessage?: boolean;
messageFormatter?: (logObject: LogObject) => string;
proxyServer?: string;
uploadRate?: number;
errorHandler?: ((err: Error) => void);
silent?: boolean;
}
export interface CloudwatchTransportInstance extends winston.Logger {
new(options?: CloudwatchTransportOptions): CloudwatchTransportInstance;
kthxbye(cb: (() => void)): void;
}
export interface Transports {
CloudWatch: CloudwatchTransportInstance
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment