-
Notifications
You must be signed in to change notification settings - Fork 243
Open
Description
Describe the problem
Currently, setLogExtension and console output share the same log level configuration. When you set a log level using setLogLevel(), both console output and log extensions use the identical filtering criteria.
This creates a limitation where you cannot send detailed debug logs to external services while keeping console output clean (info level)
Describe the proposed solution
I'm unsure about the optimal implementation approach. One idea I have that doesn't trigger breaking change is to add a parameter (customLevel) to setLogExtension and modify the needLog conditional with an OR condition. I'd appreciate your thoughts on whether this approach would be appropriate.
// logger.ts
export function setLogExtension(extension: LogExtension, logger?: StructuredLogger, customLevel?: LogLevel) {
const loggers = logger ? [logger] : livekitLoggers;
loggers.forEach((logR) => {
const originalFactory = logR.methodFactory;
logR.methodFactory = (methodName, configLevel, loggerName) => {
const rawMethod = originalFactory(methodName, configLevel, loggerName);
const logLevel = LogLevel[methodName as LogLevelString];
const needConsoleLog = logLevel >= configLevel && logLevel < LogLevel.silent;
const needExtensionLog = customLevel !== undefined
? (logLevel >= customLevel && logLevel < LogLevel.silent) // extensionLog depending on customLevel
: needConsoleLog;
return (msg, context?: [msg: string, context: object]) => {
if (needConsoleLog) {
if (context) rawMethod(msg, context);
else rawMethod(msg);
}
if (needExtensionLog) {
extension(logLevel, msg, context);
}
};
};
logR.setLevel(logR.getLevel());
});
}Alternatives considered
No response
Importance
nice to have
Additional Information
No response
Metadata
Metadata
Assignees
Labels
No labels