aboutsummaryrefslogtreecommitdiff
path: root/src/log.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2008-07-11 22:45:37 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2008-07-11 22:45:37 +0000
commiteb79907f63b7985751849d7a13e13879b6b8da9e (patch)
treeeefbe4fc827242cb32f18a1ef0a4ffb4772630cd /src/log.c
parent156b2a34fbc4dd3215c5b8cc2cc326f56dfb7df8 (diff)
downloadtagr-eb79907f63b7985751849d7a13e13879b6b8da9e.tar.gz
tagr-eb79907f63b7985751849d7a13e13879b6b8da9e.tar.bz2
Reorganize project directory layout.
* README-hacking: New file. * src: New directory * src/Makefile.am: New file. * graph.c, readconfig.c, tagr.h, log.c, report.h, queue.c: Move to src * main.c: Move to src, fix a minor bug in main. * html.l: Move to src/html.lex.l. * html.y: Move to src/html.gram.y. * lib/argcv.c, lib/argcv.h: Move to src. * config, INSTALL: Remove * README_hacking: New file. * configure.ac, Makefile.am: Update for new gnulib and new directory structure. * bootstrap: Update from gnulib. * gnulib.modules: New file. * bootstrap.conf: New file. git-svn-id: file:///svnroot/tagr/trunk@89 7c378d0d-a4e4-4a64-9229-dfce8bfd23d4
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/log.c b/src/log.c
new file mode 100644
index 0000000..950068c
--- /dev/null
+++ b/src/log.c
@@ -0,0 +1,106 @@
+/* This file is part of tagr.
+ Copyright (C) 2000, 2005, Max Bouglacoff, Sergey Poznyakoff
+
+ 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 2, 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+/* $Id: log.c,v 1.3 2005-11-23 19:32:28 gray Exp $ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <syslog.h>
+#include <tagr.h>
+
+char *progname;
+int use_stderr = 1;
+
+void
+init_syslog (char *name)
+{
+ progname = name;
+ openlog (progname, LOG_PID, LOGFACILITY);
+}
+
+int syslog_level[] = {
+ LOG_DEBUG,
+ LOG_INFO,
+ LOG_NOTICE,
+ LOG_WARNING,
+ LOG_ERR,
+ LOG_CRIT,
+};
+
+char *level_str[] = {
+ "debug",
+ "info",
+ "notice",
+ "warning",
+ "error",
+ "CRITICAL",
+};
+
+
+void
+logmsg (int level, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ if (use_stderr)
+ {
+ fprintf (stderr, "%s: %s: ", progname, level_str[level]);
+ vfprintf (stderr, fmt, ap);
+ fprintf (stderr, "\n");
+ }
+ vsyslog (syslog_level[level], fmt, ap);
+ va_end (ap);
+}
+
+void
+die (int code, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ fprintf (stderr, "%s: ", progname);
+ vfprintf (stderr, fmt, ap);
+ fprintf (stderr, "\n");
+ va_end (ap);
+ exit (code);
+}
+
+
+void
+verbose (int level, const char *fmt, ...)
+{
+ va_list ap;
+
+ if (verbose_level < level)
+ return;
+ va_start (ap, fmt);
+ printf ("%s: ", progname);
+ vprintf (fmt, ap);
+ printf ("\n");
+ va_end (ap);
+}
+

Return to:

Send suggestions and report system problems to the System administrator.