This commit is contained in:
Christopher Hoskin 2020-07-30 14:45:49 +01:00
parent 74e2a5eaa1
commit 6917847b10

View file

@ -22,6 +22,7 @@ const errSerializer = function (err) {
const Logger = (module.exports = {
initialize(name) {
console.log("IN INIT")
this.logLevelSource = (process.env.LOG_LEVEL_SOURCE || 'file').toLowerCase()
this.isProduction =
(process.env.NODE_ENV || '').toLowerCase() === 'production'
@ -39,6 +40,7 @@ const Logger = (module.exports = {
})
this._setupRingBuffer()
this._setupStackdriver()
console.log(this.logger)
this._setupLogLevelChecker()
return this
},
@ -52,6 +54,7 @@ const Logger = (module.exports = {
this.logger.level(this.defaultLevel)
}
} catch (err) {
console.log(err)
this.logger.level(this.defaultLevel)
}
},
@ -253,6 +256,8 @@ async getTracingEndTimeMetadata() {
},
_setupLogLevelChecker() {
console.log("In _setupLogLevelChecker")
console.log(this.logger)
if (this.isProduction) {
// clear interval if already set
if (this.checkInterval) {
@ -269,7 +274,9 @@ async getTracingEndTimeMetadata() {
return
}
// check for log level override on startup
this.checkLogLevel()
this.checkLogLevel().catch((error) => {
console.log(error)
})
// re-check log level every minute
this.checkInterval = setInterval(this.checkLogLevel.bind(this), 1000 * 60)
}