Skip to content

Commit

Permalink
Merge pull request #9 from digipolisantwerp/feature/dontlogbuffer
Browse files Browse the repository at this point in the history
don't log buffer
  • Loading branch information
vademo committed Feb 23, 2022
2 parents f6aa034 + 3e37c74 commit c1df91c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/helpers/formatter.js
Expand Up @@ -5,6 +5,9 @@ const getCircularReplacer = () => {
const seen = new WeakSet();
return (key, value) => {
if (typeof value === 'object' && value !== null) {
if (Buffer.isBuffer(value) || value.type === 'Buffer') {
return '[Buffer]';
}
if (seen.has(value)) {
return '[Circular]';
}
Expand Down
16 changes: 16 additions & 0 deletions test/log.test.js
Expand Up @@ -257,6 +257,22 @@ describe('Logs:', () => {
message: 'logmessage Extrainfo: {"extraparam":"extravalue"}',
}));
});
it('{ message: "logmessage", extraparam: buffer }', async () => {
const buffer = Buffer.from('smdlfkjmsldjfmlskdjfmlskjfmlksdjflskdjf');
const logmessage = { message: 'logmessage', extraparam: buffer };
log(console, {
type: 'log',
override: true,
});
console.log(logmessage);
sinon.assert.calledWith(logstub.log, JSON.stringify({
timestamp: new Date().toISOString(),
type: ['technical'],
level: 'INFO',
correlationId: '',
message: 'logmessage Extrainfo: {"extraparam":"[Buffer]"}',
}));
});
});
describe('{ type: text }', () => {
it('"logmessage"', async () => {
Expand Down

0 comments on commit c1df91c

Please sign in to comment.