Skip to content

Commit f50dcbe

Browse files
committed
fix(node,ProcLog): change EVENT_NAME to EVENT_PROC_LOG
1 parent 40c39e6 commit f50dcbe

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/ProcLog.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { inspectOpts, inspectNamespaces, INFO } from './utils.js'
1111
* @property {string} [namespaces] namespaces for logging
1212
*/
1313

14-
export const EVENT_NAME = 'log-level'
14+
export const EVENT_PROC_LOG = 'log-level'
1515

1616
const defaultOptions = {
1717
level: INFO,
@@ -71,7 +71,7 @@ export class ProcLog extends LogBase {
7171

7272
_log(level, fmt, args) {
7373
// @ts-expect-error
74-
process.emit(EVENT_NAME, level, this.name, fmt, args)
74+
process.emit(EVENT_PROC_LOG, level, this.name, fmt, args)
7575
}
7676
}
7777

@@ -86,9 +86,9 @@ export function initProcLog(options) {
8686
logger[namespace] || (logger[namespace] = new LogCls(namespace, options))
8787

8888
// prevent multiple log-lines from adding more than one listener
89-
process.removeAllListeners(EVENT_NAME)
89+
process.removeAllListeners(EVENT_PROC_LOG)
9090
// listen on event
91-
process.on(EVENT_NAME, (level, namespace, fmt, args) => {
91+
process.on(EVENT_PROC_LOG, (level, namespace, fmt, args) => {
9292
const log = getLogger(namespace)
9393
log[level.toLowerCase()]?.(fmt, ...args)
9494
})

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { LogEcs } from './ecs/LogEcs.js'
1313
import { logger } from './logger.js'
1414
import { browserLogs } from './browserLogs.js'
1515
import { httpLogs } from './httpLogs.js'
16-
import { ProcLog, initProcLog, EVENT_NAME } from './ProcLog.js'
16+
import { ProcLog, initProcLog, EVENT_PROC_LOG } from './ProcLog.js'
1717

1818
export default Log
1919

@@ -23,7 +23,7 @@ export {
2323
logger,
2424
ProcLog,
2525
initProcLog,
26-
EVENT_NAME,
26+
EVENT_PROC_LOG,
2727
browserLogs,
2828
httpLogs
2929
}

test/ProcLog.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from 'node:assert'
22
import { LogEcs } from '../src/index.js'
3-
import { ProcLog, initProcLog, EVENT_NAME } from '../src/ProcLog.js'
3+
import { ProcLog, initProcLog, EVENT_PROC_LOG } from '../src/ProcLog.js'
44

55
describe('ProcLog', function () {
66
beforeEach(function () {
@@ -98,7 +98,7 @@ const myInitProcLog = () => {
9898
const reset = () => {
9999
lines = []
100100
}
101-
process.on(EVENT_NAME, (...args) => {
101+
process.on(EVENT_PROC_LOG, (...args) => {
102102
lines.push(...args)
103103
})
104104
return { lines, reset }

types/ProcLog.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function initProcLog(options?: LogOptionsWithCustomLog): void;
1111
* @property {Level} [level] log level
1212
* @property {string} [namespaces] namespaces for logging
1313
*/
14-
export const EVENT_NAME: "log-level";
14+
export const EVENT_PROC_LOG: "log-level";
1515
/**
1616
* Decouple logging via process event 'log'. This allows to use a different
1717
* logger framework than 'debug-level'. In such cases you'd need to adapt your

types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { LogEcs } from './ecs/LogEcs.js';
1515
import { logger } from './logger.js';
1616
import { ProcLog } from './ProcLog.js';
1717
import { initProcLog } from './ProcLog.js';
18-
import { EVENT_NAME } from './ProcLog.js';
18+
import { EVENT_PROC_LOG } from './ProcLog.js';
1919
import { browserLogs } from './browserLogs.js';
2020
import { httpLogs } from './httpLogs.js';
21-
export { Log, LogEcs, logger, ProcLog, initProcLog, EVENT_NAME, browserLogs, httpLogs };
21+
export { Log, LogEcs, logger, ProcLog, initProcLog, EVENT_PROC_LOG, browserLogs, httpLogs };

0 commit comments

Comments
 (0)