log4js-node / gelf

GELF Appender for log4js-node
Apache License 2.0
4 stars 10 forks source link

fix: Removed delete for CustomFields.GELF #4

Closed SockeThe2nd closed 5 years ago

SockeThe2nd commented 5 years ago

When using log4js with the GELF-Appender like this, only the first message is sent correctly. GELF_DATA.GELF is removed after the first call.

const GELF_DATA = {
  GELF: true,
  _userId: "someID"
  _customerId: "someOtherId"
};

//GELF_DATA.GELF was removed here
logger.info(GELF_DATA, "Requested resource");

if(accessOk) {
  logger.info(GELF_DATA, "Resource access OK");
}else {
  logger.warn(GELF_DATA, "Resource access not OK");
}

Field is not used later as all fields not starting with underscore are removed anyway. The fix keeps the input-object unchanged. And allows this kind of usage.

codecov[bot] commented 5 years ago

Codecov Report

Merging #4 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #4   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines          76     75    -1     
=====================================
- Hits           76     75    -1
Impacted Files Coverage Δ
lib/index.js 100% <ø> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update cad1836...fc9cff0. Read the comment docs.

nomiddlename commented 5 years ago

Thanks for this, much appreciated.

nomiddlename commented 5 years ago

Published to NPM in version 1.0.2