New prototype for log_redirect() and log_set_levels()

This commit is contained in:
Christophe Grenier 2020-08-08 12:22:55 +02:00
parent 745ced8e14
commit 4700325701
2 changed files with 27 additions and 5 deletions

View file

@ -49,13 +49,18 @@
static FILE *log_handle=NULL;
static int f_status=0;
/*@
@ requires valid_read_string(_format);
@*/
static int log_handler(const char *_format, va_list ap) __attribute__((format(printf, 1, 0)));
/* static unsigned int log_levels=LOG_LEVEL_DEBUG|LOG_LEVEL_TRACE|LOG_LEVEL_QUIET|LOG_LEVEL_INFO|LOG_LEVEL_VERBOSE|LOG_LEVEL_PROGRESS|LOG_LEVEL_WARNING|LOG_LEVEL_ERROR|LOG_LEVEL_PERROR|LOG_LEVEL_CRITICAL; */
static unsigned int log_levels=LOG_LEVEL_TRACE|LOG_LEVEL_QUIET|LOG_LEVEL_INFO|LOG_LEVEL_VERBOSE|LOG_LEVEL_PROGRESS|LOG_LEVEL_WARNING|LOG_LEVEL_ERROR|LOG_LEVEL_PERROR|LOG_LEVEL_CRITICAL;
int log_set_levels(const unsigned int levels)
unsigned int log_set_levels(const unsigned int levels)
{
const int old_levels=log_levels;
const unsigned int old_levels=log_levels;
log_levels=levels;
return old_levels;
}
@ -160,7 +165,7 @@ int log_close(void)
return f_status;
}
int log_redirect(unsigned int level, const char *format, ...)
int log_redirect(const unsigned int level, const char *format, ...)
{
if((log_levels & level)==0)
return 0;

View file

@ -25,12 +25,29 @@
extern "C" {
#endif
int log_set_levels(const unsigned int levels);
unsigned int log_set_levels(const unsigned int levels);
/*@
@ requires valid_read_string(default_filename);
@ requires \valid(errsv);
@ requires separation: \separated(default_filename, errsv);
@*/
FILE *log_open(const char*default_filename, const int mode, int *errsv);
/*@
@ requires \valid_read(default_filename);
@ requires \valid(errsv);
@ requires separation: \separated(default_filename, errsv);
@*/
FILE *log_open_default(const char*default_filename, const int mode, int *errsv);
int log_flush(void);
int log_close(void);
int log_redirect(unsigned int level, const char *format, ...) __attribute__((format(printf, 2, 3)));
/*@
@ requires valid_read_string(format);
@*/
int log_redirect(const unsigned int level, const char *format, ...) __attribute__((format(printf, 2, 3)));
void dump_log(const void *nom_dump,unsigned int lng);
void dump2_log(const void *dump_1, const void *dump_2,const unsigned int lng);