@join-com/gcloud-logger
Advanced tools
Comparing version 1.6.0 to 1.6.1-alpha.1
import { Logger } from '../src' | ||
describe('logger', () => { | ||
afterEach(() => jest.resetAllMocks()) | ||
it('truncates field over maxFieldLength', () => { | ||
@@ -20,2 +22,19 @@ const stdoutSpy = jest.spyOn(process.stdout, 'write'); | ||
}) | ||
}) | ||
it('ignores provided max field length if warning', () => { | ||
const stdoutSpy = jest.spyOn(process.stdout, 'write') | ||
const logger = new Logger(true, 'DEBUG', [], 5) | ||
logger.warn('msg', { response: { some: 'longWord' } }) | ||
const log = '{"response":{"some":"longWord"},"message":"msg","severity":"WARNING","level":400}\n' | ||
expect(stdoutSpy).toHaveBeenCalledWith(log) | ||
}) | ||
it('truncates field over maxFieldLengthForError if warning', () => { | ||
const stdoutSpy = jest.spyOn(process.stdout, 'write') | ||
const logger = new Logger(true, 'DEBUG', [], 5) | ||
logger.warn('msg', { response: { some: 'x'.repeat(8000) } }) | ||
expect(stdoutSpy.mock.calls[0]?.[0].length).toBeLessThan(4100) | ||
}) | ||
}) |
@@ -8,3 +8,4 @@ "use strict"; | ||
Object.defineProperty(exports, "Level", { enumerable: true, get: function () { return Logger_2.Level; } }); | ||
exports.logger = new Logger_1.Logger(process.env['NODE_ENV'] === 'production', process.env['LOG_LEVEL'], undefined, parseInt(process.env['LOG_MAX_FIELD_LENGTH'] ?? '', 10)); | ||
const DEFAULT_MAX_LENGTH = '1000'; | ||
exports.logger = new Logger_1.Logger(process.env['NODE_ENV'] === 'production', process.env['LOG_LEVEL'], undefined, parseInt(process.env['LOG_MAX_FIELD_LENGTH'] ?? DEFAULT_MAX_LENGTH, 10)); | ||
const reportError = (e) => { | ||
@@ -11,0 +12,0 @@ exports.logger.reportError(e); |
@@ -176,3 +176,3 @@ "use strict"; | ||
if (obj.length > maxLength) { | ||
return obj.substring(0, this.maxFieldLength) + '...TRUNCATED'; | ||
return obj.substring(0, maxLength) + '...TRUNCATED'; | ||
} | ||
@@ -179,0 +179,0 @@ } |
{ | ||
"name": "@join-com/gcloud-logger", | ||
"version": "1.6.0", | ||
"version": "1.6.1-alpha.1", | ||
"description": "gcloud simple logger", | ||
@@ -5,0 +5,0 @@ "author": "JOIN Solutions", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
24455
357
2