2 * Copyright (C) 1999, 2000, 2001, 2004, 2006 Free Software Foundation, Inc.
4 * This file is part of JNLIB.
6 * JNLIB is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 3 of
9 * the License, or (at your option) any later version.
11 * JNLIB is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef LIBJNLIB_LOGGING_H
21 #define LIBJNLIB_LOGGING_H
26 /* Flag values for log_set_prefix. */
27 #define JNLIB_LOG_WITH_PREFIX 1
28 #define JNLIB_LOG_WITH_TIME 2
29 #define JNLIB_LOG_WITH_PID 4
30 #define JNLIB_LOG_RUN_DETACHED 256
32 int log_get_errorcount (int clear
);
33 void log_inc_errorcount (void);
34 void log_set_file( const char *name
);
35 void log_set_fd (int fd
);
36 void log_set_get_tid_callback (unsigned long (*cb
)(void));
37 void log_set_prefix (const char *text
, unsigned int flags
);
38 const char *log_get_prefix (unsigned int *flags
);
39 int log_test_fd (int fd
);
41 FILE *log_get_stream (void);
43 #ifdef JNLIB_GCC_M_FUNCTION
44 void bug_at( const char *file
, int line
, const char *func
) JNLIB_GCC_A_NR
;
45 # define BUG() bug_at( __FILE__ , __LINE__, __FUNCTION__ )
47 void bug_at( const char *file
, int line
);
48 # define BUG() bug_at( __FILE__ , __LINE__ )
51 /* To avoid mandatory inclusion of stdarg and other stuff, do it only
52 if explicitly requested to do so. */
53 #ifdef JNLIB_NEED_LOG_LOGV
55 enum jnlib_log_levels
{
65 void log_logv (int level
, const char *fmt
, va_list arg_ptr
);
66 #endif /*JNLIB_NEED_LOG_LOGV*/
69 void log_bug( const char *fmt
, ... ) JNLIB_GCC_A_NR_PRINTF(1,2);
70 void log_fatal( const char *fmt
, ... ) JNLIB_GCC_A_NR_PRINTF(1,2);
71 void log_error( const char *fmt
, ... ) JNLIB_GCC_A_PRINTF(1,2);
72 void log_info( const char *fmt
, ... ) JNLIB_GCC_A_PRINTF(1,2);
73 void log_debug( const char *fmt
, ... ) JNLIB_GCC_A_PRINTF(1,2);
74 void log_printf( const char *fmt
, ... ) JNLIB_GCC_A_PRINTF(1,2);
76 /* Print a hexdump of BUFFER. With TEXT passes as NULL print just the
77 raw dump, with TEXT being an empty string, print a trailing
78 linefeed, otherwise print an entire debug line with TEXT followed
79 by the hexdump and a final LF. */
80 void log_printhex (const char *text
, const void *buffer
, size_t length
);
83 #endif /*LIBJNLIB_LOGGING_H*/