LOGGING: Pass the log level down to the log target output function

This will be required for mapping osmocore log levels to syslog priorities.
This commit is contained in:
Harald Welte 2011-02-17 15:52:39 +01:00
parent 76681bafa8
commit 76e72abe32
3 changed files with 10 additions and 7 deletions

View File

@ -95,7 +95,8 @@ struct log_target {
} tgt_vty; } tgt_vty;
}; };
void (*output) (struct log_target *target, const char *string); void (*output) (struct log_target *target, unsigned int level,
const char *string);
}; };
/* use the above macros */ /* use the above macros */

View File

@ -124,8 +124,8 @@ static const char* color(int subsys)
} }
static void _output(struct log_target *target, unsigned int subsys, static void _output(struct log_target *target, unsigned int subsys,
char *file, int line, int cont, const char *format, unsigned int level, char *file, int line, int cont,
va_list ap) const char *format, va_list ap)
{ {
char col[30]; char col[30];
char sub[30]; char sub[30];
@ -167,7 +167,7 @@ static void _output(struct log_target *target, unsigned int subsys,
snprintf(final, sizeof(final), "%s%s%s%s%s", col, tim, sub, buf, snprintf(final, sizeof(final), "%s%s%s%s%s", col, tim, sub, buf,
target->use_color ? "\033[0;m" : ""); target->use_color ? "\033[0;m" : "");
final[sizeof(final)-1] = '\0'; final[sizeof(final)-1] = '\0';
target->output(target, final); target->output(target, level, final);
} }
@ -212,7 +212,7 @@ static void _logp(unsigned int subsys, int level, char *file, int line,
* with the same va_list will segfault */ * with the same va_list will segfault */
va_list bp; va_list bp;
va_copy(bp, ap); va_copy(bp, ap);
_output(tar, subsys, file, line, cont, format, bp); _output(tar, subsys, level, file, line, cont, format, bp);
va_end(bp); va_end(bp);
} }
} }
@ -294,7 +294,8 @@ void log_set_category_filter(struct log_target *target, int category,
target->categories[category].loglevel = level; target->categories[category].loglevel = level;
} }
static void _file_output(struct log_target *target, const char *log) static void _file_output(struct log_target *target, unsigned int level,
const char *log)
{ {
fprintf(target->tgt_file.out, "%s", log); fprintf(target->tgt_file.out, "%s", log);
fflush(target->tgt_file.out); fflush(target->tgt_file.out);

View File

@ -35,7 +35,8 @@
extern const struct log_info *osmo_log_info; extern const struct log_info *osmo_log_info;
static void _vty_output(struct log_target *tgt, const char *line) static void _vty_output(struct log_target *tgt,
unsigned int level, const char *line)
{ {
struct vty *vty = tgt->tgt_vty.vty; struct vty *vty = tgt->tgt_vty.vty;
vty_out(vty, "%s", line); vty_out(vty, "%s", line);