Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #136 from Financial-Times/revert-129-set-system-code
Browse files Browse the repository at this point in the history
Revert "CPP-555 expose a setSystemCode, and deprecate SYSTEM_CODE"
  • Loading branch information
apaleslimghost authored Oct 7, 2021
2 parents 86f37b9 + 5b505ed commit 66d07c5
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 33 deletions.
5 changes: 0 additions & 5 deletions src/lib/app-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ class AppLogger extends Logger {
.forEach(logger => this.logger.remove(logger));
}

setSystemCode (systemCode) {
if(this.logger.transports.splunkHEC) {
this.logger.transports.splunkHEC.setSystemCode(systemCode);
}
}
}

export default AppLogger;
26 changes: 1 addition & 25 deletions src/lib/transports/splunkHEC.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,6 @@ const throwIfNotOk = res => {
};

class SplunkHEC extends winston.Transport {
// name that Winston refers to the transport by
get name () {
return 'splunkHEC';
}

setSystemCode (systemCode) {
this._systemCode = systemCode;
}

get systemCode () {
if(this._systemCode) {
return this._systemCode;
} else if(process.env.SYSTEM_CODE) {
// fall back to legacy environment variable with a warning
if(!this.warnedSystemCode) {
console.warn('n-logger Splunk transport received the system code from the SYSTEM_CODE environment variable, which is deprecated. Call logger.setSystemCode instead');
this.warnedSystemCode = true;
}

return process.env.SYSTEM_CODE;
} else {
throw new Error('You must set the systemCode option to a valid Biz Ops system code (call logger.setSystemCode) to use the Splunk transport.');
}
}

log (level, message, meta) {
const httpsAgent = new https.Agent({ keepAlive: true });
Expand All @@ -50,7 +26,7 @@ class SplunkHEC extends winston.Transport {
const data = {
'time': Date.now(),
'host': 'localhost',
'source': `/var/log/apps/heroku/ft-${this.systemCode}.log`,
'source': `/var/log/apps/heroku/ft-${process.env.SYSTEM_CODE}.log`,
'sourcetype': process.env.SPLUNK_SOURCETYPE || '_json',
'index': process.env.SPLUNK_INDEX || 'heroku',
'event': formattedMessage
Expand Down
3 changes: 0 additions & 3 deletions test/lib/transports/splunkHEC.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ const SplunkHEC = proxyquire('../../../dist/lib/transports/splunkHEC', {
'../formatter': formatter
}).default;

// required for Splunk URL
process.env.SYSTEM_CODE = 'n-logger';

describe('SplunkHEC', () => {

it('should exist', () => {
Expand Down

0 comments on commit 66d07c5

Please sign in to comment.