Skip to content

Commit

Permalink
[pinpoint-apm#117] Logger integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
feelform committed Oct 19, 2022
1 parent 710d830 commit 1a3969a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,15 @@ function hasDockerCGroup() {
}
}

function needsLoadConfig() {
return typeof agentConfig !== 'undefined'
}

module.exports = {
getConfig,
clear,
readConfigJson,
readRootConfigFile,
getMainModulePath
getMainModulePath,
needsLoadConfig
}
5 changes: 4 additions & 1 deletion lib/supports.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'use strict'

const Logger = require('./utils/log/logger2')
const { needsLoadConfig } = require('./config')

const log = new Logger.NoneBuilder({
logs: [],
Expand All @@ -26,6 +27,8 @@ const log = new Logger.NoneBuilder({

module.exports = {
getLog: function () {
return log
if (needsLoadConfig()) {
return log
}
}
}
3 changes: 3 additions & 0 deletions test/utils/log/logger.integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
const test = require('tape')
const { getLog } = require('../../../lib/supports')
const Agent = require('../../../lib/agent')
const { clear } = require('../../../lib/config')

test('Logger Adaptor', (t) => {
clear()
const actual = getLog()
new Agent()
t.equal(actual.adaptor.constructor.name, 'LoggerOutputAdaptor', 'log adaptor')

t.end()
})

0 comments on commit 1a3969a

Please sign in to comment.