mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add types for syslog-client (#40354)
This commit is contained in:
parent
b907c0ca82
commit
949922e095
76
types/syslog-client/index.d.ts
vendored
Normal file
76
types/syslog-client/index.d.ts
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
// Type definitions for node-syslog-client 1.1
|
||||
// Project: https://github.com/paulgrove/node-syslog-client
|
||||
// Definitions by: Romain CONNESSON <https://github.com/helorem>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
export enum Transport {
|
||||
Tcp = 1,
|
||||
Udp = 2
|
||||
}
|
||||
|
||||
export enum Facility {
|
||||
Kernel = 0,
|
||||
User = 1,
|
||||
System = 3,
|
||||
Audit = 13,
|
||||
Alert = 14,
|
||||
Local0 = 16,
|
||||
Local1 = 17,
|
||||
Local2 = 18,
|
||||
Local3 = 19,
|
||||
Local4 = 20,
|
||||
Local5 = 21,
|
||||
Local6 = 22,
|
||||
Local7 = 23
|
||||
}
|
||||
|
||||
export enum Severity {
|
||||
Emergency = 0,
|
||||
Alert = 1,
|
||||
Critical = 2,
|
||||
Error = 3,
|
||||
Warning = 4,
|
||||
Notice = 5,
|
||||
Informational = 6,
|
||||
Debug = 7
|
||||
}
|
||||
|
||||
export interface ClientOptions {
|
||||
syslogHostname?: string;
|
||||
port?: number;
|
||||
tcpTimeout?: number;
|
||||
facility?: Facility;
|
||||
severity?: Severity;
|
||||
rfc3164?: boolean;
|
||||
appName?: string;
|
||||
dateFormatter?: (() => string);
|
||||
transport?: Transport;
|
||||
timestamp?: Date;
|
||||
msgid?: string;
|
||||
}
|
||||
|
||||
export interface MessageOptions {
|
||||
syslogHostname?: string;
|
||||
facility?: Facility;
|
||||
severity?: Severity;
|
||||
rfc3164?: boolean;
|
||||
appName?: string;
|
||||
timestamp?: Date;
|
||||
msgid?: string;
|
||||
}
|
||||
|
||||
export class Client extends EventEmitter {
|
||||
constructor(target?: string, options?: ClientOptions);
|
||||
buildFormattedMessage(message: string, options: MessageOptions): Buffer;
|
||||
close(): Client;
|
||||
log(message: string, options?: MessageOptions, cb?: ((error: Error | null) => void)): Client;
|
||||
getTransport(cb: ((error: Error | null, transport: Transport) => void)): void;
|
||||
onClose(): Client;
|
||||
onError(error: Error): Client;
|
||||
}
|
||||
|
||||
export function createClient(target: string, options: ClientOptions): Client;
|
||||
11
types/syslog-client/syslog-client-tests.ts
Normal file
11
types/syslog-client/syslog-client-tests.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import * as syslog from 'syslog-client';
|
||||
|
||||
const syslog_client = syslog.createClient("127.0.0.1", {
|
||||
port: 514,
|
||||
transport: syslog.Transport.Tcp,
|
||||
rfc3164: false,
|
||||
appName: "testapp"
|
||||
});
|
||||
syslog_client.log("Test message", { severity: syslog.Severity.Warning }, (error: Error | null) => {
|
||||
syslog_client.close();
|
||||
});
|
||||
23
types/syslog-client/tsconfig.json
Normal file
23
types/syslog-client/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"syslog-client-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/syslog-client/tslint.json
Normal file
1
types/syslog-client/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user