mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-25 12:35:01 +01:00
17 lines
698 B
JavaScript
17 lines
698 B
JavaScript
|
// these are helper functions if you can't assume you always have a log item (e.g. some code paths call with one set, others don't)
|
||
|
// if you know you always have a log item, better to use the methods on the log item than these utility functions.
|
||
|
|
||
|
import {Instance as NullLoggerInstance} from "./NullLogger.js";
|
||
|
|
||
|
export function wrapOrRunNullLogger(logItem, labelOrValues, callback, logLevel = null, filterCreator = null) {
|
||
|
if (logItem) {
|
||
|
return logItem.wrap(logItem, labelOrValues, callback, logLevel, filterCreator);
|
||
|
} else {
|
||
|
return NullLoggerInstance.run(null, callback);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export function ensureLogItem(logItem) {
|
||
|
return logItem || NullLoggerInstance.item;
|
||
|
}
|