diff --git a/types/winston-syslog/index.d.ts b/types/winston-syslog/index.d.ts index 816274ded8..b0409ad4c4 100644 --- a/types/winston-syslog/index.d.ts +++ b/types/winston-syslog/index.d.ts @@ -1,25 +1,32 @@ -// Type definitions for winston-syslog 1.0 -// Project: https://github.com/indexzero/winston-syslog#readme -// Definitions by: Chris Barth +// Type definitions for winston-syslog 2.0 +// Project: https://github.com/winstonjs/winston-syslog +// Definitions by: Chris Barth , Felix Hochgruber // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as winston from "winston"; -export interface SyslogTransportOptions extends winston.GenericTextTransportOptions { - host?: string; - port?: number; - path?: string; - protocol?: string; - pid?: number; - facility?: string; - localhost?: string; - type?: string; - app_name?: string; - eol?: string; +import * as Transport from 'winston-transport'; +import * as dgram from 'dgram'; +import * as net from 'net'; + +export interface SyslogTransportOptions extends Transport.TransportStreamOptions { + host?: string; + port?: number; + path?: string; + protocol?: string; + pid?: number; + facility?: string; + localhost?: string; + type?: string; + app_name?: string; + eol?: string; } -export class Syslog extends winston.Transport implements winston.TransportInstance { -} -declare module "winston" { - interface Transports { - Syslog: Syslog; - } + +export interface SyslogTransportInstance extends Transport { + producer: any; + socket: dgram.Socket | net.Socket; + + connect(callback: (err: (true | null)) => any): void; + + new(options?: SyslogTransportOptions): SyslogTransportInstance; } + +export const Syslog: SyslogTransportInstance; diff --git a/types/winston-syslog/package.json b/types/winston-syslog/package.json index 33e1a4f018..0aa4cf368f 100644 --- a/types/winston-syslog/package.json +++ b/types/winston-syslog/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "@types/winston": "^2.3.9" + "winston": "^3.0.0" } } diff --git a/types/winston-syslog/tsconfig.json b/types/winston-syslog/tsconfig.json index e11a89c680..2c0a6050a4 100644 --- a/types/winston-syslog/tsconfig.json +++ b/types/winston-syslog/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -21,4 +21,4 @@ "index.d.ts", "winston-syslog-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/winston-syslog/tslint.json b/types/winston-syslog/tslint.json index f93cf8562a..bf5a9b916f 100644 --- a/types/winston-syslog/tslint.json +++ b/types/winston-syslog/tslint.json @@ -1,3 +1,8 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + // This allows to be in line with winston transport types. + // See https://github.com/winstonjs/winston-mongodb/blob/master/lib/winston-mongodb.d.ts and https://github.com/winstonjs/winston-daily-rotate-file/blob/master/index.d.ts + "no-misused-new": false + } } diff --git a/types/winston-syslog/v1/index.d.ts b/types/winston-syslog/v1/index.d.ts new file mode 100644 index 0000000000..b2d5ecfb90 --- /dev/null +++ b/types/winston-syslog/v1/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for winston-syslog 1.0 +// Project: https://github.com/indexzero/winston-syslog#readme +// Definitions by: Chris Barth +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.9 + +import * as winston from "winston"; +export interface SyslogTransportOptions extends winston.GenericTextTransportOptions { + host?: string; + port?: number; + path?: string; + protocol?: string; + pid?: number; + facility?: string; + localhost?: string; + type?: string; + app_name?: string; + eol?: string; +} +export class Syslog extends winston.Transport implements winston.TransportInstance { +} +declare module "winston" { + interface Transports { + Syslog: Syslog; + } +} diff --git a/types/winston-syslog/v1/package.json b/types/winston-syslog/v1/package.json new file mode 100644 index 0000000000..a39b614c7e --- /dev/null +++ b/types/winston-syslog/v1/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "@types/winston": "2.3.9" + } +} diff --git a/types/winston-syslog/v1/tsconfig.json b/types/winston-syslog/v1/tsconfig.json new file mode 100644 index 0000000000..610ded1b9b --- /dev/null +++ b/types/winston-syslog/v1/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "winston-syslog": [ + "winston-syslog/v1" + ], + "winston-syslog/*": [ + "winston-syslog/v1/*" + ] + }, + "noEmit": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "winston-syslog-tests.ts" + ] +} diff --git a/types/winston-syslog/v1/tslint.json b/types/winston-syslog/v1/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/winston-syslog/v1/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/winston-syslog/v1/winston-syslog-tests.ts b/types/winston-syslog/v1/winston-syslog-tests.ts new file mode 100644 index 0000000000..a08b80b045 --- /dev/null +++ b/types/winston-syslog/v1/winston-syslog-tests.ts @@ -0,0 +1,35 @@ +import winston = require('winston'); +import { SyslogTransportOptions } from 'winston-syslog'; + +const str = ""; +const bool = true; +const num = 1; +const obj: any = {}; + +const syslogOptions: SyslogTransportOptions = { + host: str, + port: num, + path: str, + protocol: str, + pid: num, + facility: str, + localhost: str, + type: str, + app_name: str, + eol: str, + json: bool, + colorize: bool, + colors: str, + prettyPrint: bool, + showLevel: bool, + label: str, + depth: num, +}; + +winston.add(winston.transports.Syslog, syslogOptions); + +const logger: winston.LoggerInstance = new (winston.Logger)({ + transports: [ + new (winston.transports.Syslog)(syslogOptions), + ] +}); diff --git a/types/winston-syslog/winston-syslog-tests.ts b/types/winston-syslog/winston-syslog-tests.ts index a08b80b045..66a4a71e17 100644 --- a/types/winston-syslog/winston-syslog-tests.ts +++ b/types/winston-syslog/winston-syslog-tests.ts @@ -1,5 +1,5 @@ import winston = require('winston'); -import { SyslogTransportOptions } from 'winston-syslog'; +import { Syslog, SyslogTransportOptions } from 'winston-syslog'; const str = ""; const bool = true; @@ -16,20 +16,15 @@ const syslogOptions: SyslogTransportOptions = { localhost: str, type: str, app_name: str, - eol: str, - json: bool, - colorize: bool, - colors: str, - prettyPrint: bool, - showLevel: bool, - label: str, - depth: num, + eol: str }; -winston.add(winston.transports.Syslog, syslogOptions); +const syslogTransport = new Syslog(syslogOptions); -const logger: winston.LoggerInstance = new (winston.Logger)({ +winston.add(syslogTransport); + +const logger: winston.Logger = winston.createLogger({ transports: [ - new (winston.transports.Syslog)(syslogOptions), + syslogTransport ] });