Skip to content
Snippets Groups Projects
Commit d0a6788e authored by Dmitry Ivanov's avatar Dmitry Ivanov Committed by Dmitry Rodionov
Browse files

feat: Add new methods to `say` for FFI use cases

This patch helps us create and write to non-default
loggers provided by `say.h`. We'll use this mainly
for audit log in picodata.

NO_DOC=internal
NO_TEST=internal
NO_CHANGELOG=internal
parent 21904219
No related branches found
No related tags found
1 merge request!127move to support only one branch
Pipeline #26363 passed
......@@ -657,3 +657,9 @@ coio_write_timeout
authenticate
user_auth_method_name
port_c_create
# picodata audit log
log_create
log_destroy
log_new
log_say
......@@ -660,6 +660,12 @@ log_syslog_init(struct log *log, const char *init_str)
return 0;
}
struct log *
log_new(void)
{
return xmalloc(sizeof(struct log));
}
/**
* Initialize logging subsystem to use in daemon mode.
*/
......@@ -1401,6 +1407,18 @@ log_vsay(struct log *log, int level, bool check_level, const char *module,
return total;
}
int
log_say(struct log *log, int level, const char *filename,
int line, const char *error, const char *format, ...)
{
va_list ap;
va_start(ap, format);
int total = log_vsay(log, level, true, NULL, filename, line, error,
format, ap);
va_end(ap);
return total;
}
void
say_set_stderr_callback(say_stderr_callback_t before,
say_stderr_callback_t after)
......
......@@ -186,6 +186,16 @@ struct log {
struct rlist in_log_list;
};
/**
* Allocate a new uninitialized log object.
* To initialize the object one must call log_create()
* before doing log_say(). To deallocate the object use
* log_destroy() and free().
* @return pointer to log object (allocation failure is fatal)
*/
struct log *
log_new(void);
/**
* Create a new log object.
* @param log log to initialize
......@@ -207,17 +217,9 @@ log_vsay(struct log *log, int level, bool check_level, const char *module,
va_list ap);
/** Perform log write. */
static inline int
int
log_say(struct log *log, int level, const char *filename,
int line, const char *error, const char *format, ...)
{
va_list ap;
va_start(ap, format);
int total = log_vsay(log, level, true, NULL, filename, line, error,
format, ap);
va_end(ap);
return total;
}
int line, const char *error, const char *format, ...);
/**
* Default logger type info.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment