Christopher Hoskin 6 лет назад
Родитель
Сommit
d695a40a61

+ 4 - 4
libraries/logger/logging-manager.js

@@ -22,9 +22,9 @@ const errSerializer = function(err) {
 const Logger = (module.exports = {
   initialize(name) {
     this.isProduction =
-      (process.env['NODE_ENV'] || '').toLowerCase() === 'production'
+      (process.env.NODE_ENV || '').toLowerCase() === 'production'
     this.defaultLevel =
-      process.env['LOG_LEVEL'] || (this.isProduction ? 'warn' : 'debug')
+      process.env.LOG_LEVEL || (this.isProduction ? 'warn' : 'debug')
     this.loggerName = name
     this.logger = bunyan.createLogger({
       name,
@@ -210,7 +210,7 @@ const Logger = (module.exports = {
   },
 
   _setupRingBuffer() {
-    this.ringBufferSize = parseInt(process.env['LOG_RING_BUFFER_SIZE']) || 0
+    this.ringBufferSize = parseInt(process.env.LOG_RING_BUFFER_SIZE) || 0
     if (this.ringBufferSize > 0) {
       this.ringBuffer = new bunyan.RingBuffer({ limit: this.ringBufferSize })
       this.logger.addStream({
@@ -224,7 +224,7 @@ const Logger = (module.exports = {
   },
 
   _setupStackdriver() {
-    const stackdriverEnabled = yn(process.env['STACKDRIVER_LOGGING'])
+    const stackdriverEnabled = yn(process.env.STACKDRIVER_LOGGING)
     if (!stackdriverEnabled) {
       return
     }

+ 6 - 6
libraries/logger/test/unit/loggingManagerTests.js

@@ -376,14 +376,14 @@ describe('LoggingManager', function() {
 
     describe('when ring buffer size is positive', function() {
       beforeEach(function() {
-        process.env['LOG_RING_BUFFER_SIZE'] = '20'
+        process.env.LOG_RING_BUFFER_SIZE = '20'
         this.logger = this.LoggingManager.initialize(this.loggerName)
         this.logger.ringBuffer.records = this.logBufferMock
         this.logger.error({}, 'error')
       })
 
       afterEach(function() {
-        process.env['LOG_RING_BUFFER_SIZE'] = undefined
+        process.env.LOG_RING_BUFFER_SIZE = undefined
       })
 
       it('should include buffered logs in error log and filter out error logs in buffer', function() {
@@ -396,13 +396,13 @@ describe('LoggingManager', function() {
 
     describe('when ring buffer size is zero', function() {
       beforeEach(function() {
-        process.env['LOG_RING_BUFFER_SIZE'] = '0'
+        process.env.LOG_RING_BUFFER_SIZE = '0'
         this.logger = this.LoggingManager.initialize(this.loggerName)
         this.logger.error({}, 'error')
       })
 
       afterEach(function() {
-        process.env['LOG_RING_BUFFER_SIZE'] = undefined
+        process.env.LOG_RING_BUFFER_SIZE = undefined
       })
 
       it('should not include buffered logs in error log', function() {
@@ -414,7 +414,7 @@ describe('LoggingManager', function() {
   describe('stackdriver logging', function() {
     describe('when STACKDRIVER_LOGGING is unset', function() {
       beforeEach(function() {
-        process.env['STACKDRIVER_LOGGING'] = undefined
+        process.env.STACKDRIVER_LOGGING = undefined
         this.LoggingManager.initialize(this.loggerName)
       })
 
@@ -427,7 +427,7 @@ describe('LoggingManager', function() {
 
     describe('when STACKDRIVER_LOGGING is true', function() {
       beforeEach(function() {
-        process.env['STACKDRIVER_LOGGING'] = 'true'
+        process.env.STACKDRIVER_LOGGING = 'true'
         this.LoggingManager.initialize(this.loggerName)
       })