2001-11-26 15:00:40 +03:00
|
|
|
.\" syslog.txt - -*- Indented-Text -*-
|
2002-02-25 15:13:30 +03:00
|
|
|
$RoughId: syslog.txt,v 1.18 2002/02/25 08:20:14 knu Exp $
|
2001-11-26 15:00:40 +03:00
|
|
|
$Id$
|
|
|
|
|
|
|
|
UNIX Syslog extension for Ruby
|
|
|
|
Amos Gouaux, University of Texas at Dallas
|
|
|
|
<amos+ruby@utdallas.edu>
|
|
|
|
&
|
|
|
|
Akinori MUSHA
|
2008-03-21 15:15:06 +03:00
|
|
|
<knu@iDaemons.org>
|
|
|
|
|
|
|
|
Contact:
|
|
|
|
- Akinori MUSHA <knu@iDaemons.org> (current maintainer)
|
2001-11-26 15:00:40 +03:00
|
|
|
|
2002-02-25 15:13:30 +03:00
|
|
|
** Syslog(Module)
|
2001-11-26 15:00:40 +03:00
|
|
|
|
2002-02-25 15:13:30 +03:00
|
|
|
Included Modules: Syslog::Constants
|
2001-11-26 15:00:40 +03:00
|
|
|
|
|
|
|
require 'syslog'
|
|
|
|
|
|
|
|
A Simple wrapper for the UNIX syslog system calls that might be handy
|
|
|
|
if you're writing a server in Ruby. For the details of the syslog(8)
|
|
|
|
architecture and constants, see the syslog(3) manual page of your
|
|
|
|
platform.
|
|
|
|
|
2002-02-25 15:13:30 +03:00
|
|
|
Module Methods:
|
2001-11-26 15:00:40 +03:00
|
|
|
|
|
|
|
open(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
|
|
|
|
facility = Syslog::LOG_USER) [{ |syslog| ... }]
|
|
|
|
|
2002-02-25 15:13:30 +03:00
|
|
|
Opens syslog with the given options and returns the module
|
|
|
|
itself. If a block is given, calls it with an argument of
|
|
|
|
itself. If syslog is already opened, raises RuntimeError.
|
2001-11-26 15:00:40 +03:00
|
|
|
|
|
|
|
Example:
|
2002-02-25 15:13:30 +03:00
|
|
|
Syslog.open('ftpd', Syslog::LOG_PID | Syslog::LOG_NDELAY,
|
|
|
|
Syslog::LOG_FTP)
|
2001-11-26 15:00:40 +03:00
|
|
|
|
|
|
|
open!(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
|
|
|
|
facility = Syslog::LOG_USER)
|
|
|
|
reopen(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
|
|
|
|
facility = Syslog::LOG_USER)
|
|
|
|
|
|
|
|
Same as open, but does a close first.
|
|
|
|
|
|
|
|
opened?
|
|
|
|
|
|
|
|
Returns true if syslog opened, otherwise false.
|
|
|
|
|
|
|
|
ident
|
|
|
|
options
|
|
|
|
facility
|
|
|
|
|
|
|
|
Returns the parameters given in the last open, respectively.
|
2002-02-25 15:13:30 +03:00
|
|
|
Every call of Syslog::open resets these values.
|
2001-11-26 15:00:40 +03:00
|
|
|
|
|
|
|
log(pri, message, ...)
|
|
|
|
|
|
|
|
Writes message to syslog.
|
|
|
|
|
|
|
|
Example:
|
2002-02-25 15:13:30 +03:00
|
|
|
Syslog.log(Syslog::LOG_CRIT, "the sky is falling in %d seconds!", 10)
|
2001-11-26 15:00:40 +03:00
|
|
|
|
|
|
|
crit(message, ...)
|
|
|
|
emerg(message, ...)
|
|
|
|
alert(message, ...)
|
|
|
|
err(message, ...)
|
|
|
|
warning(message, ...)
|
|
|
|
notice(message, ...)
|
|
|
|
info(message, ...)
|
|
|
|
debug(message, ...)
|
|
|
|
|
2002-02-25 15:13:30 +03:00
|
|
|
These are shortcut methods of Syslog::log(). The lineup may
|
2001-11-26 15:00:40 +03:00
|
|
|
vary depending on what priorities are defined on your system.
|
|
|
|
|
|
|
|
Example:
|
2002-02-25 15:13:30 +03:00
|
|
|
Syslog.crit("the sky is falling in %d seconds!", 5)
|
2011-05-22 13:26:02 +04:00
|
|
|
|
2001-11-26 15:00:40 +03:00
|
|
|
mask
|
|
|
|
mask=(mask)
|
|
|
|
|
|
|
|
Returns or sets the log priority mask. The value of the mask
|
2002-02-25 15:13:30 +03:00
|
|
|
is persistent and will not be reset by Syslog::open or
|
|
|
|
Syslog::close.
|
2001-11-26 15:00:40 +03:00
|
|
|
|
|
|
|
Example:
|
2002-02-25 15:13:30 +03:00
|
|
|
Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR)
|
2001-11-26 15:00:40 +03:00
|
|
|
|
2011-05-22 13:26:02 +04:00
|
|
|
close
|
2001-11-26 15:00:40 +03:00
|
|
|
|
|
|
|
Closes syslog.
|
|
|
|
|
|
|
|
inspect
|
|
|
|
|
2002-02-25 15:13:30 +03:00
|
|
|
Returns the "inspect" string of the Syslog module.
|
2001-11-26 15:00:40 +03:00
|
|
|
|
2002-02-25 15:13:30 +03:00
|
|
|
instance
|
2001-11-26 15:00:40 +03:00
|
|
|
|
2002-02-25 15:13:30 +03:00
|
|
|
Returns the module itself. (Just for backward compatibility)
|
|
|
|
|
|
|
|
LOG_MASK(pri)
|
|
|
|
|
|
|
|
Creates a mask for one priority.
|
|
|
|
|
|
|
|
LOG_UPTO(pri)
|
|
|
|
|
|
|
|
Creates a mask for all priorities up to pri.
|
|
|
|
|
|
|
|
** Syslog::Constants(Module)
|
2001-11-26 15:00:40 +03:00
|
|
|
|
|
|
|
require 'syslog'
|
|
|
|
include Syslog::Constants
|
|
|
|
|
|
|
|
This module includes the LOG_* constants available on the system.
|
2002-02-25 15:13:30 +03:00
|
|
|
|
|
|
|
Module Methods:
|
|
|
|
|
|
|
|
LOG_MASK(pri)
|
|
|
|
|
|
|
|
Creates a mask for one priority.
|
|
|
|
|
|
|
|
LOG_UPTO(pri)
|
|
|
|
|
|
|
|
Creates a mask for all priorities up to pri.
|