Merge pull request #24135 from cjbarth/winston-syslog

Add typings for winston-syslog
This commit is contained in:
Armando Aguirre
2018-03-08 10:49:14 -08:00
committed by GitHub
4 changed files with 87 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
// Type definitions for winston-syslog 1.0
// Project: https://github.com/indexzero/winston-syslog#readme
// Definitions by: Chris Barth <https://github.com/cjbarth>
// 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;
}
export class Syslog extends winston.Transport implements winston.TransportInstance {
}
declare module "winston" {
interface Transports {
Syslog: Syslog;
}
}
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"winston-syslog-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
@@ -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),
]
});