Closed Z3TA closed 7 years ago
Haven't tried your patch yet. I will be able to have a deeper look into this over the weekend. But a very good idea! Thank you.
But according to the systemd documentation, we need to add SD_JOURNAL_SUPPRESS_LOCATION
before including sd-journal.h. Is there a reason, why you added this afterwards? (cf. https://www.freedesktop.org/software/systemd/man/sd_journal_print.html)
Just tested and can confirm that SD_JOURNAL_SUPPRESS_LOCATION needs to go before including sd-journal.h
The reason why I first put it below was that it looked nicer with the #define's grouped together. (I'm a C++ newb)
I just pushed the branch feature/store-line-numbers
. (I'm very good at bad branch naming ;))
It includes your PR. I also added a few lines for handling instances of Error
: The source's file name, function name and line number are also included into the log.
What do you think?
I have a philosophical dilemma in that no process, especially a NodeJS script should never be coupled with the init system of the OS it's running on.
Yes, I know what you mean.
In my projects, I'm using glue code to couple the main code with the logging provider. Thus, the project is still independent from the init system. Just the glue code is. And it can be easily replaced for other init/logging systems.
Make it possible to have more meaningful CODE_FILE, CODE_LINE and CODE_FUNC instead of them always pointing to journal_send.cc.
CODE_FILE, CODE_LINE and CODE_FUNC can be populated from a stack trace, for example using the npm module callsite.