0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-06 22:40:26 -05:00
verdaccio/packages/logger/logger-prettify/test/index.spec.ts
Michael Ryan cf1b46cc59
fix: log spacing depending on the FORMAT and COLORS options (#4631)
* fix: Bad log spacing depending on the FORMAT and COLORS options used

fixes: #4630

inserted a space between the timestamp and the message when logging timestamped messages.

* fix: Bad log spacing depending on the FORMAT and COLORS options used

fixes: #4630

removed padding of an unnecessary space (at the start or end of the log string, depending on whether colors are enabled).

* remove padLeft, update tests

* update logger-commons tests

---------

Co-authored-by: Marc Bernard <marc@marcbernardtools.com>
2024-06-01 21:35:06 +02:00

28 lines
692 B
TypeScript

import pino from 'pino';
import { Writable } from 'stream';
import { buildPretty } from '../src';
describe('prettyFactory', () => {
const prettyfierOptions = {
messageKey: 'msg',
levelFirst: true,
prettyStamp: false,
colors: false,
};
test('should return a function', (done) => {
const pretty = buildPretty(prettyfierOptions);
const log = pino(
new Writable({
objectMode: true,
write(chunk, enc, cb) {
const formatted = pretty(JSON.parse(chunk));
expect(formatted).toBe('info --- test message');
cb();
done();
},
})
);
log.info({ test: 'test' }, '@{test} message');
});
});