Christopher Hoskin 6 ani în urmă
părinte
comite
6b8dd86a26

+ 5 - 0
libraries/logger/logging-manager.js

@@ -64,12 +64,17 @@ const Logger = (module.exports = {
     }
     const uri = `http://metadata.google.internal/computeMetadata/v1/project/attributes/${this.loggerName}-setLogLevelEndTime`
     fetch.fetch(uri,options).then(res => res.text()).then(body => {
+      console.log("About to parse Int", body)
       if (parseInt(body) > Date.now()) {
+        console.log("About to set logger level to trace")
+        console.log(this.logger)
         this.logger.level('trace')
       } else {
+        console.log("About to set logger level to default")
         this.logger.level(this.defaultLevel)
       }
     }).catch(err => {
+      console.log("ERROR: About to set logger level to default")
       this.logger.level(this.defaultLevel)
       return
     })

+ 8 - 3
libraries/logger/test/unit/loggingManagerTests.js

@@ -30,7 +30,9 @@ describe('LoggingManager', function () {
       once: sinon.stub().yields()
     }
     this.fetchResponse = {
-      text: sinon.stub().resolves('')
+      text: sinon.stub().resolves(''),
+      status: 200,
+      ok: true
     }
     this.Bunyan = {
       createLogger: sinon.stub().returns(this.bunyanLogger),
@@ -439,11 +441,14 @@ describe('LoggingManager', function () {
             describe('when level is already set', function() {
               beforeEach(function() {
                 this.bunyanLogger.level.returns(10)
-                this.Request.yields(null, { statusCode: 200 }, this.start + 1000)
+                //this.Request.yields(null, { statusCode: 200 }, this.start + 1000)
+                console.log("In test ", this.start + 1000)
+                this.fetchResponse.text = sinon.stub().resolves(this.start + 1000)
+                this.Fetch.fetch = sinon.stub().resolves(this.fetchResponse)
                 this.logger.checkLogLevel()
               })
       
-              it('should set trace level', function() {
+              it.only('should set trace level', function() {
                 this.bunyanLogger.level.should.have.been.calledOnce.and.calledWith(
                   'trace'
                 )