1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
/*
* Copyright (c) 2000-2001 Silicon Graphics, Inc.
* All Rights Reserved.
*
* 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.
*
* This program is distributed in the hope that it would 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 the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MLOG_H
#define MLOG_H
/* mlog.[hc] - message logging abstraction
*/
#include <stdarg.h>
#include "types.h"
/* defined log levels - msg will be logged only if cmdline -v arg
* is greater than or equal to its level.
*/
#define MLOG_NORMAL 0 /* OLD */
#define MLOG_SILENT 0 /* NEW */
#define MLOG_VERBOSE 1
#define MLOG_TRACE 2
#define MLOG_DEBUG 3
#define MLOG_NITTY 4
#define MLOG_LEVELMASK 0xff
/* modifier flags for the level - only the first is generally exported
*/
#define MLOG_BARE 0x010000 /* don't print preamble */
#define MLOG_NOTE 0x020000 /* use NOTE format */
#define MLOG_WARNING 0x040000 /* use WARNING format */
#define MLOG_ERROR 0x080000 /* use ERROR format */
#define MLOG_NOLOCK 0x100000 /* do not attempt to obtain mlog lock */
/* subsystem ids: allows per-subsystem control of log level.
* use to index mlog_level_ss.
*/
#define MLOG_SS_GEN 0 /* default if no subsystem specified */
#define MLOG_SS_PROC 1 /* process/thread-related */
#define MLOG_SS_DRIVE 2 /* I/O-related */
#define MLOG_SS_MEDIA 3 /* media-related */
#define MLOG_SS_INV 4 /* media inventory */
#ifdef DUMP
#define MLOG_SS_INOMAP 5 /* dump inode number map */
#endif /* DUMP */
#ifdef RESTORE
#define MLOG_SS_TREE 5 /* restore tree */
#endif /* RESTORE */
#define MLOG_SS_EXCLFILES 6 /* list excluded files */
#define MLOG_SS_CNT 7 /* NOTE! bump this when adding ss */
#define MLOG_SS_SHIFT 8
#define MLOG_SS_MASK (0xff << MLOG_SS_SHIFT)
/* subsystem flags - NOTE! only one may be specified! use in mlog(first arg)
*/
#define MLOG_ALL (MLOG_SS_GEN << MLOG_SS_SHIFT)
#define MLOG_PROC (MLOG_SS_PROC << MLOG_SS_SHIFT)
#define MLOG_DRIVE (MLOG_SS_DRIVE << MLOG_SS_SHIFT)
#define MLOG_MEDIA (MLOG_SS_MEDIA << MLOG_SS_SHIFT)
#define MLOG_INV (MLOG_SS_INV << MLOG_SS_SHIFT)
#ifdef DUMP
#define MLOG_INOMAP (MLOG_SS_INOMAP << MLOG_SS_SHIFT)
#endif /* DUMP */
#ifdef RESTORE
#define MLOG_TREE (MLOG_SS_TREE << MLOG_SS_SHIFT)
#endif /* RESTORE */
#define MLOG_EXCLFILES (MLOG_SS_EXCLFILES << MLOG_SS_SHIFT)
/* mlog_level - set during initialization, exported to facilitate
* message logging decisions. one per subsystem (see above)
*/
extern int mlog_level_ss[MLOG_SS_CNT];
/* made external so main.c sigint dialog can change
*/
extern int mlog_showlevel;
extern int mlog_showss;
extern int mlog_timestamp;
/* mlog_ss_name - so main.c sigint dialog can allow changes
*/
extern char *mlog_ss_names[MLOG_SS_CNT];
/* initializes the mlog abstraction. split into two phases to
* unravel some initialization sequencing problems.
*/
extern void mlog_init0(void);
extern bool_t mlog_init1(int argc, char *argv[]);
extern bool_t mlog_init2(void);
/* post-initialization, to tell mlog how many streams
*/
extern void mlog_tell_streamcnt(size_t streamcnt);
/* override the -v option
*/
void mlog_override_level(int levelarg);
/* vprintf-based message format
*/
extern void mlog(int level, char *fmt, ...);
extern void mlog_va(int levelarg, char *fmt, va_list args);
#define mlog_exit(e, r) _mlog_exit(__FILE__, __LINE__, (e), (r))
extern int _mlog_exit(const char *file, int line, int exit_code, rv_t return_code);
#define mlog_exit_hint(r) _mlog_exit_hint(__FILE__, __LINE__, (r))
extern void _mlog_exit_hint(const char *file, int line, rv_t rv);
extern rv_t mlog_get_hint(void);
extern void mlog_exit_flush(void);
/* the following calls are exported ONLY to dlog.c!
*/
extern void mlog_lock(void);
extern void mlog_unlock(void);
/* fold_t - a character string made to look like a "fold here"
*/
#define FOLD_LEN 79
typedef char fold_t[FOLD_LEN + 1];
extern void fold_init(fold_t fold, char *infostr, char c);
#endif /* MLOG_H */
|