Skip to content

Commit

Permalink
refactor id with struct pl
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Sep 10, 2023
1 parent 73e29fa commit 33843e7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions include/re_dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ enum dbg_flags {
* @param len String length
* @param arg Handler argument
*/
typedef void(dbg_print_h)(uint32_t id, int level, const char *p, size_t len,
typedef void(dbg_print_h)(struct pl *id, int level, const char *p, size_t len,
void *arg);

void dbg_init(int level, enum dbg_flags flags);
void dbg_close(void);
int dbg_logfile_set(const char *name);
void dbg_handler_set(dbg_print_h *ph, void *arg);
void dbg_printf(int level, const char *fmt, ...);
void dbg_printf_id(uint32_t id, int level, const char *fmt, ...);
void dbg_printf_id(struct pl *id, int level, const char *fmt, ...);
const char *dbg_level_str(int level);

#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions src/async/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <re_thread.h>
#include <re_async.h>
#include <re_tmr.h>
#include <re_fmt.h>
#include <re_mqueue.h>

#define DEBUG_MODULE "async"
Expand Down
14 changes: 7 additions & 7 deletions src/dbg/dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void dbg_handler_set(dbg_print_h *ph, void *arg)


/* NOTE: This function should not allocate memory */
static void dbg_vprintf(uint32_t id, int level, const char *fmt, va_list ap)
static void dbg_vprintf(struct pl *id, int level, const char *fmt, va_list ap)
{
dbg_lock();

Expand Down Expand Up @@ -171,8 +171,8 @@ static void dbg_vprintf(uint32_t id, int level, const char *fmt, va_list ap)
(void)re_fprintf(stderr, "[%09llu] ", ticks - dbg.tick);
}

if (id)
(void)re_fprintf(stderr, "{%u} ", id);
if (pl_isset(id))
(void)re_fprintf(stderr, "{%r} ", id);

(void)re_vfprintf(stderr, fmt, ap);

Expand All @@ -184,7 +184,7 @@ static void dbg_vprintf(uint32_t id, int level, const char *fmt, va_list ap)


/* Formatted output to print handler and/or logfile */
static void dbg_fmt_vprintf(uint32_t id, int level, const char *fmt,
static void dbg_fmt_vprintf(struct pl *id, int level, const char *fmt,
va_list ap)
{
char buf[256];
Expand Down Expand Up @@ -230,11 +230,11 @@ void dbg_printf(int level, const char *fmt, ...)
va_list ap;

va_start(ap, fmt);
dbg_vprintf(0, level, fmt, ap);
dbg_vprintf(NULL, level, fmt, ap);
va_end(ap);

va_start(ap, fmt);
dbg_fmt_vprintf(0, level, fmt, ap);
dbg_fmt_vprintf(NULL, level, fmt, ap);
va_end(ap);
}

Expand All @@ -245,7 +245,7 @@ void dbg_printf(int level, const char *fmt, ...)
* @param level Debug level
* @param fmt Formatted string
*/
void dbg_printf_id(uint32_t id, int level, const char *fmt, ...)
void dbg_printf_id(struct pl *id, int level, const char *fmt, ...)
{
va_list ap;

Expand Down
1 change: 1 addition & 0 deletions src/hmac/hmac_sha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <mbedtls/error.h>
#endif
#include <re_hmac.h>
#include <re_fmt.h>


#define DEBUG_MODULE "hmac"
Expand Down
1 change: 1 addition & 0 deletions src/list/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2010 Creytiv.com
*/
#include <re_types.h>
#include <re_fmt.h>
#include <re_list.h>
#include <re_mem.h>

Expand Down
2 changes: 1 addition & 1 deletion test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void usage(void)
#endif


static void dbg_handler(uint32_t id, int level, const char *p, size_t len,
static void dbg_handler(struct pl *id, int level, const char *p, size_t len,
void *arg)
{
(void)level;
Expand Down

0 comments on commit 33843e7

Please sign in to comment.