mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00
Logging fixes (#467)
* Log fatal to console if we haven't configured logging * Move token store load up * Fix logging typo * Fix everything logging at debug * changelog * Make private
This commit is contained in:
parent
9d7e6adcd4
commit
944bbe77ff
1
changelog.d/467.bugfix
Normal file
1
changelog.d/467.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fixed issue where log lines would only be outputted when the `logging.level` is `debug`.
|
@ -49,6 +49,11 @@ async function start() {
|
||||
}
|
||||
|
||||
start().catch((ex) => {
|
||||
log.error("BridgeApp encountered an error and has stopped:", ex);
|
||||
if (LogWrapper.configured) {
|
||||
log.error("BridgeApp encountered an error and has stopped:", ex);
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("BridgeApp encountered an error and has stopped", ex);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
|
@ -88,6 +88,7 @@ export class Bridge {
|
||||
|
||||
public async start() {
|
||||
log.info('Starting up');
|
||||
await this.tokenStore.load();
|
||||
await this.storage.connect?.();
|
||||
await this.queue.connect?.();
|
||||
|
||||
@ -140,7 +141,6 @@ export class Bridge {
|
||||
}
|
||||
|
||||
|
||||
await this.tokenStore.load();
|
||||
const connManager = this.connectionManager = new ConnectionManager(this.as,
|
||||
this.config, this.tokenStore, this.commentProcessor, this.messageClient, this.storage, this.github);
|
||||
|
||||
|
@ -29,6 +29,12 @@ interface HookshotLogInfo extends winston.Logform.TransformableInfo {
|
||||
}
|
||||
export default class LogWrapper {
|
||||
|
||||
private static isConfigured: boolean;
|
||||
|
||||
public static get configured() {
|
||||
return this.isConfigured;
|
||||
}
|
||||
|
||||
static formatMsgTypeArray(...data: MsgType[]): string {
|
||||
data = data.flat();
|
||||
return data.map(obj => {
|
||||
@ -144,6 +150,7 @@ export default class LogWrapper {
|
||||
|
||||
LogService.setLevel(LogLevel.fromString(cfg.level));
|
||||
LogService.debug("LogWrapper", "Reconfigured logging");
|
||||
LogWrapper.isConfigured = true;
|
||||
}
|
||||
|
||||
constructor(private module: string) { }
|
||||
@ -154,7 +161,7 @@ export default class LogWrapper {
|
||||
* @param {*[]} messageOrObject The data to log
|
||||
*/
|
||||
public debug(...messageOrObject: MsgType[]) {
|
||||
LogWrapper.winstonLog.debug("debug", { module: this.module, data: messageOrObject });
|
||||
LogWrapper.winstonLog.log("debug", { module: this.module, data: messageOrObject });
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,7 +169,7 @@ export default class LogWrapper {
|
||||
* @param {*[]} messageOrObject The data to log
|
||||
*/
|
||||
public error(...messageOrObject: MsgType[]) {
|
||||
LogWrapper.winstonLog.debug("error", { module: this.module, data: messageOrObject });
|
||||
LogWrapper.winstonLog.log("error", { module: this.module, data: messageOrObject });
|
||||
}
|
||||
|
||||
/**
|
||||
@ -170,7 +177,7 @@ export default class LogWrapper {
|
||||
* @param {*[]} messageOrObject The data to log
|
||||
*/
|
||||
public info(...messageOrObject: MsgType[]) {
|
||||
LogWrapper.winstonLog.debug("info", { module: this.module, data: messageOrObject });
|
||||
LogWrapper.winstonLog.log("info", { module: this.module, data: messageOrObject });
|
||||
}
|
||||
|
||||
/**
|
||||
@ -178,6 +185,6 @@ export default class LogWrapper {
|
||||
* @param {*[]} messageOrObject The data to log
|
||||
*/
|
||||
public warn(...messageOrObject: MsgType[]) {
|
||||
LogWrapper.winstonLog.debug("warn", { module: this.module, data: messageOrObject });
|
||||
LogWrapper.winstonLog.log("warn", { module: this.module, data: messageOrObject });
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user