Skip to content
This repository was archived by the owner on Apr 8, 2024. It is now read-only.

Commit e96b8f3

Browse files
authored
Merge pull request #130 from jwulf/127-log-interface
Add ZBCustomLogger and ZBLogMessage interfaces
2 parents b9f500c + 2e72c45 commit e96b8f3

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/lib/MockStdOut.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export class MockStdOut {
1+
import { ZBCustomLogger } from './interfaces'
2+
export class MockStdOut implements ZBCustomLogger {
23
public messages: string[] = []
34

45
public info(message: string) {

src/lib/interfaces.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ export interface BasicAuthConfig {
77
password: string
88
username: string
99
}
10+
// The JSON-stringified version of this is sent to the ZBCustomLogger
11+
export interface ZBLogMessage {
12+
timestamp: Date
13+
context: string
14+
id: string
15+
level: Loglevel
16+
message: string
17+
time: string
18+
}
1019

1120
export interface KeyedObject {
1221
[key: string]: any
@@ -451,10 +460,21 @@ export interface CamundaCloudConfig {
451460
cacheOnDisk?: boolean
452461
}
453462

463+
export interface ZBCustomLogger {
464+
/**
465+
* Receives a JSON-stringified ZBLogMessage
466+
*/
467+
info: (message: string) => void
468+
/**
469+
* Receives a JSON-stringified ZBLogMessage
470+
*/
471+
error: (message: string) => void
472+
}
473+
454474
export interface ZBClientOptions {
455475
connectionTolerance?: number
456476
loglevel?: Loglevel
457-
stdout?: any
477+
stdout?: ZBCustomLogger
458478
retry?: boolean
459479
maxRetries?: number
460480
maxRetryTimeout?: number

src/zb/ZBClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class ZBClient extends EventEmitter {
4747
private oAuth?: OAuthProvider
4848
private basicAuth?: ZB.BasicAuthConfig
4949
private useTLS: boolean
50-
private stdout: any
50+
private stdout: ZB.ZBCustomLogger
5151
private lastReady?: Date
5252
private lastConnectionError?: Date
5353

0 commit comments

Comments
 (0)