Skip to content

Commit beff2f4

Browse files
author
Steven Weingärtner
committed
feat(logger): add basic typescript types for module
1 parent 6512f86 commit beff2f4

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

packages/logger/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "2.2.3",
44
"description": "Logger for node projects",
55
"main": "dist/index.js",
6+
"types": "src/types.d.ts",
67
"scripts": {
78
"build": "babel ./src --out-dir ./dist --ignore test.js,setupTests.js,__mocks__/*",
89
"build:watch": "npm run build -- --watch --source-maps",

packages/logger/src/types.d.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
declare module '@tspm/node-logger' {
2+
type LogMethod = (message: unknown, meta?: Record<string, unknown>) => void;
3+
4+
abstract class LogMethods {
5+
emergency: LogMethod;
6+
alert: LogMethod;
7+
critical: LogMethod;
8+
error: LogMethod;
9+
warning: LogMethod;
10+
notice: LogMethod;
11+
info: LogMethod;
12+
debug: LogMethod;
13+
}
14+
15+
type LogLevel = keyof LogMethods;
16+
17+
interface Config {
18+
channel?: string;
19+
levels?: LogLevel[];
20+
maxLevel?: LogLevel;
21+
outputs?: Record<string, string>;
22+
timerLevel?: string;
23+
formatter?: string;
24+
plugins?: string[];
25+
context?: {
26+
user?: string | Record<string, unknown>;
27+
[key: string]: unknown;
28+
};
29+
}
30+
31+
export class Logger extends LogMethods {
32+
constructor(config?: Config);
33+
start(message: unknown): void;
34+
stop(message: unknown, meta?: Record<string, unknown>): void;
35+
}
36+
}

0 commit comments

Comments
 (0)