{"id":21703719,"url":"https://github.com/carvilsi/node-systemd-journal","last_synced_at":"2026-01-28T09:03:51.521Z","repository":{"id":230238325,"uuid":"776077035","full_name":"carvilsi/node-systemd-journal","owner":"carvilsi","description":"Interact with linux systemd journal, adding entries and retrieving logs from NodeJS.","archived":false,"fork":false,"pushed_at":"2024-10-18T08:51:42.000Z","size":118,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T15:12:39.977Z","etag":null,"topics":["journal","journalctl","linux","logger","nodejs","npm","systemd"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carvilsi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-22T16:26:40.000Z","updated_at":"2024-08-23T06:20:29.000Z","dependencies_parsed_at":"2024-03-28T16:04:07.792Z","dependency_job_id":"7f7d6550-5c11-49f5-b0a5-b5826c4cbec9","html_url":"https://github.com/carvilsi/node-systemd-journal","commit_stats":null,"previous_names":["carvilsi/node-systemd-journal"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvilsi%2Fnode-systemd-journal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvilsi%2Fnode-systemd-journal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvilsi%2Fnode-systemd-journal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carvilsi%2Fnode-systemd-journal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carvilsi","download_url":"https://codeload.github.com/carvilsi/node-systemd-journal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586245,"owners_count":21128998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["journal","journalctl","linux","logger","nodejs","npm","systemd"],"created_at":"2024-11-25T21:35:02.520Z","updated_at":"2026-01-28T09:03:51.515Z","avatar_url":"https://github.com/carvilsi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/carvilsi/node-systemd-journal/tests.yml?logo=github\u0026label=tests\" alt=\"test\"\u003e\n  \u003cp\u003e\u003c/p\u003e\n\u003c/div\u003e\n\n# node-systemd-journal\n\nInteract with linux systemd journal, adding entries and retrieving logs from NodeJS.\n\n**Only works on Linux**\n\n## Usage\n\n`$ npm install --save sysdlogger`\n\nThe in your code:\n\n```javascript\nimport { SysDLogger } from 'sysdlogger';\n\n// instatiate with a tag\nconst syslogger = new SysDLogger({ tag: 'FOOBAR' });\n\n(async() =\u003e {\n    // writes with the provided tag\n    await syslogger.write('This is a foobar entry for journal');\n    // reads from journal by tag\n    const res = await syslogger.read();\n    console.log(res);\n})();\n```\nYou can check the added entry to journal like:\n\n`$ journalctl -t FOOBAR`\n\n**Options**\nThis could be provided when instantiate or override when calling *write* or *read*.\n\n```javascript\nconst options = {\n    // string; the choosen tag, if not provided the default will be 'SysDLogger'\n    tag: 'SysDLogger', \n    // boolean; true will retrieve a JSON object with the log contenc\n    json: false,\n    // number of lines to retrieve from journal\n    lines: 0,\n    // if true will retrieve first latest entries\n    reverse: false,\n    // string; the choosen level or priority for logging, default: notice\n    level: undefined, \n}\n```  \n\nWith options for writing and reading you can do things like:\n\n```javascript\nimport { SysDLogger } from 'sysdlogger';\nimport assert from 'node:assert';\n\n(async() =\u003e {\n    const myTag = 'NODE_SYSTEMD_JOURNAL';\n    const message = 'an ugly pigeon and a fluffy squirrel';\n    await syslogger.write(message, { tag: myTag });\n    const slogJSON = await syslogger.read({\n            tag: myTag,\n            json: true,\n            reverse: true,\n            lines: 1,\n            level: 'warn',\n    });\n    assert(slogJSON[0].SYSLOG_IDENTIFIER === myTag);\n    assert(slogJSON[0].MESSAGE === message);\n    assert(slogJSON[0].PRIORITY === 4);\n    assert(typeof slogJSON === 'object');\n})();\n```     \nThe properties of the JSON object from journal are:\n\n```javascript\n[\n  '_TRANSPORT',\n  '_SYSTEMD_CGROUP',\n  '_UID',\n  '_SYSTEMD_USER_SLICE',\n  'PRIORITY',\n  '_AUDIT_LOGINUID',\n  'SYSLOG_IDENTIFIER',\n  '__MONOTONIC_TIMESTAMP',\n  '_SYSTEMD_SLICE',\n  '_SYSTEMD_UNIT',\n  'SYSLOG_FACILITY',\n  '_CAP_EFFECTIVE',\n  '_SOURCE_REALTIME_TIMESTAMP',\n  '_RUNTIME_SCOPE',\n  '_MACHINE_ID',\n  '__SEQNUM_ID',\n  '_SYSTEMD_INVOCATION_ID',\n  '_HOSTNAME',\n  '__CURSOR',\n  '_GID',\n  '_SYSTEMD_OWNER_UID',\n  '__REALTIME_TIMESTAMP',\n  '_BOOT_ID',\n  'MESSAGE',\n  'SYSLOG_TIMESTAMP',\n  '_AUDIT_SESSION',\n  '_PID',\n  '_SYSTEMD_USER_UNIT',\n  '__SEQNUM',\n  '_COMM'\n]\n```\n\nThe list of **levels** and the equivalent of *PRIORITY* JSON field:\n\n```javascript\n[ \n    emerg: 0,\n    alert: 1,\n    crit: 2,\n    err: 3,\n    error: 3,\n    warning: 4,\n    warn: 4,\n    notice: 5,\n    info: 6,\n    debug: 7\n]\n```\n\nAlso possible to use an alias to write a log message with a level like this:\n\n```javascript\nconst MESSAGE = 'a pigeon over the roof';\n\n//add an entry to systemd-journal with debug level\nawait syslogger.debug(MESSAGE);\n\n//add an entry to systemd-journal with info level\nawait syslogger.info(MESSAGE);\n\n//add an entry to systemd-journal with notice level\nawait syslogger.notice(MESSAGE);\n\n//add an entry to systemd-journal with warning level\nawait syslogger.warn(MESSAGE);\n\n//add an entry to systemd-journal with error level\nawait syslogger.error(MESSAGE);\n\n//add an entry to systemd-journal with critical level\nawait syslogger.crit(MESSAGE);\n\n//add an entry to systemd-journal with alert level\nawait syslogger.alert(MESSAGE);\n\n//add an entry to systemd-journal with emergency level\nawait syslogger.emerg(MESSAGE);\n```\n\nMore info about [Journal JSON format](https://systemd.io/JOURNAL_EXPORT_FORMATS#journal-json-format)\n\nMore info also:\n\n`$ man journalctl`\n\n`$ man logger`\n\n---\n\nFeedback from usage and contributions are very welcome.\nAlso if you like it, please leave a :star: I would appreciate it ;)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarvilsi%2Fnode-systemd-journal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarvilsi%2Fnode-systemd-journal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarvilsi%2Fnode-systemd-journal/lists"}