Skip to content

Can't set global log() function overriding namespaces ones #873

Open
@piranna

Description

@piranna

On the example located at https://github.com/debug-js/debug#output-streams, it shows that's possible to set custom log() functions for each namespace, but also that setting it directly on the debug module takes precedence and will be used instead of the namespace ones. This is specially useful in my use case, since I want to capture Mediasoup debuging Logger and redirect it to Moleculer logger. Problem is that according to

debug/src/common.js

Lines 112 to 113 in c0805cc

const logFn = self.log || createDebug.log;
logFn.apply(self, args);
namespaces log() function has absolute priority, so it's not possible to do it globally, and it's not possible to directly bind on top of Mediasoup Loggers since they are private, so I'm in an end road.

Since the linken example at https://github.com/debug-js/debug/blob/master/examples/node/stdout.js doesn't exists too, I'm not sure if the documentation is outdated or wrong, or if setting debug.log() should effectively override per-namespace log() function and this is in fact a bug. Besides fixing this one way or another, how can I solve my problem of redirect Mediasoup log messages to Moleculer?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue identifies a malfunctionchange-patchThis proposes or provides a change that requires a patch releaseneeds-documentationThis issue or change requires additional documentationpr-welcomeThis issue has an approved change; a pull request would be appreciated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions