11import { LogBase } from './LogBase.js'
22import { Log } from './node.js'
33import { inspectOpts , inspectNamespaces , INFO } from './utils.js'
4+ import { wrapConsole } from './wrapConsole.js'
5+ import { wrapDebug } from './wrapDebug.js'
46
57/** @typedef {import('./utils.js').Level } Level */
68/** @typedef {import('./node.js').LogOptions } LogOptions */
9+ /** @typedef {import('./node.js').LogOptionWrapConsole } LogOptionWrapConsole */
710/** @typedef {LogOptions & {Log: typeof Log} } LogOptionsWithCustomLog */
11+
812/**
913 * @typedef {object } ProcLogOptions
1014 * @property {Level } [level] log level
@@ -13,7 +17,7 @@ import { inspectOpts, inspectNamespaces, INFO } from './utils.js'
1317
1418export const EVENT_PROC_LOG = 'log-level'
1519
16- const defaultOptions = {
20+ const options = {
1721 level : INFO ,
1822 namespaces : undefined
1923}
@@ -57,7 +61,7 @@ export class ProcLog extends LogBase {
5761 */
5862 constructor ( name , opts ) {
5963 const _opts = {
60- ...defaultOptions ,
64+ ...options ,
6165 ...inspectOpts ( process . env ) ,
6266 ...inspectNamespaces ( process . env ) ,
6367 ...opts ,
@@ -73,6 +77,24 @@ export class ProcLog extends LogBase {
7377 // @ts -expect-error
7478 process . emit ( EVENT_PROC_LOG , level , this . name , fmt , args )
7579 }
80+
81+ /**
82+ * @param {string } [name]
83+ * @param {ProcLogOptions & LogOptionWrapConsole } [opts]
84+ * @returns {() => void } unwrap functions
85+ */
86+ static wrapConsole ( name = 'console' , opts ) {
87+ const log = new ProcLog ( name , opts )
88+ return wrapConsole ( log , opts )
89+ }
90+
91+ /**
92+ * @param {ProcLogOptions } [opts]
93+ * @returns {() => void } unwrap functions
94+ */
95+ static wrapDebug ( opts ) {
96+ return wrapDebug ( ProcLog , opts )
97+ }
7698}
7799
78100/**
0 commit comments