tcl-syslog(3tcl)

πŸ“¦
version 2.0.2 Β· 2 versions
, in ubuntu stonking

πŸ’– tcl-syslog β€” the manual page, but make it a group chat πŸ’–

okay bestie, sit down, hydrate, and let me tell you about tcl-syslog(3tcl) β€” the Syslog interface for Tcl. yes it's real, yes it's iconic, and yes we're gonna go through every single line together. no skipping. 🫢


✨ NAME ✨

tcl-syslog β€” the Syslog interface for Tcl πŸ’…


🌸 SYNOPSIS 🌸

like, here's the whole shape of it:

package require syslog

::syslog::open ?-ident ident? ?-facility facility? ?-pid? ?-perror? ?-console? ?-nodelay?
::syslog::close
::syslog::log ?-level level? ?-priority level? ?-facility facility? ?-format message_format? message
::syslog::configure ?-ident ident? ?-facility facility? ?-pid? ?-perror? ?-console? ?-nodelay?
::syslog::configure ?-level level? ?-priority level? ?-facility facility? ?-format message_format?
::syslog::cget
::syslog::cget -global

syslog ?-ident ident? ?-facility facility? ?-pid? ?-perror? ?-console? ?-nodelay? ?-level level? message

the ?question marks? mean "optional, bestie, you don't gotta". the rest you type exactly. periodt. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so. Syslog is a standard for forwarding log messages to local and other logging services that live on a TCP/IP network. it's typically used for computer system management and security auditing β€” usually to aggregate log messages in a central repository, which is giving "let's put all our receipts in one folder". it's standardized inside the Syslog working group of the IETF. and it's available in all POSIX compliant and POSIX-like Operating Systems. all of them. no cap. πŸ‘‘

this package provides a Tcl interface to the standard syslog service. it creates a Tcl namespace with commands for:

  • opening and closing the connection to syslogd,
  • sending messages to the syslog service,
  • and querying configuration.

the current version also provides the global namespace command syslog for compatibility with earlier versions of the package. and bestie, listen: it is deprecated and kept only for backward compatibility. it's that one friend who still shows up but we're gently phasing out. πŸ™ˆ


πŸŽ€ COMMANDS πŸŽ€

πŸ’œ ::syslog::open

Establish the process-wide connection to the syslog facility (calls openlog). this one should be called once per process (typically at startup, like your morning routine). options set here are global and shared among threads.

okay so the options:

  • -ident ident β€” optional tag used by syslog to identify the process or log context. it's the little name tag at the party. 🏷️
  • -pid β€” if rsyslog or the logger log line formatting rules don't already show the pid, it can be added by specifying this option.
  • -perror β€” print the message also to stderr.
  • -console β€” write directly to the system console if syslogd is unavailable.
  • -nodelay β€” open the connection immediately instead of waiting for the first message. impatient queen behaviour, we respect it.
  • -facility facility β€” set the default facility for this process. valid facilities are:
  • auth β€” security/authorization messages
  • authpriv β€” security/authorization messages (private)
  • cron β€” clock daemon (cron and at)
  • daemon β€” system daemons without separate facility value
  • ftp β€” ftp daemon
  • kern β€” kernel messages
  • local0 β€” local use (0)
  • local1 β€” local use (1)
  • local2 β€” local use (2)
  • local3 β€” local use (3)
  • local4 β€” local use (4)
  • local5 β€” local use (5)
  • local6 β€” local use (6)
  • local7 β€” local use (7)
  • lpr β€” line printer subsystem
  • mail β€” mail subsystem
  • news β€” USENET news subsystem
  • syslog β€” messages generated internally by syslogd(8)
  • user β€” generic user-level messages
  • uucp β€” UUCP subsystem

the default facility is user. 🌿

🌈 ::syslog::close

Close the process-wide connection to syslog (calls closelog). it is safe to call this multiple times, but unwise if the code is supposed to log more lines. it will work, but it comes at the cost of re-establishing the connection to the syslog service. it's giving "leaving the group chat and then getting re-added 30 seconds later". 😭

⭐ ::syslog::log

Send a log message. options set here are per-thread (interpreter-local) and persist across subsequent calls in the same thread. yes, they remember. they hold onto your settings like a bestie holds onto your secrets. πŸ’…

the options:

  • -level level β€” describe the severity of the message. valid levels are:
  • emergency β€” system is unusable
  • alert β€” action must be taken immediately
  • critical β€” critical conditions
  • error β€” error conditions
  • warning β€” warning conditions
  • notice β€” normal, but significant, condition
  • info β€” informational message
  • debug β€” debug-level message

