Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ac-syslogh

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ac-syslogh

Log to the system's Syslog. Provides simple native bindings to <syslog.h> and syslog(3). Works on Node v0.10 up to v4.

  • 1.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Syslogh.js

NPM version Build status

Syslogh.js is a library for logging to your system's Syslog (RFC 3164) from within Node.js. It provides simple native bindings to <syslog.h> and syslog(3). You're in luck, because it does not come with any bells and whistles. Intentionally. KISS, right?

Works with Node v0.10, v0.11, v0.12 and of course v4 (stable).
Using it in production with Monday Calendar, so will be kept up to date when new Node versions come out.

Installing

Install with: npm install syslogh

Using

Using Syslogh.js is similar to using syslog(3) from C/C++.
First use openlog with your app name (up to 255 characters), options and the facility:

var Syslogh = require("syslogh")
Syslogh.openlog("myapp", Syslogh.PID, Syslogh.LOCAL7)

Then, when logging, just pass in the severity and your message.
Just like with regular syslog(3), you can use sprintf style placeholders. Those internally use Node's built-in Util.format.

Syslogh.syslog(Syslogh.NOTICE, "Freeze-frame high-five.")
Syslogh.syslog(Syslogh.NOTICE, "Phone %d.", 5)

You can also call Syslogh.closelog to close things down, but I'm not sure why you should bother. :-) Exiting your Node.js program will most likely shut everything down, too.

The syslog(3) manpage also talks about setlogmask to filter logs before they're sent. This isn't implemented. Not yet, at least.

Options

Options to pass to openlog come from <syslog.h>.

OptionDescription
CONSLog to the system console on error.
ODELAYDelay open until syslog() is called. (Often default.)
PIDLog the process ID with each message.
NDELAYConnect to syslog daemon immediately.
NOWAITDon't wait for child processes.

Access them as constants. E.g. Syslogh.PID.
They form a bit mask, so to pass multiple of them to openlog, binary-OR them together with the | operator:

Syslogh.openlog("myapp", Syslogh.PID | Syslogh.NDELAY, Syslogh.LOCAL7)

Facilities

Facilities to pass to openlog come from <syslog.h> and (RFC 3164).
Some facilities might differ between systems. For your own app use, best stick to LOCAL* facilities.

FacilityDescription
KERNKernel messages.
USERUser-level messages.
MAILMail system.
DAEMONSystem daemons.
AUTHSecurity/authorization messages.
SYSLOGMessages generated internally by syslogd.
LPRLine printer subsystem.
NEWSNetwork news subsystem.
UUCPUUCP subsystem.
CRONClock daemon.
AUTHPRIVSecurity/authorization messages.
LOCAL0Local use 0.
LOCAL1Local use 1.
LOCAL2Local use 2.
LOCAL3Local use 3.
LOCAL4Local use 4.
LOCAL5Local use 5.
LOCAL6Local use 6.
LOCAL7Local use 7.

Access them as constants. E.g. Syslogh.LOCAL7.

Severities

Severities to pass to syslog come from <syslog.h> and (RFC 3164).

SeverityDescription
EMERGSystem is unusable.
ALERTAction must be taken immediately.
CRITCritical conditions.
ERRError conditions.
WARNINGWarning conditions.
NOTICENormal but significant.
INFOInformational messages.
DEBUGDebug-level messages.

Access them as constants. E.g. Syslogh.NOTICE.

License

Syslogh.js is released under a Lesser GNU Affero General Public License, which in summary means:

  • You can use this program for no cost.
  • You can use this program for both personal and commercial reasons.
  • You do not have to share your own program's code which uses this program.
  • You have to share modifications (e.g. bug-fixes) you've made to this program.

For more convoluted language, see the LICENSE file.

About

Andri Möll typed this and the code.
Monday Calendar supported the engineering work.

If you find Syslogh.js needs improving, please don't hesitate to type to me now at andri@dot.ee or create an issue online.

Keywords

FAQs

Package last updated on 18 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc