Browse Source

[core] inline buffer in log_error_st errh

personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
3e8cdb2e54
  1. 15
      src/log.c
  2. 8
      src/log.h

15
src/log.c

@ -159,14 +159,14 @@ log_buffer_vprintf (buffer * const b,
static void
log_error_va_list_impl (const log_error_st * const errh,
log_error_va_list_impl (log_error_st * const errh,
const char * const filename,
const unsigned int line,
const char * const fmt, va_list ap,
const int perr)
{
const int errnum = errno;
buffer * const b = errh->b;
buffer * const b = &errh->b;
if (-1 == log_buffer_prepare(errh, filename, line, b)) return;
log_buffer_vprintf(b, fmt, ap);
if (perr) {
@ -179,7 +179,7 @@ log_error_va_list_impl (const log_error_st * const errh,
void
log_error(const log_error_st * const errh,
log_error(log_error_st * const errh,
const char * const filename, const unsigned int line,
const char *fmt, ...)
{
@ -191,7 +191,7 @@ log_error(const log_error_st * const errh,
void
log_perror (const log_error_st * const errh,
log_perror (log_error_st * const errh,
const char * const filename, const unsigned int line,
const char * const fmt, ...)
{
@ -203,7 +203,7 @@ log_perror (const log_error_st * const errh,
void
log_error_multiline_buffer (const log_error_st * const restrict errh,
log_error_multiline_buffer (log_error_st * const restrict errh,
const char * const restrict filename,
const unsigned int line,
const buffer * const restrict multiline,
@ -212,7 +212,7 @@ log_error_multiline_buffer (const log_error_st * const restrict errh,
if (multiline->used < 2) return;
const int errnum = errno;
buffer * const b = errh->b;
buffer * const b = &errh->b;
if (-1 == log_buffer_prepare(errh, filename, line, b)) return;
va_list ap;
@ -243,7 +243,6 @@ log_error_st_init (void)
force_assert(errh);
errh->errorlog_fd = STDERR_FILENO;
errh->errorlog_mode = ERRORLOG_FD;
errh->b = buffer_init();
return errh;
}
@ -252,6 +251,6 @@ void
log_error_st_free (log_error_st *errh)
{
if (NULL == errh) return;
buffer_free(errh->b);
free(errh->b.ptr);
free(errh);
}

8
src/log.h

@ -15,7 +15,7 @@ ssize_t write_all(int fd, const void* buf, size_t count);
struct log_error_st {
enum { ERRORLOG_FILE, ERRORLOG_FD, ERRORLOG_SYSLOG, ERRORLOG_PIPE } errorlog_mode;
int errorlog_fd;
buffer *b;
buffer b;
};
__attribute_cold__
@ -26,14 +26,14 @@ void log_error_st_free (log_error_st *errh);
__attribute_cold__
__attribute_format__((__printf__, 4, 5))
void log_error(const log_error_st *errh, const char *filename, unsigned int line, const char *fmt, ...);
void log_error(log_error_st *errh, const char *filename, unsigned int line, const char *fmt, ...);
__attribute_cold__
__attribute_format__((__printf__, 4, 5))
void log_perror(const log_error_st *errh, const char *filename, unsigned int line, const char *fmt, ...);
void log_perror(log_error_st *errh, const char *filename, unsigned int line, const char *fmt, ...);
__attribute_cold__
__attribute_format__((__printf__, 5, 6))
void log_error_multiline_buffer(const log_error_st *errh, const char *filename, unsigned int line, const buffer *multiline, const char *fmt, ...);
void log_error_multiline_buffer(log_error_st *errh, const char *filename, unsigned int line, const buffer *multiline, const char *fmt, ...);
#endif

Loading…
Cancel
Save