Skip to content

Commit 34e193c

Browse files
committed
feat(LogEcs): static methods wrapConsole, wrapDebug on LogEcs
1 parent a46d4f5 commit 34e193c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/ecs/LogEcs.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Log, stringify } from '../node.js'
22
import { ecsSerializers } from './serializers.js'
3+
import { wrapConsole } from '../wrapConsole.js'
4+
import { wrapDebug } from '../wrapDebug.js'
35

46
/**
57
* @typedef {import('../serializers/index.js').Serializer} Serializer
@@ -33,6 +35,23 @@ export class LogEcs extends Log {
3335
this.toJson = this._toJson
3436
}
3537

38+
/**
39+
* @param {string} [name]
40+
* @param {LogOptionsEcs & LogOptionWrapConsole} [opts]
41+
* @returns {() => void} unwrap functions
42+
*/
43+
static wrapConsole(name = 'console', opts) {
44+
const log = new LogEcs(name, opts)
45+
return wrapConsole(log, opts)
46+
}
47+
48+
/**
49+
* @returns {() => void} unwrap functions
50+
*/
51+
static wrapDebug() {
52+
return wrapDebug(LogEcs)
53+
}
54+
3655
/* c8 ignore next 18 */
3756
_applySerializers(obj) {
3857
const ecsObj = {}

types/ecs/LogEcs.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
* (response) keys in objects
1414
*/
1515
export class LogEcs extends Log {
16+
/**
17+
* @param {string} [name]
18+
* @param {LogOptionsEcs & LogOptionWrapConsole} [opts]
19+
* @returns {() => void} unwrap functions
20+
*/
21+
static wrapConsole(name?: string, opts?: LogOptionsEcs & LogOptionWrapConsole): () => void;
1622
/**
1723
* @param {string} name logger namespace
1824
* @param {LogOptionsEcs} [opts]

0 commit comments

Comments
 (0)