Merge pull request #5715 from mizunashi-mana/fix-winston-transports

make instances ddspecific in `winston`
This commit is contained in:
Horiuchi_H
2015-09-08 10:37:53 +09:00
2 changed files with 168 additions and 17 deletions
+28 -3
View File
@@ -165,25 +165,46 @@ var logger: winston.LoggerInstance = new (winston.Logger)({
new (winston.transports.Console)({
level: str,
silent: bool,
json: bool,
colorize: bool,
timestamp: bool,
showLevel: bool,
label: str,
logstash: bool,
debugStdout: bool,
depth: num,
}),
new (winston.transports.DailyRotateFile)({
level: str,
silent: bool,
json: bool,
colorize: bool,
maxsize: num,
maxFiles: num,
maxRetries: num,
prettyPrint: bool,
timestamp: bool,
filename: str,
dirname: str,
datePattern: str
datePattern: str,
eol: str,
stream: writeableStream,
}),
new (winston.transports.File)({
level: str,
silent: bool,
json: bool,
colorize: bool,
prettyPrint: bool,
timestamp: bool,
showLevel: bool,
logstash: bool,
rotationFormat: bool,
depth: num,
zippedArchive: bool,
eol: str,
tailable: bool,
maxRetries: num,
filename: str,
maxsize: num,
maxFiles: num,
@@ -195,7 +216,7 @@ var logger: winston.LoggerInstance = new (winston.Logger)({
port: num,
path: str,
auth: { username: str, password: str },
ssl: {},
ssl: bool,
}),
new (winston.transports.Loggly)({
level: str,
@@ -206,6 +227,10 @@ var logger: winston.LoggerInstance = new (winston.Logger)({
}),
new (winston.transports.Memory)({
level: str,
json: bool,
colorize: bool,
showLevel: bool,
depth: num,
timestamp: bool,
label: str,
}),
@@ -217,7 +242,7 @@ var logger: winston.LoggerInstance = new (winston.Logger)({
method: str,
path: str,
auth: { username: str, password: str },
ssl: {},
ssl: {ca: {}},
}),
]
});
+140 -14
View File
@@ -8,7 +8,6 @@
/// <reference path="../node/node.d.ts" />
declare module "winston" {
export var transports: Transports;
export var Transport: TransportStatic;
export var Logger: LoggerStatic;
@@ -110,10 +109,38 @@ declare module "winston" {
}
export interface TransportInstance extends TransportStatic, NodeJS.EventEmitter {
formatQuery(query: any): any;
formatQuery(query: (string|Object)): (string|Object);
normalizeQuery(options: QueryOptions): QueryOptions;
formatResults(results: any, options: any): any;
logException(msg: string, meta: any, callback: () => void): void;
formatResults(results: (Object|Array<any>), options?: Object): (Object|Array<any>);
logException(msg: string, meta: Object, callback: () => void): void;
}
export interface ConsoleTransportInstance extends TransportInstance {
new (options?: ConsoleTransportOptions): ConsoleTransportInstance;
}
export interface DailyRotateFileTransportInstance extends TransportInstance {
new (options?: DailyRotateFileTransportOptions): DailyRotateFileTransportInstance;
}
export interface FileTransportInstance extends TransportInstance {
new (options?: FileTransportOptions): FileTransportInstance;
}
export interface HttpTransportInstance extends TransportInstance {
new (options?: HttpTransportOptions): HttpTransportInstance;
}
export interface MemoryTransportInstance extends TransportInstance {
new (options?: MemoryTransportOptions): MemoryTransportInstance;
}
export interface WebhookTransportInstance extends TransportInstance {
new (options?: WebhookTransportOptions): WebhookTransportInstance;
}
export interface WinstonModuleTrasportInstance extends TransportInstance {
new (options?: WinstonMoudleTransportOptions): WinstonModuleTrasportInstance;
}
export interface ContainerStatic {
@@ -131,13 +158,13 @@ declare module "winston" {
}
export interface Transports {
File: TransportInstance;
Console: TransportInstance;
Loggly: TransportInstance;
DailyRotateFile: TransportInstance;
Http: TransportInstance;
Memory: TransportInstance;
Webhook: TransportInstance;
File: FileTransportInstance;
Console: ConsoleTransportInstance;
Loggly: WinstonModuleTrasportInstance;
DailyRotateFile: DailyRotateFileTransportInstance;
Http: HttpTransportInstance;
Memory: MemoryTransportInstance;
Webhook: WebhookTransportInstance;
}
export interface TransportOptions {
@@ -145,11 +172,110 @@ declare module "winston" {
silent?: boolean;
raw?: boolean;
name?: string;
formatter?: Function;
handleExceptions?: boolean;
exceptionsLevel?: string;
humanReadableUnhandledException?: boolean;
}
// TODO: Need to make instances specific,
// and need to get options for each instance.
// Unfortunately, the documentation is unhelpful.
export interface ConsoleTransportOptions extends TransportOptions {
json?: boolean;
colorize?: boolean;
prettyPrint?: boolean;
timestamp?: (Function|boolean);
showLevel?: boolean;
label?: string;
logstash?: boolean;
debugStdout?: boolean;
depth?: number;
}
export interface DailyRotateFileTransportOptions extends TransportOptions {
json?: boolean;
colorize?: boolean;
prettyPrint?: boolean;
timestamp?: (Function|boolean);
showLevel?: boolean;
label?: string;
logstash?: boolean;
depth?: number;
maxsize?: number;
maxFiles?: number;
eol?: string;
maxRetries?: number;
datePattern?: string;
filename?: string;
dirname?: string;
options?: {
flags?: string;
highWaterMark?: number;
}
stream?: NodeJS.WritableStream;
}
export interface FileTransportOptions extends TransportOptions {
json?: boolean;
colorize?: boolean;
prettyPrint?: boolean;
timestamp?: (Function|boolean);
showLevel?: boolean;
label?: string;
logstash?: boolean;
depth?: number;
maxsize?: number;
rotationFormat?: boolean;
zippedArchive?: boolean;
maxFiles?: number;
eol?: string;
tailable?: boolean;
maxRetries?: number;
filename?: string;
dirname?: string;
options?: {
flags?: string;
highWaterMark?: number;
}
stream?: NodeJS.WritableStream;
}
export interface HttpTransportOptions extends TransportOptions {
ssl?: boolean;
host?: string;
port?: number;
auth?: {
username: string;
password: string;
};
path?: string;
}
export interface MemoryTransportOptions extends TransportOptions {
json?: boolean;
colorize?: boolean;
prettyPrint?: boolean;
timestamp?: (Function|boolean);
showLevel?: boolean;
label?: string;
depth?: number;
}
export interface WebhookTransportOptions extends TransportOptions {
host?: string;
port?: number;
method?: string;
path?: string;
auth?: {
username?: string;
password?: string;
};
ssl?: {
key?: any;
cert?: any;
ca: any;
};
}
export interface WinstonMoudleTransportOptions extends TransportOptions {
[optionName: string]: any;
}