Skip to content

Commit 115f86d

Browse files
authored
🤖 Merge PR DefinitelyTyped#72226 [splunk-logging] add Severity levels enum to types by @dhensby
1 parent 5c69929 commit 115f86d

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

‎types/splunk-logging/index.d.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { CoreOptions as RequestOptions } from "request";
22

3+
export enum Severity {
4+
DEBUG = "debug",
5+
INFO = "info",
6+
WARN = "warn",
7+
ERROR = "error",
8+
}
9+
310
export interface Config {
411
token: string;
512
name?: string | undefined;
@@ -9,7 +16,7 @@ export interface Config {
916
protocol?: "http" | "https" | undefined;
1017
port?: number | undefined;
1118
url?: string | undefined;
12-
level?: string | undefined;
19+
level?: Severity | string | undefined;
1320
batchInterval?: number | undefined;
1421
maxBatchSize?: number | undefined;
1522
maxBatchCount?: number | undefined;
@@ -25,7 +32,7 @@ export interface SendContextMetadata {
2532

2633
export interface SendContext {
2734
message: any;
28-
severity?: string | undefined;
35+
severity?: Severity | string | undefined;
2936
metadata?: SendContextMetadata | undefined;
3037
}
3138

@@ -37,6 +44,7 @@ export class Logger {
3744
eventFormatter: EventFormatter;
3845
requestOptions: RequestOptions;
3946
readonly serializedContextQueue: any[];
47+
readonly levels: typeof Severity;
4048

4149
constructor(config: Config);
4250

‎types/splunk-logging/splunk-logging-tests.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Logger } from "splunk-logging";
1+
import { Logger, Severity } from "splunk-logging";
22

33
const config = {
44
token: "your-token-here",
@@ -28,7 +28,7 @@ logger.send(payload, (err, resp, body) => {
2828

2929
const fullPayload = {
3030
message: [1, 2, 3],
31-
severity: "error",
31+
severity: logger.levels.ERROR,
3232
metadata: {
3333
host: "myHost",
3434
index: "splunkIndex",
@@ -48,7 +48,7 @@ const fullConfig = {
4848
path: "splunkPath",
4949
procotol: "https",
5050
port: 2,
51-
level: "info",
51+
level: Severity.INFO,
5252
batchInterval: 3,
5353
maxBatchSize: 4,
5454
maxBatchCount: 5,

0 commit comments

Comments
 (0)