diff --git a/extra/exports b/extra/exports index c8f814b33a20992da9e01ced7d55fb3f2a353188..2962b4e0a8024b92b2c4be7c0f784df22dce4a59 100644 --- a/extra/exports +++ b/extra/exports @@ -653,3 +653,9 @@ fiber_set_name_n authenticate user_auth_method_name port_c_create + +# picodata audit log +log_create +log_destroy +log_new +log_say diff --git a/src/lib/core/say.c b/src/lib/core/say.c index e441418faeb20667dd0f987e67e309033d6424f5..a12d811146be8881b51af52a0506506fa098c7bf 100644 --- a/src/lib/core/say.c +++ b/src/lib/core/say.c @@ -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) diff --git a/src/lib/core/say.h b/src/lib/core/say.h index 235aec751a8f4681adfafce2ece14549bb779cff..bcd70f23ee0f927439872ec1665c82c21f5634e0 100644 --- a/src/lib/core/say.h +++ b/src/lib/core/say.h @@ -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.