Skip to content

Instantly share code, notes, and snippets.

@lazywithclass
Last active December 4, 2018 20:22
Show Gist options
  • Save lazywithclass/c8ff480ff812fb5498cf7feda6416f98 to your computer and use it in GitHub Desktop.
Save lazywithclass/c8ff480ff812fb5498cf7feda6416f98 to your computer and use it in GitHub Desktop.

Revisions

  1. lazywithclass revised this gist Dec 4, 2018. 1 changed file with 10 additions and 13 deletions.
    23 changes: 10 additions & 13 deletions winston-cloudwatch-type-definition.d.ts
    Original file line number Diff line number Diff line change
    @@ -3,18 +3,19 @@ import * as Transport from 'winston-transport';

    import { CloudWatch, CloudWatchLogs } from 'aws-sdk';

    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;
    }

    declare module "winston" {
    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);
    @@ -31,10 +32,6 @@ declare module "winston" {
    silent?: boolean;
    }

    export interface Winston {
    add(transport: Transport): winston.Logger;
    }

    export interface CloudwatchTransportInstance extends winston.Logger {
    new(options?: CloudwatchTransportOptions): CloudwatchTransportInstance;
    kthxbye(cb: (() => void)): void;
  2. lazywithclass created this gist Dec 4, 2018.
    46 changes: 46 additions & 0 deletions winston-cloudwatch-type-definition.d.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    import * as winston from 'winston';
    import * as Transport from 'winston-transport';

    import { CloudWatch, CloudWatchLogs } from 'aws-sdk';

    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;
    }

    declare module "winston" {

    export type LogObject = {level: string, msg: string, meta?: any};

    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 Winston {
    add(transport: Transport): winston.Logger;
    }

    export interface CloudwatchTransportInstance extends winston.Logger {
    new(options?: CloudwatchTransportOptions): CloudwatchTransportInstance;
    kthxbye(cb: (() => void)): void;
    }

    export interface Transports {
    CloudWatch: CloudwatchTransportInstance
    }
    }