jue89 / node-systemd-journald Goto Github PK
View Code? Open in Web Editor NEWNative bindings to journald
License: MIT License
Native bindings to journald
License: MIT License
Actually null
is an Object for Javascript.
With that in mind fields would not be flattened down to some entry in the Journal. They are just ignored by the converter function - and this more by accident - tbh:
Lines 7 to 23 in 5b9b59a
This is maybe not the best behaviour.
Propose: Display fields that are null
with the string "null" in the Journal? Any different opinions on that?
Thanks for this great lib, I stumbled upon it after getting annoyed by all log entries having different PIDs using my previous method, which was piping the log message into logger --journald
.
It would be great if you could add Typescript definitions to the package, for cleaner code in Typescript projects!
As a developer I'm really confused because there are "official" bindings for node provided on github.com/systemd
account and there is your lib which works on newer node versions (as far as I understand your README.Why
section).
Have you considered proposing your bindings as a replacement for github.com/systemd/node-systemd
? I mean something like opening pull request or issue there.
node-systemd-journald/src/journal_send.cc
Lines 50 to 61 in 12b17ee
process.title
is limited, according to the node docs.
The
process.title
property returns the current process title (i.e. returns the current value ofps
). Assigning a new value toprocess.title
modifies the current value ofps
.Note: When a new value is assigned, different platforms will impose different maximum length restrictions on the title. Usually such restrictions are quite limited. For instance, on Linux and OS X,
process.title
is limited to the size of the binary name plus the length of the command line arguments because setting theprocess.title
overwrites theargv
memory of the process. Node.js v0.8 allowed for longer process title strings by also overwriting theenviron
memory but that was potentially insecure and confusing in some (rather obscure) cases.
It would be awesome if there was a way to specify the syslog identifier without mucking with process.title
.
One idea would be to allow
const log = require('systemd-journald')
log.identifier = 'my-identifier';
log.debug(...)
I did some very light testing on one machine, and I was able to set the syslog identifier with the following code:
log.debug('My message', { syslog_identifier: 'my-identifier' })
which makes me think it might be as easy as checking if log.identifier
is defined and, if it is, adding fields.SYSLOG_IDENTIFIER = log.identifier
, but I didn't test that.
Thoughts?
If buffers are included in the fields object, something like this is put into the journal:
{
...
"PAYLOAD_0" : "1",
"PAYLOAD_1" : "2",
"PAYLOAD_2" : "3",
"PAYLOAD_3" : "4",
"PAYLOAD_4" : "5",
"PAYLOAD_5" : "6",
"PAYLOAD_6" : "7",
"PAYLOAD_7" : "8",
"PAYLOAD_8" : "9",
"PAYLOAD_9" : "0",
"PAYLOAD_ASCIISLICE" : "function asciiSlice() { [native code] }",
"PAYLOAD_BASE64SLICE" : "function base64Slice() { [native code] }",
"PAYLOAD_LATIN1SLICE" : "function latin1Slice() { [native code] }",
"PAYLOAD_HEXSLICE" : "function hexSlice() { [native code] }",
"PAYLOAD_UCS2SLICE" : "function ucs2Slice() { [native code] }",
"PAYLOAD_UTF8SLICE" : "function utf8Slice() { [native code] }",
"PAYLOAD_ASCIIWRITE" : "function asciiWrite() { [native code] }",
"PAYLOAD_BASE64WRITE" : "function base64Write() { [native code] }",
"PAYLOAD_LATIN1WRITE" : "function latin1Write() { [native code] }",
"PAYLOAD_HEXWRITE" : "function hexWrite() { [native code] }",
"PAYLOAD_UCS2WRITE" : "function ucs2Write() { [native code] }",
"PAYLOAD_UTF8WRITE" : "function utf8Write() { [native code] }",
"PAYLOAD_COPY" : "function copy() { [native code] }",
...
}
Maybe that's a better way to display them:
{
...
"PAYLOAD" : "<Buffer 01 02 03 04 05 06 07 08 09 00>",
...
}
I noticed in your code that you never call sd_journal_open
. Is the journal already opened by the NodeJS runtime or something?
Thanks in advance!
The convenience functions are nice, however it would be great if the log command would also be exposed, for easier incorporation in other logging libraries.
npm install
> [email protected] install /home/myproject/node_modules/systemd-journald
> node-gyp rebuild
Package libsystemd was not found in the pkg-config search path.
Perhaps you should add the directory containing `libsystemd.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libsystemd' found
gyp: Call to 'pkg-config --libs-only-l libsystemd' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
The problem is that on Mint 17.3, the package libsystemd-dev
doesn't exist, it's actually split up into systemct-*-dev
packages:
sudo aptitude search libsystemd-
i libsystemd-daemon-dev - systemd utility library - development files
p libsystemd-daemon-dev:i386 - systemd utility library - development files
i libsystemd-daemon0 - systemd utility library
p libsystemd-daemon0:i386 - systemd utility library
i A libsystemd-id128-0 - systemd 128 bit ID utility library
p libsystemd-id128-0:i386 - systemd 128 bit ID utility library
i A libsystemd-id128-dev - systemd 128 bit ID utility library - development files
p libsystemd-id128-dev:i386 - systemd 128 bit ID utility library - development files
i libsystemd-journal-dev - systemd journal utility library - development files
p libsystemd-journal-dev:i386 - systemd journal utility library - development files
i A libsystemd-journal0 - systemd journal utility library
p libsystemd-journal0:i386 - systemd journal utility library
i libsystemd-login-dev - systemd login utility library - development files
p libsystemd-login-dev:i386 - systemd login utility library - development files
i libsystemd-login0 - systemd login utility library
p libsystemd-login0:i386 - systemd login utility library
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.