SYSLOG(3lua)
π SYSLOG(3lua) β the Lua glow-up
okay so bestie, this is the syslog page from the LOCAL manual set β like, section 3lua, the Lua-bindings corner of the man-page universe. It's the one that lets your Lua code talk to syslog(3). Yes. That syslog. The β¨realβ¨ one. Buckle up π
πΈ NAME πΈ
syslog β get at all that syslog(3) functionality straight from Lua, no cap π
β¨ SYNOPSIS β¨
local syslog = require 'syslog'
syslog.openlog(ident, logopt, facility)
syslog.syslog(priority, message)
syslog.closelog()
oldmask = syslog.setlogmask(maskpri)
That's it. Four calls. Iconic behaviour, honestly π«Ά
π DESCRIPTION π
The syslog Lua binding hands you access to syslog(3) functionality. Like, the whole point. Logging from Lua, but the real logging, the system kind. Obsessed π¦
π§ syslog.openlog(ident, logopt, facility)
This one is for when you want more specialized processing of the messages that syslog.syslog() sends out. Fancy. Main character energy.
The parameter ident is a string that gets prepended to every single message. Every one. It's the little name tag your logs wear π
The logopt argument is a bit field specifying logging options, and you form it by adding together one or more of these bad boys:
syslog.LOG_CONSβ ifsyslog.syslog()can't pass the message along tosyslogd(8), it's gonna try writing that message to the console (/dev/console). Backup plan activated πsyslog.LOG_NDELAYβ open the connection tosyslogd(8)immediately. Normally that open is delayed until the very first message gets logged. This one's useful for programs that need to manage the order in which file descriptors get allocated. fr fr, it matters π₯syslog.LOG_PERRORβ writes the message to standard error output as well as to the system log. Double posting, but make it intentional β¨syslog.LOG_PIDβ logs the process id with each message, which is genuinely so useful for identifying instantiations of daemons. (And just so we're clear: this PID gets placed within brackets between theidentand the message. tiny detail, big deal π)
Then the facility parameter encodes a default facility assigned to all messages that don't already have an explicit facility encoded. The menu:
syslog.LOG_AUTHβ the authorization system:login(1),su(1),getty(8), etc. π«Άsyslog.LOG_AUTHPRIVβ same asLOG_AUTH, except it gets logged to a file readable only by selected individuals. exclusive. iykyk πsyslog.LOG_CRONβ the cron daemon:cron(8)β°syslog.LOG_DAEMONβ system daemons, likerouted(8), that aren't provided for explicitly by other facilitiessyslog.LOG_FTPβ the file transfer protocol daemon:ftpd(8)πsyslog.LOG_KERNβ messages generated by the kernel. Heads up bestie: these cannot be generated by any user processes. Not your lane, not your problem πsyslog.LOG_LPRβ the line printer spooling system:lpr(1),lpc(8),lpd(8), etc. π¨οΈsyslog.LOG_MAILβ the mail system π¬syslog.LOG_NEWSβ the network news system π°syslog.LOG_SYSLOGβ messages generated internally bysyslogd(8). self-referential queen πsyslog.LOG_USERβ messages generated by random user processes. This is the default facility identifier if none is specified, so if you're lazy (same), this is where you land πsyslog.LOG_UUCPβ the uucp systemsyslog.LOG_LOCAL0β reserved for local use. Similarly forsyslog.LOG_LOCAL1throughsyslog.LOG_LOCAL7β you get the whole little family, seven siblings and all π
π syslog.syslog(priority, message)
The syslog() function writes message to the system message logger. Then that message gets written to the system console, log files, logged-in users, or forwarded to other machines as appropriate (peep syslogd(8) for the how). It's giving distribution network β¨
The message gets tagged with priority, and priorities are encoded as a facility plus a level. The facility describes which part of the system is generating the message. The level comes from this list, and it's ordered β high to low, bestie:
syslog.LOG_EMERGβ a panic condition. This one is normally broadcast to all users. π¨ everyone's getting this textsyslog.LOG_ALERTβ a condition that should be corrected immediately, like, say, a corrupted system database. fix it NOW πsyslog.LOG_CRITβ critical conditions, e.g., hard device errorssyslog.LOG_ERRβ errorssyslog.LOG_WARNINGβ warning messagessyslog.LOG_NOTICEβ conditions that aren't error conditions but should possibly be handled specially. the "hmm π" tiersyslog.LOG_INFOβ informational messagessyslog.LOG_DEBUGβ messages that contain information normally of use only when debugging a program π
π syslog.closelog()
Use this to close the log file. That's the whole thing. Bye π
π¦ oldmask = syslog.setlogmask(maskpri)
The setlogmask() function sets the log priority mask to maskpri and returns the previous mask β so you get the old one back as oldmask, cute little handoff π«Ά. Calls to syslog() with a priority that isn't set in maskpri get rejected. Just so you know π
π SEE ALSO π
lua(1), luac(1), syslog(3), intro(3lua), syslogd(8)
the whole friend group, go say hi π
β HISTORY β
A syslog Lua binding manual appeared in NetBSD 7.0</> . and now it's here, being explained to you in a group chat. glow-up complete β¨
π AUTHORS π
The syslog Lua binding was written by Marc Balmer <mbalmer@NetBSD.org>. king behaviour, we love to see it π«Άπ
ngl bestie, log responsibly β LOG_EMERG is not a vibe for casual use π
Debian Β· January 7, 2014 β that's the source and the date, mwah, catch you in the logs πππ¦
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2013, 2014 Marc Balmer <mbalmer@NetBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms