Skip to content

Commit

Permalink
Merge pull request HardySimpson#171 from bjoern-r/append_cr_feature
Browse files Browse the repository at this point in the history
added support for %r to insert a carriage return
  • Loading branch information
deemar authored May 6, 2020
2 parents 5c1d1b0 + 1991d6b commit bced46d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ static int zlog_spec_write_newline(zlog_spec_t * a_spec, zlog_thread_t * a_threa
return zlog_buf_append(a_buf, FILE_NEWLINE, FILE_NEWLINE_LEN);
}

static int zlog_spec_write_cr(zlog_spec_t * a_spec, zlog_thread_t * a_thread, zlog_buf_t * a_buf)
{
return zlog_buf_append(a_buf, "\r", 1);
}

static int zlog_spec_write_percent(zlog_spec_t * a_spec, zlog_thread_t * a_thread, zlog_buf_t * a_buf)
{
return zlog_buf_append(a_buf, "%", 1);
Expand Down Expand Up @@ -609,6 +614,9 @@ zlog_spec_t *zlog_spec_new(char *pattern_start, char **pattern_next, int *time_c
case 'n':
a_spec->write_buf = zlog_spec_write_newline;
break;
case 'r':
a_spec->write_buf = zlog_spec_write_cr;
break;
case 'p':
a_spec->write_buf = zlog_spec_write_pid;
break;
Expand Down

0 comments on commit bced46d

Please sign in to comment.