the default level is info. 🌱

  • -priority β€” synonym for -level. same energy, different spelling.
  • -format message_format β€” limited support for syslog formatting. the format string must contain %s where the message will be substituted. don't forget the %s, bestie, it's load-bearing. 🫠
  • -facility facility β€” override the global facility for this thread only. just this thread. not the whole process. it's a personal choice. πŸ™ˆ

🧚 ::syslog::configure

Set configuration options without emitting a message. this command accepts both:

  • global options (same as ::syslog::open), and
  • per-thread options (same as ::syslog::log).

and heads up: if a global option changes, the process-wide connection is reopened. ⚠️

πŸ‘‘ ::syslog::cget

Return the current configuration.

  • with no arguments, returns the per-thread options as a Tcl list of -option value pairs.
  • with -global, returns the process-wide options (global state) as a Tcl list.

option lists returned by ::syslog::cget have a form suitable to be passed as as arguments to ::syslog::configure and are equivalent to storing the configuration for later use. basically you can yank the config out and shove it right back in later. saving for the group chat, as one does. πŸ’Ύβœ¨


🌟 RATIONALE 🌟

okay so here's the tea. the syslog connection established by openlog is process-wide, while per-thread settings (level, facility override, format) should be isolated in each thread. the separation between ::syslog::open and ::syslog::log mirrors this design:

  • ::syslog::open manages the process-level connection and options that should be set once and shared.
  • ::syslog::log manages per-thread options that can differ across interpreters.

this avoids the overhead of reopening the syslog connection for every log call, while still allowing per-thread customization. iconic engineering honestly. efficiency AND personalization. main character design. πŸ‘‘


πŸ”₯ EXAMPLES πŸ”₯

here's the whole lil routine:

package require syslog

::syslog::open -ident myapp -facility local0 -pid
::syslog::log -level info "An info message..."
# equivalently
::syslog::log info "An info message...."
::syslog::log -facility user info "Info message 2...."
# subsequent calls preserve thread-local options
::syslog::log "Info message 3...."

see how the last one just says the message and nothing else? that's the thread-local options persisting. they remembered. they always remember. πŸ₯Ή


πŸ’€ COMPATIBILITY πŸ’€

the global space command syslog is provided for compatibility but it is deprecated because it can reopen openlog implicitly. this command accepts both global options and per-thread options, but it should be replaced by explicit ::syslog::open and ::syslog::log calls. bestie, let the legacy go. πŸ•ŠοΈ

package require syslog

syslog critical "Message 1"
syslog -ident tclsh warning "Message 2"
syslog -facility local0 notice "Message 3"
syslog -ident tclsh -facility user error "Message 4"
syslog -pid critical "Message 5.0"
syslog -pid -ident tclsh critical "Message 5.1"
syslog -pid -facility local0 debug "Message 5.1"
syslog -pid -facility local1 -ident tclsh info "Message 5.2"
syslog -pid -ident tclsh -facility local2 warning "Message 5.3"

outputs in /var/log/syslog (syslog timestamps and line prefix removed):

tclsh: Message 1
tclsh: Message 2
tclsh: Message 3
testident: Message 4
tclsh[7049]: Message 5.0
my_ident[7049]: Message 5.1
tclsh[7049]: Message 5.1
my_ident[7049]: Message 5.2
my_ident[7049]: Message 5.3

look at all those pids showing up. the -pid option really said "let me introduce myself". 🫢


πŸ“š REFERENCES πŸ“š

  • Michael Kerrisk, The Linux Programming Interface, No Starch Press, 2010, ISBN 978-1-59327-220-3.

🫢 AUTHORS 🫢

  • Alexandros Stergiakis <sterg@kth.se>
  • Massimo Manghi <mxmanghi@apache.org>

Copyright Β© 2008 Alexandros Stergiakis Copyright Β© 2024-2026 Massimo Manghi

this program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

this program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. see the GNU General Public License for more details.

you should have received a copy of the GNU General Public License along with this program. if not, see http://www.gnu.org/licenses/.

⚠️ real talk: no warranty, bestie. it's giving "we love you but we're not legally responsible for your log messages". πŸ’–

πŸ‘€ SEE ALSO πŸ‘€

syslog(3), openlog(3), closelog(3), logger(1), syslogd(8), tcl(3tcl)


and that's the whole page!! this one's Tcl-Extensions version 2.0.2, and if u ever forget which manual u were reading it's literally right there in the name: tcl-syslog(3tcl). πŸ’–βœ¨ go log something cute, bestie. mwah. πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from