Intercepting the 'time' section of the log message?
See original GitHub issueHi,
Great tool. I especially love the fact that we can intercept and modify the concat
and render
stages.
One thing I was not able to do:
I would like to format the timestamp
in the following fashion:
[2019-01-19T15:40:28.535Z] (INFO) This is just a message reporting a variable:
[1, 2, 3, 4, 5, 6] (info @ logging.js:60)
I know we can add a custom printer for the time, but that changes the output to:
[Sat Jan 19 2019 15:17:03 GMT+0000 (Greenwich Mean Time)]
which is not something that I would like to do? So here is what I am trying to achieve:
- Add
[
to the start and]
to the end of the timestamp. - Change the color of the timestamp (I know I can do that through the custom printer, but the custom printer is changing the look of the date)
- Adding a
(INFO)
signature between the timestamp and the message block, so the second line of the message does not spill below the(INFO)
signature.
So it looks a bit like this:
Obviously, I tried this:
const logging = log.configure ({
/* Injects a function after the "concat" step */
'concat+' (blocks) {
console.log(blocks)
return blocks;
},
time: {
yes: true,
format: 'iso'
}
});
as an attempt to intercept the text stream and try re-format it, but I got this:
[ '\u001b[33m\u001b[22m\u001b[1mThis is just a message reporting a variable:\u001b[22m\u001b[39m',
'\u001b[33m\u001b[22m\u001b[1m\u001b[22m\u001b[39m [1, 2, 3, 4, 5, 6]' ]
… so the timestamp was not there 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Intercepting all logging messages - python - Stack Overflow
I'm working with an application where just about every module and every class emits logging messages.
Read more >Logging and intercepting database operations - EF6
Starting with Entity Framework 6, anytime Entity Framework sends a command to the database this command can be intercepted by application ...
Read more >Intercepting messages - PortSwigger
From the Proxy > Intercept tab, you can intercept HTTP requests and responses sent between the browser and the target server.
Read more >intercept, evaluate, change syslog messages - Server Fault
is it possible to intercept syslog messages and evaluate (in special cases change) them before they are written into /var/log/?.
Read more >Chapter 18. Intercepting Messages Red Hat AMQ 7.0
Chapter 18. Intercepting Messages. With AMQ Broker you can intercept packets entering or exiting the broker, allowing you to audit packets or filter...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cryptoeraser I’ve added a new overrideable stage called
tag
. Please see the updated docs:The example code:
Yeah, I have seen your commit and I was already digging in the diffs 😃 Thank you very much! This is amazing!