diff --git a/extra/exports b/extra/exports index 1c780e1719676f255001e077a7e6022e4f2d8ada..fb91cacb95f1426df7d4a20c544f6fae68765ca2 100644 --- a/extra/exports +++ b/extra/exports @@ -663,3 +663,9 @@ coio_write_timeout 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 de8ac167b4c66fe2db14302f9de000f917da9148..efe8674181dd37570f8449ae673c9f306d11aeab 100644 --- a/src/lib/core/say.c +++ b/src/lib/core/say.c @@ -649,6 +649,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. */ @@ -1390,6 +1396,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.