a CallbackLogger does not pass enough information to callback function

This issue has been tracked since 2023-02-01.

Search Terms

logger callbacklogger custom addcontext


When using a custom logger (a CallbackLogger), the callback is called with [message:string, level: LogLevel] and that's it. CallbackLogger does not override addContext; its prototype contains Logger.addContext() which throws away the extra information. This extra information is most certainly useful to someone using a custom logging function.

Suggested Solution

CallbackLogger.log() should look like this (changes highlighted):

 * Print a log message.
 * @param message  The message itself.
 * @param level  The urgency of the log message.
override log(message: string, level: LogLevel, ...args: [ts.Node?] | [number, MinimalSourceFile]) { // ๐Ÿ‘ˆ
    super.log(message, level);
    this.callback(message, level, ...args); // ๐Ÿ‘ˆ
Gerrit0 wrote this answer on 2023-02-02

Seems reasonable, I think you may be the first person to have used the callback logger.

boneskull wrote this answer on 2023-02-02

Hmm, what I suggested was insufficient. It looks like the addContext method is called, and the string result is then passed along to the log and callback methods. So something more fundamental would need to change in the public API.

The use-case here is programmatic usage of TypeDoc (not plugin implementation).

I'll see if I can find another workaround.

More Details About Repo
Owner Name TypeStrong
Repo Name typedoc
Full Name TypeStrong/typedoc
Language TypeScript
Created Date 2014-05-24
Updated Date 2023-03-19
Star Count 6487
Watcher Count 68
Fork Count 639
Issue Count 48


Issue Title Created Date Updated Date