[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]


Well, this is my first shot at making a wrapper for logger for packages
to use. This is just for testing and usability try outs. I used
dpkg-divert as a template so that it could easily be droped into
dpkg-?.?.?/scripts/ for actual usage.

The only thing it needs now is a formal proposal written up with the
proper ammendments to the policy. I'm working on that now. After that I
hope I can get some developers to back the proposal in order to get a

The script works in this way:

 dpkg-logger [ --stdout ] <pkgname> <level> message|<message

 --stdout	Also echo message to stdout as well as log

 <pkgname>	The package that is sending this message

 <level>	One of: info, warn, alert, debug
		Please read the policy manual for usage of levels.
		Debug is not for production, but is for testing only.

 message	The message you wish to have logged. This is either on
		the command line or from stdin (command line takes

What it does:

Right now I have it set to log to local6 priority (can be whatever).
I set it up for only 4 levels of logging to accept, 3 production, 1
testing. IMO, there shouldn't be a need for more. Plus if another
logging mechanism replaces dpkg-logger with an alternative, the new
wrapper only needs to implement those 4. The --stdout option sends the
output to screen, as well as the log mechanism (in this case syslog).
Package name is pretty obvious. It is prepended with "pkg:" in the log.

The message can either be on the command line like:

dpkg-logger foo-dev info This is some info text to log

Or on stdin like:

dpkg-logger foo-dev info << EOF
This is some multi line text
blah blah blah

If for some weird reason there is stdin and command line message text,
command line takes precedence. If the /usr/bin/logger binary is missing,
it sends all output to stdout regardless.

Here is some sample output in syslog

Jan  2 02:54:51 marcus pkg:foo-dev: This is some info text

-----    -- - -------- --------- ----  -------  -----  - - ---   --------
Ben Collins <b.m.collins@larc.nasa.gov>                  Debian GNU/Linux
UnixGroup Admin - Jordan Systems Inc.                 bcollins@debian.org
------ -- ----- - - -------   ------- -- The Choice of the GNU Generation

Attachment: dpkg-logger.pl
Description: Perl program

Reply to: