1 /* $NetBSD: log.h,v 1.1.1.1 2015/07/08 15:37:48 christos Exp $ */ 2 3 /***************************************************************** 4 ** 5 ** @(#) log.h (c) June 2008 Holger Zuleger hznet.de 6 ** 7 ** Copyright (c) June 2008, Holger Zuleger HZnet. All rights reserved. 8 ** 9 ** This software is open source. 10 ** 11 ** Redistribution and use in source and binary forms, with or without 12 ** modification, are permitted provided that the following conditions 13 ** are met: 14 ** 15 ** Redistributions of source code must retain the above copyright notice, 16 ** this list of conditions and the following disclaimer. 17 ** 18 ** Redistributions in binary form must reproduce the above copyright notice, 19 ** this list of conditions and the following disclaimer in the documentation 20 ** and/or other materials provided with the distribution. 21 ** 22 ** Neither the name of Holger Zuleger HZnet nor the names of its contributors may 23 ** be used to endorse or promote products derived from this software without 24 ** specific prior written permission. 25 ** 26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 ** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 ** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 30 ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 ** POSSIBILITY OF SUCH DAMAGE. 37 ** 38 *****************************************************************/ 39 #ifndef LOG_H 40 # define LOG_H 41 # include <sys/types.h> 42 # include <stdarg.h> 43 # include <stdio.h> 44 # include <time.h> 45 # include <syslog.h> 46 47 #ifndef LOG_FNAMETMPL 48 # define LOG_FNAMETMPL "/zkt-%04d-%02d-%02dT%02d%02d%02dZ+log" 49 #endif 50 51 #ifndef LOG_DOMAINTMPL 52 # define LOG_DOMAINTMPL "zktlog-%s" 53 #endif 54 55 56 typedef enum { 57 LG_NONE = 0, 58 LG_DEBUG, 59 LG_INFO, 60 LG_NOTICE, 61 LG_WARNING, 62 LG_ERROR, 63 LG_FATAL 64 } lg_lvl_t; 65 66 extern lg_lvl_t lg_str2lvl (const char *name); 67 extern int lg_str2syslog (const char *facility); 68 extern const char *lg_lvl2str (lg_lvl_t level); 69 extern lg_lvl_t lg_lvl2syslog (lg_lvl_t level); 70 extern long lg_geterrcnt (void); 71 extern long lg_seterrcnt (long value); 72 extern long lg_reseterrcnt (void); 73 extern int lg_open (const char *progname, const char *facility, const char *syslevel, const char *path, const char *file, const char *filelevel); 74 extern int lg_close (void); 75 extern int lg_zone_start (const char *dir, const char *domain); 76 extern int lg_zone_end (void); 77 extern void lg_args (lg_lvl_t level, int argc, char * const argv[]); 78 extern void lg_mesg (int level, char *fmt, ...); 79 #endif 80