logpipes
v1.10.2
Published
Console.log transformation pipes
Downloads
79,823
Maintainers
Readme
logpipes
Transforms console.log ('debug', 'error', 'info', 'log', 'trace', 'warn') method output with chainable pipes.
Comes with a ready-to-use implementation of different pipes, like 'JsonStringifyPipe': a pipe that transforms console output into a single serialized JSON string.
TypeScript safe. Has zero external dependencies.
Usage example:
import {installConsoleOverrides} from 'logpipes';
installConsoleOverrides(createJsonStringifyPipe());
console.log('Log after pipe is installed', {a: 1, b: 2, c: 3});
Produces a one-liner string with a serialized JSON:
'{"message":"Log after pipe is installed $1","$1":{"a":1,"b":2,"c":3},"level":"log","timestamp":"2023-07-03T17:13:56.018Z","id":"current-log-message-uuid"}'
Pipes
JsonPipe
JsonPipe converts console log arguments into a single serializable JSON object.
The pipe accepts JsonPipeOptions
which inherits all JsonSimplifierOptions
.
See in-code docs for the available options:
Check unit tests for more examples.
JsonStringifyPipe
JsonStringifyPipe calls JsonPipe and converts the result JSON object into a single line string.
See docs for JsonPipe
for more details.
LogLevelFilterPipe
LogLevelFilterPipe excludes configured log levels from the final output.
See LogLevelFilterPipeOptions and related unit tests.
LogMessageFilterPipe
LogMessageFilterPipe excludes configured all log events with a specified tokens in the message.
See LogMessageFilterPipeOptions and related unit tests.
LogCachePipe
LogCachePipe caches console messages and provides access to the cache.
This pipe can be used to dump or sideload all console log messages.
See LogCachePipeOptions and related unit tests.
DateTimePipe
Adds a timestamp as the first parameter to every console message.
NoopPipe
NoopPipe does nothing and proxies all parameters to the next pipe with no changes.
It can be used to reduce a client-side boilerplate code.