Commit 7bb00d3a authored by Shawn Webb's avatar Shawn Webb
Browse files

Support logging flags


Signed-off-by: Shawn Webb's avatarShawn Webb <shawn.webb@hardenedbsd.org>
parent e148832c
......@@ -44,6 +44,7 @@ typedef struct _sqlite_ctx sqlite_ctx_t;
#define LATTUTIL_LOG_VERBOSITY_DEFAULT 1000
#define LATTUTIL_LOG_DEFAULT_NAME "lattutil"
#define LATTUTIL_LOG_FLAG_TIME 0x1
#define LATTUTIL_SQL_FLAG_LOG_QUERY 0x1
......@@ -70,6 +71,7 @@ typedef struct _llconfig {
typedef struct _lllog {
uint64_t ll_version;
uint64_t ll_flags;
int ll_verbosity;
char *ll_path;
void *ll_aux;
......@@ -214,9 +216,10 @@ int64_t find_config_int(const ucl_object_t *, const char *, int64_t);
*
* @param Path
* @param Verbosity
* @param Flags
* @return Pointer to the logging object
*/
lattutil_log_t *lattutil_log_init(char *, int);
lattutil_log_t *lattutil_log_init(char *, int, uint64_t);
/**
* Free logger
......@@ -235,6 +238,32 @@ void lattutil_log_free(lattutil_log_t **);
*/
uint64_t lattutil_log_get_version(lattutil_log_t *);
/**
* Get the currently-set flags of the log object
*
* @param The log object
* @return The flags
*/
uint64_t lattutil_log_get_flags(lattutil_log_t *);
/**
* Set the log object's flags
*
* @param The log object
* @param The flags
* @return The previous flags
*/
uint64_t lattutil_log_set_flags(lattutil_log_t *, uint64_t);
/**
* Set a given flag in the log object
*
* @param The log object
* @param The flag
* @return The previous flags
*/
uint64_t lattutil_log_set_flag(lattutil_log_t *, uint64_t);
/**
* Initialize syslog-based logging
*
......
......@@ -33,7 +33,7 @@
EXPORTED_SYM
lattutil_log_t *
lattutil_log_init(char *path, int verbosity)
lattutil_log_init(char *path, int verbosity, uint64_t flags)
{
lattutil_log_t *res;
......@@ -43,6 +43,7 @@ lattutil_log_init(char *path, int verbosity)
}
res->ll_version = LATTUTIL_VERSION;
res->ll_flags = flags;
res->ll_verbosity = (verbosity == -1) ? LATTUTIL_LOG_VERBOSITY_DEFAULT :
verbosity;
......@@ -92,6 +93,50 @@ lattutil_log_get_version(lattutil_log_t *logp)
return (logp->ll_version);
}
EXPORTED_SYM
uint64_t
lattutil_log_get_flags(lattutil_log_t *logp)
{
if (logp == NULL) {
return (0);
}
return (logp->ll_flags);
}
EXPORTED_SYM
uint64_t
lattutil_log_set_flags(lattutil_log_t *logp, uint64_t flags)
{
uint64_t orig;
if (logp == NULL) {
return (0);
}
orig = logp->ll_flags;
logp->ll_flags = flags;
return (orig);
}
EXPORTED_SYM
uint64_t
lattutil_log_set_flag(lattutil_log_t *logp, uint64_t flag)
{
uint64_t orig;
if (logp == NULL) {
return (0);
}
orig = logp->ll_flags;
logp->ll_flags |= flag;
return (orig);
}
EXPORTED_SYM
bool
lattutil_log_ready(lattutil_log_t *logp)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment