-VERSION=2.0
+VERSION=2.1
# This is root of installation tree
PREFIX=/usr/local
CC=gcc
${INSTALL} -m 755 -c libsyslog.so.${VERSION} ${LIBDIR}/syslog
${INSTALL} -m 644 -c pkgIndex.tcl ${LIBDIR}/syslog
${INSTALL} -m 644 -c syslog.n ${MANDIR}/syslog.${MANSUFFIX}
-
+tar:
+
+ tar czfC ../tclsyslog-${VERSION}.tar.gz .. tclsyslog --exclude CVS
'\" Copyright (c) 1999 Victor B. Wagner
'\"
'\"
-'\" RCS: @(#) $Id: syslog.n,v 1.2 2006-02-24 14:13:07 vitus Exp $
+'\" RCS: @(#) $Id: syslog.n,v 1.2.2.1 2006-02-24 14:14:08 vitus Exp $
'\"
'\" The definitions below are for supplemental macros used in Tcl/Tk
'\" manual entries.
'\" .UL arg1 arg2
'\" Print arg1 underlined, then print arg2 normally.
'\"
-'\" RCS: @(#) $Id: syslog.n,v 1.2 2006-02-24 14:13:07 vitus Exp $
+'\" RCS: @(#) $Id: syslog.n,v 1.2.2.1 2006-02-24 14:14:08 vitus Exp $
'\"
'\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
.if t .wh -1.3i ^B
\fB\-facility\fR \fIvalue\fR
Use specified facility instead of \fBuser\fR. Following facility are
recognized:
+.RS
.PP
\fBauthpriv\fR, \fBcron\fR, \fBdaemon\fR, \fBkernel\fR, \fBlpr\fR,
\fBmail\fR, \fBnews\fR, \fBsyslog\fR, \fBuser\fR, \fBuucp\fR, \fBlocal0\fR,
\fBlocal1\fR, \fBlocal2\fR.
+.RE
.TP 20
\fB\-ident\fR \fIstring\fR
Use given \fIstring\fR instead of \fBargv0\fB variable for ident string.
.TP 20
-\fB\-options\fR \fIinteger\fR
+\fB\-options\fR \fIlist\fR
Set syslog options such as \fBLOG_CONS\fR, \fBLOG_NDELAY\fR
-You should user numeric values of those from your system \fBsyslog.h\fR
-file, becouse I haven't got time to implement yet another hash table.
+List should contain one or more strings
+\fBCONS\fR, \fBNDELAY\fR, \fBODELAY\fR, \fBPERROR\fR, \fBPID\fR, \fBNOWAIT\fR
+.RS
+.PP
+Options \fBNDELAY\fR and \fBODELAY\fR are effectively no-op, becouse
+\fBopenlog\fR(3) call is only performed upon first message send.
+.PP
+Numeric value of options can be specified instead of list for
+compatibility with older versions. Mixing of numeric and string
+constants are not allowed.
.RE
-
+.PP
+If any options are specified, \fIpriority\fR and \fImessage\fR arguments
+can be omitted. In this case \fBsyslog\fR command only sets logging
+parameters which would be used for subsequent calls.
.SH KEYWORDS
logging, syslog
char ident[32];
Tcl_HashTable *priorities;
Tcl_HashTable *facilities;
+ Tcl_HashTable *option_names;
} SyslogInfo;
void Syslog_ListHash(Tcl_Interp *interp,Tcl_HashTable *table);
info-> logOpened=0;
}
} else if (!strncmp(Tcl_GetString(objv[i]),"-options",9)) {
- long tmp;
- if (Tcl_GetLongFromObj(interp,objv[i+1],&tmp)==TCL_ERROR)
- return TCL_ERROR;
+ int tmp;
+ int j,n;
+ Tcl_Obj *elem;
+ Tcl_HashEntry *entry;
+ Tcl_ResetResult(interp);
+ tmp=0;
+ if (Tcl_ListObjLength(interp,objv[i+1],&n)==TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ for (j=0;j<n;j++) {
+ Tcl_ListObjIndex(interp,objv[i+1],j,&elem);
+ entry=Tcl_FindHashEntry(info->option_names,Tcl_GetString(elem));
+ if (!entry) {
+ if (n!=1 || Tcl_GetIntFromObj(interp,elem,&tmp)!=TCL_OK) {
+ Tcl_AppendResult(interp,"Invalid option '",
+ Tcl_GetString(elem),"' valid ones are:",NULL);
+ Syslog_ListHash(interp,info->option_names);
+ return TCL_ERROR;
+ }
+ } else {
+ tmp |= (int) Tcl_GetHashValue(entry);
+ }
+ }
+
info->options=tmp;
if (info->logOpened) {
closelog();
AddEntry(info->priorities,"notice",LOG_NOTICE);
AddEntry(info->priorities,"info",LOG_INFO);
AddEntry(info->priorities,"debug",LOG_DEBUG);
+ info->option_names=(Tcl_HashTable *) Tcl_Alloc(sizeof(Tcl_HashTable));
+ Tcl_InitHashTable(info->option_names,TCL_STRING_KEYS);
+ AddEntry(info->option_names,"CONS",LOG_CONS);
+ AddEntry(info->option_names,"NDELAY",LOG_NDELAY);
+ AddEntry(info->option_names,"PERROR",LOG_PERROR);
+ AddEntry(info->option_names,"PID",LOG_PID);
+ AddEntry(info->option_names,"ODELAY",LOG_ODELAY);
+ AddEntry(info->option_names,"NOWAIT",LOG_NOWAIT);
Tcl_CreateObjCommand(interp,"syslog",Syslog_Log,(ClientData) info,
Syslog_Delete);
return Tcl_PkgProvide(interp,"Syslog",VERSION);