mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 21:10:23 +00:00
Merge pull request #28023 from felix-hoc/winston-syslog-v2
Update types for winston-syslog to v2.0
This commit is contained in:
Vendored
+28
-21
@@ -1,25 +1,32 @@
|
||||
// Type definitions for winston-syslog 1.0
|
||||
// Project: https://github.com/indexzero/winston-syslog#readme
|
||||
// Definitions by: Chris Barth <https://github.com/cjbarth>
|
||||
// Type definitions for winston-syslog 2.0
|
||||
// Project: https://github.com/winstonjs/winston-syslog
|
||||
// Definitions by: Chris Barth <https://github.com/cjbarth>, Felix Hochgruber <https://github.com/felix-hoc>
|
||||
// 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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@types/winston": "^2.3.9"
|
||||
"winston": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
// 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
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@types/winston": "2.3.9"
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -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),
|
||||
]
|
||||
});
|
||||
@@ -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
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user