Skip to content

Commit 6c50363

Browse files
authored
Merge pull request #110 from navono/master
feat: add typescript declaration file
2 parents 7b6ec36 + 4a6d219 commit 6c50363

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

lib/index.d.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Type definitions for fluent-logger-node
2+
// Project: https://github.com/fluent/fluent-logger-node
3+
// Definitions by: navono <https://github.com/navono>
4+
// Definitions: https://github.com/fluent/fluent-logger-node
5+
6+
/// <reference types="node" />
7+
8+
import { Transform } from 'winston-transport';
9+
10+
declare namespace fluentLogger {
11+
interface Options {
12+
eventMode?: string;
13+
host?: string;
14+
port?: number;
15+
path?: string;
16+
timeout?: number;
17+
tls?: any;
18+
tlsOptions?: any;
19+
reconnectInterval?: number;
20+
requireAckResponse?: boolean;
21+
ackResponseTimeout?: number;
22+
milliseconds?: number;
23+
flushInterval?: number;
24+
sendQueueSizeLimit?: number;
25+
security?: Security;
26+
}
27+
28+
interface Security {
29+
clientHostname: string;
30+
sharedKey: string;
31+
username: string;
32+
password: string;
33+
}
34+
35+
type Timestamp = number | Date;
36+
type Callback = (err?: Error) => void;
37+
38+
class FluentSender<T> {
39+
constructor(tagPrefix: string, options: Options);
40+
41+
emit(data: T, callback?: Callback): void;
42+
emit(data: T, timestamp: Timestamp, callback?: Callback): void;
43+
emit(label: string, data: T, callback?: Callback): void;
44+
emit(label: string, data: T, timestamp: Timestamp, callback?: Callback): void;
45+
end(label: string, data: T, callback: Callback): void;
46+
}
47+
48+
class FluentTransport extends Transform {
49+
constructor(opt: Options);
50+
51+
public log(info: string, callback: (err: Error, b: boolean) => void): any;
52+
}
53+
54+
class InnerEventTime {
55+
epoch: number;
56+
nano: string;
57+
58+
constructor(epoch: number, nano: number);
59+
60+
static pack(eventTime: InnerEventTime): Buffer;
61+
static unpack(buffer: Buffer): InnerEventTime;
62+
static now(): InnerEventTime;
63+
static fromDate(date: Date): InnerEventTime;
64+
static fromTimestamp(t: number): InnerEventTime;
65+
}
66+
67+
interface Constructable<T, U> {
68+
new(options: U) : T;
69+
}
70+
71+
let support: {
72+
winstonTransport: () => Constructable<FluentTransport, Options>
73+
};
74+
75+
let EventTime: InnerEventTime;
76+
77+
function configure(tag: string, options: Options): void;
78+
function createFluentSender(tag: string, options: Options): FluentSender;
79+
}
80+
81+
export = fluentLogger;

0 commit comments

Comments
 (0)