Skip to content

Commit

Permalink
refactor xlevel() -> xlog_set_level()
Browse files Browse the repository at this point in the history
  • Loading branch information
jfzheng committed Jan 11, 2016
1 parent bf21c2c commit 39ff460
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion libsim/sim_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ int slog_init(slog_t *sl, int level)
sl->b_inited = 1;
if (level != SLOG_NON) {
sl->fp[SLOG_NON] = sl->fp[SLOG_ERR] = stderr;
sl->level = level;
return slog_set_range(sl, SLOG_ERR+1, level, stdout);
}
return 0;
Expand All @@ -78,11 +79,16 @@ void xlog_reset()
slog_reset(&g_slog_obj);
}

int xlevel(int level)
int xlog_set_level(int level)
{
return slog_init(&g_slog_obj, level);
}

int xlog_get_level()
{
return g_slog_obj.level;
}

int slogv(slog_t *sl, int level, const char *prompt, const char *fmt, va_list ap)
{
FILE *fp = 0;
Expand Down
5 changes: 4 additions & 1 deletion libsim/sim_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ typedef struct simple_level_log
{
int b_inited;
void *fp[SLOG_ALL+1];
int level;
} slog_t;

int slog_set_range(slog_t *sl, int minL, int maxL, void *fp);
Expand All @@ -59,10 +60,12 @@ int slog (slog_t *sl, int level, const char *prompt, const char *fmt, ...);
int xlog_set_range(int minL, int maxL, void *fp);
int xlog_init(int level);
void xlog_reset();
int xlevel(int level);
int xlog_set_level(int level);
int xlog_get_level();
int xlogv(int level, const char *prompt, const char *fmt, va_list ap);
int xlog (int level, const char *prompt, const char *fmt, ...);

#define xlevel xlog_set_level
#define xerr(...) xlog(SLOG_ERR, "err", __VA_ARGS__)
#define xwarn(...) xlog(SLOG_WARN, "warn", __VA_ARGS__)
#define xdbg(...) xlog(SLOG_DBG, "dbg", __VA_ARGS__)
Expand Down

0 comments on commit 39ff460

Please sign in to comment.