[util] change the separator in derived loggers
This commit is contained in:
parent
c5b22a0175
commit
7d2c536d82
|
@ -5,6 +5,8 @@
|
|||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
|
||||
static const char* const PREFIX_SEPARATOR = "/";
|
||||
|
||||
struct log_port;
|
||||
|
||||
struct log {
|
||||
|
@ -51,8 +53,8 @@ struct log* log_derived(struct log* parent, const char* child_suffix)
|
|||
return make_log(
|
||||
parent->derive_rgn,
|
||||
rsprintf(parent->tmp_str_rgn,
|
||||
"%s::%s",
|
||||
parent->prefix, child_suffix),
|
||||
"%s%s%s",
|
||||
parent->prefix, PREFIX_SEPARATOR, child_suffix),
|
||||
parent->port);
|
||||
}
|
||||
|
||||
|
@ -95,8 +97,7 @@ void log_writeln(struct log* lg, const char* str)
|
|||
{
|
||||
pthread_mutex_lock(&lg->port->mx);
|
||||
if (lg->port->file) {
|
||||
int pad = lg->port->padding - strlen(lg->prefix);
|
||||
fprintf(lg->port->file, "%*s[%s] %s\n", pad, "", lg->prefix, str);
|
||||
fprintf(lg->port->file, "%*s | %s\n", (int) lg->port->padding, lg->prefix, str);
|
||||
fflush(lg->port->file);
|
||||
}
|
||||
pthread_mutex_unlock(&lg->port->mx);
|
||||
|
|
Loading…
Reference in New Issue