Skip to content

Commit

Permalink
improve log message for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ocean committed Jul 25, 2024
1 parent f08d7ad commit ce03563
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/test/unit/logging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ describe('Logger instances and transports tests', async () => {
envOverrides = await setupEnvironment(
null,
buildEnvOverrideConfig(
[ENVIRONMENT_VARIABLES.NODE_ENV, ENVIRONMENT_VARIABLES.LOG_DB],
['development', 'false']
[
ENVIRONMENT_VARIABLES.NODE_ENV,
ENVIRONMENT_VARIABLES.LOG_DB,
ENVIRONMENT_VARIABLES.LOG_LEVEL
],
['development', 'false', 'info']
)
)
// because of this
Expand All @@ -43,7 +47,7 @@ describe('Logger instances and transports tests', async () => {

it(`should change LOG_DB to "true" and logger should have DB transport`, async function () {
// when we are logging to DB, things can slow down a bit
this.timeout(DEFAULT_TEST_TIMEOUT * 2)
this.timeout(DEFAULT_TEST_TIMEOUT * 3)
expect(USE_DB_TRANSPORT()).to.be.equal(false)
expect(OCEAN_NODE_LOGGER.hasDBTransport()).to.be.equal(false)
const envAfter = await setupEnvironment(
Expand All @@ -53,11 +57,13 @@ describe('Logger instances and transports tests', async () => {
['true', 'http://172.15.0.6:8108?apiKey=xyz']
)
)
console.log('env after', envAfter)
expect(USE_DB_TRANSPORT()).to.be.equal(true)
// will build the DB transport layer
const config = await getConfiguration(true)
// eslint-disable-next-line no-unused-vars
const DB = await new Database(config.dbConfig)
console.log('after DB')
// Could generate Typesene error if DB is not running, but does not matter for this test
OCEAN_NODE_LOGGER.logMessage('Should build DB transport layer')

Expand Down
5 changes: 3 additions & 2 deletions src/test/utils/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ export const mochaHooks = {
const initialVariable: OverrideEnvConfig = initialConfiguration.get(varName)
if (initialVariable.originalValue !== currentEnvVariable.originalValue) {
// reset it to the original
CONFIG_LOGGER.debug('Restoring environment variable: ' + varName)
process.env[varName] = initialVariable.originalValue
CONFIG_LOGGER.debug(
`(Hook) Restoring environment variable: ${varName} \ncurrent:\n ${process.env[varName]} original:\n ' ${initialVariable.originalValue}`
)
}
})
}
Expand Down

0 comments on commit ce03563

Please sign in to comment.