File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / mpd / src / log.h
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:39:23 2021 UTC (4 years ago) by misho
Branches: mpd, MAIN
CVS tags: v5_9p16, v5_9, HEAD
mpd 5.9

    1: 
    2: /*
    3:  * log.h
    4:  *
    5:  * Written by Toshiharu OHNO <tony-o@iij.ad.jp>
    6:  * Copyright (c) 1993, Internet Initiative Japan, Inc. All rights reserved.
    7:  * See ``COPYRIGHT.iij''
    8:  * 
    9:  * Rewritten by Archie Cobbs <archie@freebsd.org>
   10:  * Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved.
   11:  * See ``COPYRIGHT.whistle''
   12:  */
   13: 
   14: #ifndef _LG_H_
   15: #define	_LG_H_
   16: 
   17: #include "mbuf.h"
   18: 
   19: #include <stdio.h>
   20: 
   21: /*
   22:  * DEFINITIONS
   23:  */
   24: 
   25:   enum
   26:   {
   27:     LG_I_ALWAYS = 0,
   28:     LG_I_BUND,
   29:     LG_I_BUND2,
   30:     LG_I_LINK,
   31:     LG_I_REP,
   32:     LG_I_CHAT,
   33:     LG_I_CHAT2,
   34:     LG_I_IFACE,
   35:     LG_I_IFACE2,
   36:     LG_I_LCP,
   37:     LG_I_LCP2,
   38:     LG_I_AUTH,
   39:     LG_I_AUTH2,
   40:     LG_I_IPCP,
   41:     LG_I_IPCP2,
   42:     LG_I_IPV6CP,
   43:     LG_I_IPV6CP2,
   44:     LG_I_CCP,
   45:     LG_I_CCP2,
   46:     LG_I_ECP,
   47:     LG_I_ECP2,
   48:     LG_I_FSM,
   49:     LG_I_ECHO,
   50:     LG_I_PHYS,
   51:     LG_I_PHYS2,
   52:     LG_I_PHYS3,
   53:     LG_I_FRAME,
   54:     LG_I_RADIUS,
   55:     LG_I_RADIUS2,
   56:     LG_I_CONSOLE,
   57:     LG_I_EVENTS
   58:   };
   59: 
   60: /* Definition of log options */
   61: 
   62:   #define LG_BUND		(1 << LG_I_BUND)
   63:   #define LG_BUND2		(1 << LG_I_BUND2)
   64:   #define LG_LINK		(1 << LG_I_LINK)
   65:   #define LG_REP		(1 << LG_I_REP)
   66:   #define LG_CHAT		(1 << LG_I_CHAT)
   67:   #define LG_CHAT2		(1 << LG_I_CHAT2)
   68:   #define LG_IFACE		(1 << LG_I_IFACE)
   69:   #define LG_IFACE2		(1 << LG_I_IFACE2)
   70:   #define LG_LCP		(1 << LG_I_LCP)
   71:   #define LG_LCP2		(1 << LG_I_LCP2)
   72:   #define LG_AUTH		(1 << LG_I_AUTH)
   73:   #define LG_AUTH2		(1 << LG_I_AUTH2)
   74:   #define LG_IPCP		(1 << LG_I_IPCP)
   75:   #define LG_IPCP2		(1 << LG_I_IPCP2)
   76:   #define LG_IPV6CP		(1 << LG_I_IPV6CP)
   77:   #define LG_IPV6CP2		(1 << LG_I_IPV6CP2)
   78:   #define LG_CCP		(1 << LG_I_CCP)
   79:   #define LG_CCP2		(1 << LG_I_CCP2)
   80:   #define LG_ECP		(1 << LG_I_ECP)
   81:   #define LG_ECP2		(1 << LG_I_ECP2)
   82:   #define LG_FSM		(1 << LG_I_FSM)
   83:   #define LG_ECHO		(1 << LG_I_ECHO)
   84:   #define LG_PHYS		(1 << LG_I_PHYS)
   85:   #define LG_PHYS2		(1 << LG_I_PHYS2)
   86:   #define LG_PHYS3		(1 << LG_I_PHYS3)
   87:   #define LG_FRAME		(1 << LG_I_FRAME)
   88:   #define LG_RADIUS		(1 << LG_I_RADIUS)
   89:   #define LG_RADIUS2		(1 << LG_I_RADIUS2)
   90:   #define LG_CONSOLE		(1 << LG_I_CONSOLE)
   91:   #define LG_ALWAYS		(1 << LG_I_ALWAYS)
   92:   #define LG_EVENTS		(1 << LG_I_EVENTS)
   93: 
   94:   #define LG_ERR		(LG_ALWAYS)
   95: 
   96: /* Default options at startup */
   97: 
   98:   #define LG_DEFAULT_OPT	(0			\
   99: 				| LG_BUND		\
  100: 				| LG_LINK		\
  101: 				| LG_REP		\
  102: 			        | LG_IFACE		\
  103: 			        | LG_CONSOLE		\
  104: 			        | LG_CHAT		\
  105: 			        | LG_LCP		\
  106: 			        | LG_IPCP		\
  107: 			        | LG_IPV6CP		\
  108: 			        | LG_CCP		\
  109: 			        | LG_ECP		\
  110: 			        | LG_AUTH		\
  111: 			        | LG_RADIUS		\
  112: 			        | LG_FSM		\
  113: 			        | LG_PHYS		\
  114: 				)
  115: 
  116:   #define Log(lev, args)	do {				\
  117: 				  if (gLogOptions & (lev))	\
  118: 				    LogPrintf args;		\
  119: 				} while (0)
  120: 
  121:   #define Log2(lev, args)	do {				\
  122: 				  if (gLogOptions & (lev))	\
  123: 				    LogPrintf2 args;		\
  124: 				} while (0)
  125: 
  126:   #define LogDumpBuf(lev, buf, len, fmt, args...) do {		\
  127: 				  if (gLogOptions & (lev))	\
  128: 				    LogDumpBuf2(buf, len, fmt, ##args);	\
  129: 				} while (0)
  130: 
  131:   #define LogDumpBp(lev, bp, fmt, args...) do {			\
  132: 				  if (gLogOptions & (lev))	\
  133: 				    LogDumpBp2(bp, fmt, ##args);\
  134: 				} while (0)
  135: 
  136: /*
  137:  * VARIABLES
  138:  */
  139: 
  140:   extern int	gLogOptions;
  141: #ifdef SYSLOG_FACILITY
  142:   extern char	gSysLogIdent[32];
  143: #endif
  144: 
  145: /*
  146:  * FUNCTIONS
  147:  */
  148: 
  149:   extern int	LogOpen(void);
  150:   extern void	LogClose(void);
  151:   extern void	LogPrintf(const char *fmt, ...) __printflike(1, 2);
  152:   extern void	vLogPrintf(const char *fmt, va_list args);
  153:   extern void	LogPrintf2(const char *fmt, ...) __printflike(1, 2);
  154:   extern int	LogCommand(Context ctx, int ac, const char *const av[], const void *arg);
  155:   extern void	LogDumpBuf2(const u_char *buf, int len,
  156: 			const char *fmt, ...) __printflike(3, 4);
  157:   extern void	LogDumpBp2(Mbuf bp, const char *fmt, ...)
  158: 			__printflike(2, 3);
  159:   extern void	Perror(const char *fmt, ...) __printflike(1, 2);
  160: 
  161: #endif
  162: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>