diff options
author | swapnili <swapnil.ingle@nutanix.com> | 2020-11-25 17:24:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-25 17:24:28 +0100 |
commit | adc65938c8771172b80d6d523f7b1608ba3f8d46 (patch) | |
tree | 1b8eb890516c644e14eb4199cd6d1cb9f340755b /lib | |
parent | 7e48fee45f938bdb1f562155a9159e950eba4a5f (diff) | |
download | libvfio-user-adc65938c8771172b80d6d523f7b1608ba3f8d46.zip libvfio-user-adc65938c8771172b80d6d523f7b1608ba3f8d46.tar.gz libvfio-user-adc65938c8771172b80d6d523f7b1608ba3f8d46.tar.bz2 |
Split log setup from lm_create_ctx() to lm_setup_log() (#126)
* Split log setup from lm_create_ctx() to lm_setup_log()
Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/muser_ctx.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/muser_ctx.c b/lib/muser_ctx.c index 77d4f7b..fd16bed 100644 --- a/lib/muser_ctx.c +++ b/lib/muser_ctx.c @@ -1226,7 +1226,7 @@ lm_ctx_try_attach(lm_ctx_t *lm_ctx) } lm_ctx_t *lm_create_ctx(lm_trans_t trans, const char *path, int flags, - lm_log_fn_t *log, lm_log_lvl_t log_lvl, void *pvt) + void *pvt) { lm_ctx_t *lm_ctx = NULL; int err = 0; @@ -1245,9 +1245,8 @@ lm_ctx_t *lm_create_ctx(lm_trans_t trans, const char *path, int flags, //FIXME: Validate arguments. // Set other context data. lm_ctx->pvt = pvt; - lm_ctx->log = log; - lm_ctx->log_lvl = log_lvl; lm_ctx->flags = flags; + lm_ctx->log_lvl = LM_ERR; lm_ctx->uuid = strdup(path); if (lm_ctx->uuid == NULL) { @@ -1288,6 +1287,19 @@ out: return lm_ctx; } +int lm_setup_log(lm_ctx_t *lm_ctx, lm_log_fn_t *log, lm_log_lvl_t log_lvl) +{ + + if (log_lvl != LM_ERR && log_lvl != LM_INF && log_lvl != LM_DBG) { + return ERROR(EINVAL); + } + + lm_ctx->log = log; + lm_ctx->log_lvl = log_lvl; + + return 0; +} + int lm_pci_setup_config_hdr(lm_ctx_t *lm_ctx, lm_pci_hdr_id_t id, lm_pci_hdr_ss_t ss, lm_pci_hdr_cc_t cc, UNUSED bool extended) |