libyang REFACTOR major logging updates

Structured error information instead of a
single error message.
diff --git a/src/json.c b/src/json.c
index 0b1e670..4b252b7 100644
--- a/src/json.c
+++ b/src/json.c
@@ -133,7 +133,7 @@
     size_t len;      /* length of the output string (write offset in output buffer) */
     size_t size = 0; /* size of the output buffer */
     size_t u;
-    uint64_t start_line;
+    uint64_t start_line, orig_line;
     uint32_t value;
     uint8_t i;
 
@@ -283,7 +283,10 @@
 
     /* EOF reached before endchar */
     LOGVAL(jsonctx->ctx, LY_VCODE_EOF);
-    LOGVAL_LINE(jsonctx->ctx, start_line, LYVE_SYNTAX, "Missing quotation-mark at the end of a JSON string.");
+    orig_line = jsonctx->in->line;
+    jsonctx->in->line = start_line;
+    LOGVAL(jsonctx->ctx, LYVE_SYNTAX, "Missing quotation-mark at the end of a JSON string.");
+    jsonctx->in->line = orig_line;
 
 error:
     free(buf);
@@ -716,7 +719,8 @@
     jsonctx->ctx = ctx;
     jsonctx->in = in;
 
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    /* input line logging */
+    ly_log_location(NULL, NULL, NULL, in);
 
     /* WS are always expected to be skipped */
     lyjson_skip_ws(jsonctx);
@@ -1077,7 +1081,7 @@
         return;
     }
 
-    LOG_LOCBACK(0, 0, 0, 1);
+    ly_log_location_revert(0, 0, 0, 1);
 
     if (jsonctx->dynamic) {
         free((char *)jsonctx->value);
diff --git a/src/log.c b/src/log.c
index 955fa1a..2c5093d 100644
--- a/src/log.c
+++ b/src/log.c
@@ -40,7 +40,6 @@
 ATOMIC_T ly_log_opts = (uint_fast32_t)(LY_LOLOG | LY_LOSTORE_LAST);
 THREAD_LOCAL uint32_t *temp_ly_log_opts;
 static ly_log_clb log_clb;
-static ATOMIC_T path_flag = 1;
 THREAD_LOCAL char last_msg[LY_LAST_MSG_SIZE];
 #ifndef NDEBUG
 ATOMIC_T ly_ldbg_groups = 0;
@@ -48,21 +47,8 @@
 
 THREAD_LOCAL struct ly_log_location_s log_location = {0};
 
-LIBYANG_API_DEF LY_ERR
-ly_errcode(const struct ly_ctx *ctx)
-{
-    struct ly_err_item *i;
-
-    i = ly_err_last(ctx);
-    if (i) {
-        return i->no;
-    }
-
-    return LY_SUCCESS;
-}
-
 LIBYANG_API_DEF const char *
-ly_strerrcode(LY_ERR err)
+ly_strerr(LY_ERR err)
 {
     /* ignore plugin flag */
     err &= ~LY_EPLUGIN;
@@ -102,19 +88,6 @@
     return "Unknown";
 }
 
-LIBYANG_API_DEF LY_VECODE
-ly_vecode(const struct ly_ctx *ctx)
-{
-    struct ly_err_item *i;
-
-    i = ly_err_last(ctx);
-    if (i) {
-        return i->vecode;
-    }
-
-    return LYVE_SUCCESS;
-}
-
 LIBYANG_API_DEF const char *
 ly_strvecode(LY_VECODE vecode)
 {
@@ -148,58 +121,14 @@
 }
 
 LIBYANG_API_DEF const char *
-ly_errmsg(const struct ly_ctx *ctx)
-{
-    struct ly_err_item *i;
-
-    LY_CHECK_ARG_RET(NULL, ctx, NULL);
-
-    i = ly_err_last(ctx);
-    if (i) {
-        return i->msg;
-    }
-
-    return NULL;
-}
-
-LIBYANG_API_DEF const char *
-ly_last_errmsg(void)
+ly_last_logmsg(void)
 {
     return last_msg;
 }
 
-LIBYANG_API_DEF const char *
-ly_errpath(const struct ly_ctx *ctx)
-{
-    struct ly_err_item *i;
-
-    LY_CHECK_ARG_RET(NULL, ctx, NULL);
-
-    i = ly_err_last(ctx);
-    if (i) {
-        return i->path;
-    }
-
-    return NULL;
-}
-
-LIBYANG_API_DEF const char *
-ly_errapptag(const struct ly_ctx *ctx)
-{
-    struct ly_err_item *i;
-
-    LY_CHECK_ARG_RET(NULL, ctx, NULL);
-
-    i = ly_err_last(ctx);
-    if (i) {
-        return i->apptag;
-    }
-
-    return NULL;
-}
-
 LIBYANG_API_DEF LY_ERR
-ly_err_new(struct ly_err_item **err, LY_ERR ecode, LY_VECODE vecode, char *path, char *apptag, const char *err_format, ...)
+ly_err_new(struct ly_err_item **err, LY_ERR ecode, LY_VECODE vecode, char *data_path, char *apptag,
+        const char *err_format, ...)
 {
     char *msg = NULL;
     struct ly_err_item *e;
@@ -209,19 +138,19 @@
         return ecode;
     }
 
-    e = malloc(sizeof *e);
+    e = calloc(1, sizeof *e);
     LY_CHECK_ERR_RET(!e, LOGMEM(NULL), LY_EMEM);
+
     e->prev = (*err) ? (*err)->prev : e;
-    e->next = NULL;
     if (*err) {
         (*err)->prev->next = e;
     }
 
     /* fill in the information */
     e->level = LY_LLERR;
-    e->no = ecode;
+    e->err = ecode;
     e->vecode = vecode;
-    e->path = path;
+    e->data_path = data_path;
     e->apptag = apptag;
 
     if (err_format) {
@@ -243,7 +172,7 @@
         *err = e;
     }
 
-    return e->no;
+    return e->err;
 }
 
 /**
@@ -296,7 +225,7 @@
     return r ? NULL : rec;
 }
 
-LIBYANG_API_DEF struct ly_err_item *
+LIBYANG_API_DEF const struct ly_err_item *
 ly_err_first(const struct ly_ctx *ctx)
 {
     struct ly_ctx_err_rec *rec;
@@ -309,7 +238,7 @@
     return rec ? rec->err : NULL;
 }
 
-LIBYANG_API_DEF struct ly_err_item *
+LIBYANG_API_DEF const struct ly_err_item *
 ly_err_last(const struct ly_ctx *ctx)
 {
     struct ly_ctx_err_rec *rec;
@@ -357,7 +286,8 @@
     /* clean the error list */
     LY_LIST_FOR_SAFE(ptr, next, e) {
         free(e->msg);
-        free(e->path);
+        free(e->data_path);
+        free(e->schema_path);
         free(e->apptag);
         free(e);
     }
@@ -434,10 +364,9 @@
 }
 
 LIBYANG_API_DEF void
-ly_set_log_clb(ly_log_clb clb, ly_bool path)
+ly_set_log_clb(ly_log_clb clb)
 {
     log_clb = clb;
-    ATOMIC_STORE_RELAXED(path_flag, path);
 }
 
 LIBYANG_API_DEF ly_log_clb
@@ -447,31 +376,27 @@
 }
 
 void
-ly_log_location(const struct lysc_node *scnode, const struct lyd_node *dnode, const char *path, const struct ly_in *in,
-        uint64_t line)
+ly_log_location(const struct lysc_node *scnode, const struct lyd_node *dnode, const char *spath, const struct ly_in *in)
 {
     if (scnode) {
         ly_set_add(&log_location.scnodes, (void *)scnode, 1, NULL);
     }
-    if (dnode) {
+    if (dnode || (!scnode && !spath && !in)) {
         ly_set_add(&log_location.dnodes, (void *)dnode, 1, NULL);
     }
-    if (path) {
-        char *s = strdup(path);
+    if (spath) {
+        char *s = strdup(spath);
 
         LY_CHECK_ERR_RET(!s, LOGMEM(NULL), );
-        ly_set_add(&log_location.paths, s, 1, NULL);
+        ly_set_add(&log_location.spaths, s, 1, NULL);
     }
     if (in) {
         ly_set_add(&log_location.inputs, (void *)in, 1, NULL);
     }
-    if (line) {
-        log_location.line = line;
-    }
 }
 
 void
-ly_log_location_revert(uint32_t scnode_steps, uint32_t dnode_steps, uint32_t path_steps, uint32_t in_steps)
+ly_log_location_revert(uint32_t scnode_steps, uint32_t dnode_steps, uint32_t spath_steps, uint32_t in_steps)
 {
     for (uint32_t i = scnode_steps; i && log_location.scnodes.count; i--) {
         log_location.scnodes.count--;
@@ -481,8 +406,8 @@
         log_location.dnodes.count--;
     }
 
-    for (uint32_t i = path_steps; i && log_location.paths.count; i--) {
-        ly_set_rm_index(&log_location.paths, log_location.paths.count - 1, free);
+    for (uint32_t i = spath_steps; i && log_location.spaths.count; i--) {
+        ly_set_rm_index(&log_location.spaths, log_location.spaths.count - 1, free);
     }
 
     for (uint32_t i = in_steps; i && log_location.inputs.count; i--) {
@@ -496,8 +421,8 @@
     if (dnode_steps && !log_location.dnodes.count) {
         ly_set_erase(&log_location.dnodes, NULL);
     }
-    if (path_steps && !log_location.paths.count) {
-        ly_set_erase(&log_location.paths, free);
+    if (spath_steps && !log_location.spaths.count) {
+        ly_set_erase(&log_location.spaths, free);
     }
     if (in_steps && !log_location.inputs.count) {
         ly_set_erase(&log_location.inputs, NULL);
@@ -525,15 +450,18 @@
  *
  * @param[in] ctx Context to use.
  * @param[in] level Message log level.
- * @param[in] no Error number.
+ * @param[in] err Error number.
  * @param[in] vecode Error validation error code.
  * @param[in] msg Error message, always spent.
- * @param[in] path Error path, always spent.
+ * @param[in] data_path Error data path, always spent.
+ * @param[in] schema_path Error schema path, always spent.
+ * @param[in] line Error input line, if any.
  * @param[in] apptag Error app tag, always spent.
  * @return LY_ERR value.
  */
 static LY_ERR
-log_store(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR no, LY_VECODE vecode, char *msg, char *path, char *apptag)
+log_store(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR err, LY_VECODE vecode, char *msg, char *data_path,
+        char *schema_path, uint64_t line, char *apptag)
 {
     struct ly_ctx_err_rec *rec;
     struct ly_err_item *e, *last;
@@ -550,7 +478,7 @@
     if (!e) {
         /* if we are only to fill in path, there must have been an error stored */
         assert(msg);
-        e = malloc(sizeof *e);
+        e = calloc(1, sizeof *e);
         LY_CHECK_GOTO(!e, mem_fail);
         e->prev = e;
         e->next = NULL;
@@ -558,15 +486,20 @@
         rec->err = e;
     } else if (!msg) {
         /* only filling the path */
-        assert(path);
+        assert(data_path || schema_path);
 
         /* find last error */
         e = e->prev;
         do {
             if (e->level == LY_LLERR) {
                 /* fill the path */
-                free(e->path);
-                e->path = path;
+                if (data_path) {
+                    free(e->data_path);
+                    e->data_path = data_path;
+                } else {
+                    free(e->schema_path);
+                    e->schema_path = schema_path;
+                }
                 return LY_SUCCESS;
             }
             e = e->prev;
@@ -577,12 +510,13 @@
             (!temp_ly_log_opts && ((ATOMIC_LOAD_RELAXED(ly_log_opts) & LY_LOSTORE_LAST) == LY_LOSTORE_LAST))) {
         /* overwrite last message */
         free(e->msg);
-        free(e->path);
+        free(e->data_path);
+        free(e->schema_path);
         free(e->apptag);
     } else {
         /* store new message */
         last = e->prev;
-        e->prev = malloc(sizeof *e);
+        e->prev = calloc(1, sizeof *e);
         LY_CHECK_GOTO(!e->prev, mem_fail);
         e = e->prev;
         e->prev = last;
@@ -592,27 +526,75 @@
 
     /* fill in the information */
     e->level = level;
-    e->no = no;
+    e->err = err;
     e->vecode = vecode;
     e->msg = msg;
-    e->path = path;
+    e->data_path = data_path;
+    e->schema_path = schema_path;
+    e->line = line;
     e->apptag = apptag;
     return LY_SUCCESS;
 
 mem_fail:
     LOGMEM(NULL);
     free(msg);
-    free(path);
+    free(data_path);
+    free(schema_path);
     free(apptag);
     return LY_EMEM;
 }
 
+/**
+ * @brief Log data path/schema path/line to stderr after the message has been printed.
+ *
+ * @param[in] data_path Error data path.
+ * @param[in] schema_path Error schema path.
+ * @param[in] line Error input line.
+ */
 static void
-log_vprintf(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR no, LY_VECODE vecode, char *path, const char *apptag,
-        const char *format, va_list args)
+log_stderr_path_line(const char *data_path, const char *schema_path, uint64_t line)
+{
+    ly_bool par = 0;
+
+    if (data_path) {
+        fprintf(stderr, "%sdata path: %s", " (", data_path);
+        par = 1;
+    }
+
+    if (schema_path) {
+        fprintf(stderr, "%sschemadata path: %s", par ? ", " : " (", schema_path);
+        par = 1;
+    }
+
+    if (line) {
+        fprintf(stderr, "%sline: %" PRIu64, par ? ", " : " (", line);
+        par = 1;
+    }
+
+    fprintf(stderr, par ? ")\n" : "\n");
+}
+
+/**
+ * @brief Log a message.
+ *
+ * @param[in] ctx Context to use.
+ * @param[in] level Message log level.
+ * @param[in] err Error number.
+ * @param[in] vecode Error validation error code.
+ * @param[in] data_path Error data path, always spent.
+ * @param[in] schema_path Error schema path, always spent.
+ * @param[in] line Error input line, if any.
+ * @param[in] apptag Error app tag.
+ * @param[in] format Error message format.
+ * @param[in] args Error message format arguments.
+ */
+static void
+log_vprintf(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR err, LY_VECODE vecode, char *data_path,
+        char *schema_path, uint64_t line, const char *apptag, const char *format, va_list args)
 {
     char *msg = NULL;
-    ly_bool free_strs, lolog, lostore;
+    ly_bool free_strs = 1, lolog, lostore;
+    const struct ly_err_item *e;
 
     /* learn effective logger options */
     if (temp_ly_log_opts) {
@@ -625,34 +607,27 @@
 
     if (level > ATOMIC_LOAD_RELAXED(ly_ll)) {
         /* do not print or store the message */
-        free(path);
-        return;
+        goto cleanup;
     }
 
-    if (no == LY_EMEM) {
+    if (err == LY_EMEM) {
         /* just print it, anything else would most likely fail anyway */
         if (lolog) {
             if (log_clb) {
-                log_clb(level, LY_EMEM_MSG, path);
+                log_clb(level, LY_EMEM_MSG, data_path, schema_path, line);
             } else {
                 fprintf(stderr, "libyang[%d]: ", level);
                 vfprintf(stderr, format, args);
-                if (path) {
-                    fprintf(stderr, " (path: %s)\n", path);
-                } else {
-                    fprintf(stderr, "\n");
-                }
+                log_stderr_path_line(data_path, schema_path, line);
             }
         }
-        free(path);
-        return;
+        goto cleanup;
     }
 
     /* print into a single message */
     if (vasprintf(&msg, format, args) == -1) {
         LOGMEM(ctx);
-        free(path);
-        return;
+        goto cleanup;
     }
 
     /* store as the last message */
@@ -661,32 +636,32 @@
     /* store the error/warning in the context (if we need to store errors internally, it does not matter what are
      * the user log options) */
     if ((level < LY_LLVRB) && ctx && lostore) {
-        if (((no & ~LY_EPLUGIN) == LY_EVALID) && (vecode == LYVE_SUCCESS)) {
+        if (((err & ~LY_EPLUGIN) == LY_EVALID) && (vecode == LYVE_SUCCESS)) {
             /* assume we are inheriting the error, so inherit vecode as well */
-            vecode = ly_vecode(ctx);
+            e = ly_err_last(ctx);
+            vecode = e->vecode;
         }
-        if (log_store(ctx, level, no, vecode, msg, path, apptag ? strdup(apptag) : NULL)) {
-            return;
+        if (log_store(ctx, level, err, vecode, msg, data_path, schema_path, line, apptag ? strdup(apptag) : NULL)) {
+            goto cleanup;
         }
         free_strs = 0;
-    } else {
-        free_strs = 1;
     }
 
     /* if we are only storing errors internally, never print the message (yet) */
     if (lolog) {
         if (log_clb) {
-            log_clb(level, msg, path);
+            log_clb(level, msg, data_path, schema_path, line);
         } else {
-            fprintf(stderr, "libyang[%d]: %s%s", level, msg, path ? " " : "\n");
-            if (path) {
-                fprintf(stderr, "(path: %s)\n", path);
-            }
+            fprintf(stderr, "libyang[%d]: ", level);
+            fprintf(stderr, "%s", msg);
+            log_stderr_path_line(data_path, schema_path, line);
         }
     }
 
+cleanup:
     if (free_strs) {
-        free(path);
+        free(data_path);
+        free(schema_path);
         free(msg);
     }
 }
@@ -725,7 +700,7 @@
     }
 
     va_start(ap, format);
-    log_vprintf(NULL, LY_LLDBG, 0, 0, NULL, NULL, dbg_format, ap);
+    log_vprintf(NULL, LY_LLDBG, 0, 0, NULL, NULL, 0, NULL, dbg_format, ap);
     va_end(ap);
 
     free(dbg_format);
@@ -734,12 +709,12 @@
 #endif
 
 void
-ly_log(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR no, const char *format, ...)
+ly_log(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR err, const char *format, ...)
 {
     va_list ap;
 
     va_start(ap, format);
-    log_vprintf(ctx, level, no, 0, NULL, NULL, format, ap);
+    log_vprintf(ctx, level, err, 0, NULL, NULL, 0, NULL, format, ap);
     va_end(ap);
 }
 
@@ -795,6 +770,14 @@
 
     if (log_location.dnodes.count) {
         dnode = log_location.dnodes.objs[log_location.dnodes.count - 1];
+        if (!dnode) {
+            /* special root node */
+            assert(log_location.dnodes.count == 1);
+            *path = strdup("/");
+            LY_CHECK_ERR_GOTO(!*path, LOGMEM(ctx); rc = LY_EMEM, cleanup);
+            goto cleanup;
+        }
+
         if (dnode->parent || !lysc_data_parent(dnode->schema)) {
             /* data node with all of its parents */
             *path = lyd_path(log_location.dnodes.objs[log_location.dnodes.count - 1], LYD_PATH_STD, NULL, 0);
@@ -821,62 +804,38 @@
 }
 
 /**
- * @brief Build log path from the stored log location information.
+ * @brief Build log path/input line from the stored log location information.
  *
  * @param[in] ctx Context to use.
- * @param[out] path Generated log path.
+ * @param[out] data_path Generated data path.
+ * @param[out] schema_path Generated data path.
+ * @param[out] line Input line.
  * @return LY_ERR value.
  */
 static LY_ERR
-ly_vlog_build_path(const struct ly_ctx *ctx, char **path)
+ly_vlog_build_path_line(const struct ly_ctx *ctx, char **data_path, char **schema_path, uint64_t *line)
 {
-    int r;
-    char *str = NULL, *prev = NULL;
+    *data_path = NULL;
+    *schema_path = NULL;
+    *line = 0;
 
-    *path = NULL;
-
-    if (log_location.paths.count && ((const char *)(log_location.paths.objs[log_location.paths.count - 1]))[0]) {
+    if (log_location.spaths.count && ((const char *)(log_location.spaths.objs[log_location.spaths.count - 1]))[0]) {
         /* simply get what is in the provided path string */
-        r = asprintf(path, "Path \"%s\"", (const char *)log_location.paths.objs[log_location.paths.count - 1]);
-        LY_CHECK_ERR_RET(r == -1, LOGMEM(ctx), LY_EMEM);
+        *schema_path = strdup(log_location.spaths.objs[log_location.spaths.count - 1]);
+        LY_CHECK_ERR_RET(!*schema_path, LOGMEM(ctx), LY_EMEM);
     } else {
         /* data/schema node */
         if (log_location.dnodes.count) {
-            LY_CHECK_RET(ly_vlog_build_data_path(ctx, &str));
-
-            r = asprintf(path, "Data location \"%s\"", str);
-            free(str);
-            LY_CHECK_ERR_RET(r == -1, LOGMEM(ctx), LY_EMEM);
+            LY_CHECK_RET(ly_vlog_build_data_path(ctx, data_path));
         } else if (log_location.scnodes.count) {
-            str = lysc_path(log_location.scnodes.objs[log_location.scnodes.count - 1], LYSC_PATH_LOG, NULL, 0);
-            LY_CHECK_ERR_RET(!str, LOGMEM(ctx), LY_EMEM);
-
-            r = asprintf(path, "Schema location \"%s\"", str);
-            free(str);
-            LY_CHECK_ERR_RET(r == -1, LOGMEM(ctx), LY_EMEM);
+            *schema_path = lysc_path(log_location.scnodes.objs[log_location.scnodes.count - 1], LYSC_PATH_LOG, NULL, 0);
+            LY_CHECK_ERR_RET(!*schema_path, LOGMEM(ctx), LY_EMEM);
         }
     }
 
     /* line */
-    prev = *path;
-    if (log_location.line) {
-        r = asprintf(path, "%s%sine number %" PRIu64, prev ? prev : "", prev ? ", l" : "L", log_location.line);
-        free(prev);
-        LY_CHECK_ERR_RET(r == -1, LOGMEM(ctx), LY_EMEM);
-
-        log_location.line = 0;
-    } else if (log_location.inputs.count) {
-        r = asprintf(path, "%s%sine number %" PRIu64, prev ? prev : "", prev ? ", l" : "L",
-                ((struct ly_in *)log_location.inputs.objs[log_location.inputs.count - 1])->line);
-        free(prev);
-        LY_CHECK_ERR_RET(r == -1, LOGMEM(ctx), LY_EMEM);
-    }
-
-    if (*path) {
-        prev = *path;
-        r = asprintf(path, "%s.", prev);
-        free(prev);
-        LY_CHECK_ERR_RET(r == -1, LOGMEM(ctx), LY_EMEM);
+    if (log_location.inputs.count) {
+        *line = ((struct ly_in *)log_location.inputs.objs[log_location.inputs.count - 1])->line;
     }
 
     return LY_SUCCESS;
@@ -886,14 +845,15 @@
 ly_vlog(const struct ly_ctx *ctx, const char *apptag, LY_VECODE code, const char *format, ...)
 {
     va_list ap;
-    char *path = NULL;
+    char *data_path = NULL, *schema_path = NULL;
+    uint64_t line = 0;
 
-    if (ATOMIC_LOAD_RELAXED(path_flag) && ctx) {
-        ly_vlog_build_path(ctx, &path);
+    if (ctx) {
+        ly_vlog_build_path_line(ctx, &data_path, &schema_path, &line);
     }
 
     va_start(ap, format);
-    log_vprintf(ctx, LY_LLERR, LY_EVALID, code, path, apptag, format, ap);
+    log_vprintf(ctx, LY_LLERR, LY_EVALID, code, data_path, schema_path, line, apptag, format, ap);
     /* path is spent and should not be freed! */
     va_end(ap);
 }
@@ -904,14 +864,16 @@
  * @param[in] ctx libyang context to store the error record. If not provided, the error is just printed.
  * @param[in] plugin_name Name of the plugin generating the message.
  * @param[in] level Log message level (error, warning, etc.)
- * @param[in] err_no Error type code.
- * @param[in] path Optional path of the error, used if set.
+ * @param[in] err Error type code.
+ * @param[in] data_path Error data path, always spent.
+ * @param[in] schema_path Error schema path, always spent.
+ * @param[in] line Error input line, if any.
  * @param[in] format Format string to print.
  * @param[in] ap Var arg list for @p format.
  */
 static void
-ly_ext_log(const struct ly_ctx *ctx, const char *plugin_name, LY_LOG_LEVEL level, LY_ERR err_no, char *path,
-        const char *format, va_list ap)
+ly_ext_log(const struct ly_ctx *ctx, const char *plugin_name, LY_LOG_LEVEL level, LY_ERR err, char *data_path,
+        char *schema_path, uint64_t line, const char *format, va_list ap)
 {
     char *plugin_msg;
 
@@ -923,57 +885,57 @@
         return;
     }
 
-    log_vprintf(ctx, level, (level == LY_LLERR ? LY_EPLUGIN : 0) | err_no, LYVE_OTHER, path, NULL, plugin_msg, ap);
+    log_vprintf(ctx, level, (level == LY_LLERR ? LY_EPLUGIN : 0) | err, LYVE_OTHER, data_path, schema_path, line, NULL,
+            plugin_msg, ap);
     free(plugin_msg);
 }
 
 LIBYANG_API_DEF void
-lyplg_ext_parse_log(const struct lysp_ctx *pctx, const struct lysp_ext_instance *ext, LY_LOG_LEVEL level, LY_ERR err_no,
+lyplg_ext_parse_log(const struct lysp_ctx *pctx, const struct lysp_ext_instance *ext, LY_LOG_LEVEL level, LY_ERR err,
         const char *format, ...)
 {
     va_list ap;
-    char *path = NULL;
+    char *data_path, *schema_path;
+    uint64_t line;
 
-    if (ATOMIC_LOAD_RELAXED(path_flag)) {
-        ly_vlog_build_path(PARSER_CTX(pctx), &path);
-    }
+    ly_vlog_build_path_line(PARSER_CTX(pctx), &data_path, &schema_path, &line);
 
     va_start(ap, format);
-    ly_ext_log(PARSER_CTX(pctx), ext->record->plugin.id, level, err_no, path, format, ap);
+    ly_ext_log(PARSER_CTX(pctx), ext->record->plugin.id, level, err, data_path, schema_path, line, format, ap);
     va_end(ap);
 }
 
 LIBYANG_API_DEF void
-lyplg_ext_compile_log(const struct lysc_ctx *cctx, const struct lysc_ext_instance *ext, LY_LOG_LEVEL level, LY_ERR err_no,
+lyplg_ext_compile_log(const struct lysc_ctx *cctx, const struct lysc_ext_instance *ext, LY_LOG_LEVEL level, LY_ERR err,
         const char *format, ...)
 {
     va_list ap;
-    char *path = NULL;
+    char *schema_path = NULL;
 
-    if (cctx && (asprintf(&path, "Path \"%s\".", cctx->path) == -1)) {
+    if (cctx && !(schema_path = strdup(cctx->path))) {
         LOGMEM(cctx->ctx);
         return;
     }
 
     va_start(ap, format);
-    ly_ext_log(ext->module->ctx, ext->def->plugin->id, level, err_no, path, format, ap);
+    ly_ext_log(ext->module->ctx, ext->def->plugin->id, level, err, NULL, schema_path, 0, format, ap);
     va_end(ap);
 }
 
 LIBYANG_API_DEF void
-lyplg_ext_compile_log_path(const char *path, const struct lysc_ext_instance *ext, LY_LOG_LEVEL level, LY_ERR err_no,
+lyplg_ext_compile_log_path(const char *path, const struct lysc_ext_instance *ext, LY_LOG_LEVEL level, LY_ERR err,
         const char *format, ...)
 {
     va_list ap;
-    char *log_path = NULL;
+    char *schema_path = NULL;
 
-    if (path && (asprintf(&log_path, "Path \"%s\".", path) == -1)) {
+    if (path && !(schema_path = strdup(path))) {
         LOGMEM(ext->module->ctx);
         return;
     }
 
     va_start(ap, format);
-    ly_ext_log(ext->module->ctx, ext->def->plugin->id, level, err_no, log_path, format, ap);
+    ly_ext_log(ext->module->ctx, ext->def->plugin->id, level, err, NULL, schema_path, 0, format, ap);
     va_end(ap);
 }
 
@@ -981,45 +943,54 @@
  * @brief Serves only for creating ap.
  */
 static void
-_lyplg_ext_compile_log_err(const struct ly_err_item *err, const struct lysc_ext_instance *ext, ...)
+_lyplg_ext_compile_log_err(const struct ly_err_item *eitem, const struct lysc_ext_instance *ext, ...)
 {
     va_list ap;
+    char *data_path = NULL, *schema_path = NULL;
+
+    if (eitem->data_path) {
+        data_path = strdup(eitem->data_path);
+    }
+    if (eitem->schema_path) {
+        schema_path = strdup(eitem->schema_path);
+    }
 
     va_start(ap, ext);
-    ly_ext_log(ext->module->ctx, ext->def->plugin->id, err->level, err->no, err->path ? strdup(err->path) : NULL, "%s", ap);
+    ly_ext_log(ext->module->ctx, ext->def->plugin->id, eitem->level, eitem->err, data_path, schema_path, eitem->line, "%s", ap);
     va_end(ap);
 }
 
 LIBYANG_API_DEF void
-lyplg_ext_compile_log_err(const struct ly_err_item *err, const struct lysc_ext_instance *ext)
+lyplg_ext_compile_log_err(const struct ly_err_item *eitem, const struct lysc_ext_instance *ext)
 {
-    _lyplg_ext_compile_log_err(err, ext, err->msg);
+    _lyplg_ext_compile_log_err(eitem, ext, eitem->msg);
 }
 
 /**
  * @brief Exact same functionality as ::ly_err_print() but has variable arguments so log_vprintf() can be called.
  */
 static void
-_ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem, const char *format, ...)
+_ly_err_print(const struct ly_ctx *ctx, const struct ly_err_item *eitem, const char *format, ...)
 {
     va_list ap;
-    char *path_dup = NULL;
+    char *data_path = NULL, *schema_path = NULL;
 
     LY_CHECK_ARG_RET(ctx, eitem, );
 
-    if (eitem->path) {
-        /* duplicate path because it will be freed */
-        path_dup = strdup(eitem->path);
-        LY_CHECK_ERR_RET(!path_dup, LOGMEM(ctx), );
+    if (eitem->data_path) {
+        data_path = strdup(eitem->data_path);
+    }
+    if (eitem->schema_path) {
+        schema_path = strdup(eitem->schema_path);
     }
 
     va_start(ap, format);
-    log_vprintf(ctx, eitem->level, eitem->no, eitem->vecode, path_dup, eitem->apptag, format, ap);
+    log_vprintf(ctx, eitem->level, eitem->err, eitem->vecode, data_path, schema_path, eitem->line, eitem->apptag, format, ap);
     va_end(ap);
 }
 
 LIBYANG_API_DEF void
-ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem)
+ly_err_print(const struct ly_ctx *ctx, const struct ly_err_item *eitem)
 {
     /* String ::ly_err_item.msg cannot be used directly because it may contain the % character */
     _ly_err_print(ctx, eitem, "%s", eitem->msg);
diff --git a/src/log.h b/src/log.h
index c98edac..49262c7 100644
--- a/src/log.h
+++ b/src/log.h
@@ -181,24 +181,23 @@
  *
  * @param[in] level Log level of the message.
  * @param[in] msg Message.
- * @param[in] path Optional path of the concerned node.
+ * @param[in] data_path Optional data path of the related node.
+ * @param[in] schema_path Optional schema path of the related node.
+ * @param[in] line Optional related input line.
  */
-typedef void (*ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *path);
+typedef void (*ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *data_path, const char *schema_path,
+        uint64_t line);
 
 /**
  * @brief Set logger callback.
  *
  * @param[in] clb Logging callback.
- * @param[in] path flag to resolve and provide path as the third parameter of the callback function. In case of
- *            validation and some other errors, it can be useful to get the path to the problematic element. Note,
- *            that according to the tree type and the specific situation, the path can slightly differs (keys
- *            presence) or it can be NULL, so consider it as an optional parameter. If the flag is 0, libyang will
- *            not bother with resolving the path.
  */
-LIBYANG_API_DECL void ly_set_log_clb(ly_log_clb clb, ly_bool path);
+LIBYANG_API_DECL void ly_set_log_clb(ly_log_clb clb);
 
 /**
  * @brief Get logger callback.
+ *
  * @return Logger callback (can be NULL).
  */
 LIBYANG_API_DECL ly_log_clb ly_get_log_clb(void);
@@ -293,40 +292,24 @@
  */
 struct ly_err_item {
     LY_LOG_LEVEL level;         /**< error (message) log level */
-    LY_ERR no;                  /**< error code */
+    LY_ERR err;                 /**< error code number */
     LY_VECODE vecode;           /**< validation error code, if any */
     char *msg;                  /**< error message */
-    char *path;                 /**< error path that caused the error, if any */
+    char *data_path;            /**< error data path related to the error, if any */
+    char *schema_path;          /**< error schema path related to the error, if any */
+    uint64_t line;              /**< input line the error occured on, if available */
     char *apptag;               /**< error-app-tag, if any */
     struct ly_err_item *next;   /**< next error item */
     struct ly_err_item *prev;   /**< previous error item, points to the last item for the ifrst item */
 };
 
 /**
- * @brief Get the last (thread, context-specific) error code.
- *
- * @param[in] ctx Relative context.
- * @return LY_ERR value of the last error code.
- */
-LIBYANG_API_DECL LY_ERR ly_errcode(const struct ly_ctx *ctx);
-
-/**
  * @brief Get human-readable error message for an error code.
  *
  * @param[in] err Error code.
  * @return String error message.
  */
-LIBYANG_API_DECL const char *ly_strerrcode(LY_ERR err);
-
-/**
- * @brief Get the last (thread, context-specific) validation error code.
- *
- * This value is set only if ly_errno is #LY_EVALID.
- *
- * @param[in] ctx Relative context.
- * @return Validation error code.
- */
-LIBYANG_API_DECL LY_VECODE ly_vecode(const struct ly_ctx *ctx);
+LIBYANG_API_DECL const char *ly_strerr(LY_ERR err);
 
 /**
  * @brief Get human-readable error message for a validation error code.
@@ -337,69 +320,30 @@
 LIBYANG_API_DECL const char *ly_strvecode(LY_VECODE vecode);
 
 /**
- * @brief Get the last (thread, context-specific) error message. If the coresponding module defined
- * a specific error message, it will be used instead the default one.
+ * @brief Get the last (thread-specific) full logged error message.
  *
- * Sometimes, the error message is extended with path of the element where the problem is.
- * The path is available via ::ly_errpath().
- *
- * @param[in] ctx Relative context.
- * @return Text of the last error message, empty string if there is no error.
- */
-LIBYANG_API_DECL const char *ly_errmsg(const struct ly_ctx *ctx);
-
-/**
- * @brief Get the last (thread-specific) error message.
- *
- * ::ly_errmsg() should be used instead of this function but this one is useful for getting
- * errors from functions that do not have any context accessible. Or as a simple unified logging API.
+ * This function is useful for getting errors from functions that do not have any context accessible and includes
+ * any additional information such as the path or line where the error occurred.
  *
  * @return Last generated error message.
  */
-LIBYANG_API_DECL const char *ly_last_errmsg(void);
-
-/**
- * @brief Get the last (thread, context-specific) path of the element where was an error.
- *
- * The path always corresponds to the error message available via ::ly_errmsg(), so
- * whenever a subsequent error message is printed, the path is erased or rewritten.
- * The path reflects the type of the processed tree - data path for data tree functions
- * and schema path in case of schema tree functions. In case of processing YIN schema
- * or XML data, the path can be just XML path. In such a case, the corresponding
- * ly_vecode (value 1-3) is set.
- *
- * @param[in] ctx Relative context.
- * @return Path of the error element, empty string if error path does not apply to the last error.
- */
-LIBYANG_API_DECL const char *ly_errpath(const struct ly_ctx *ctx);
-
-/**
- * @brief Get the last (thread, context-specific) error-app-tag if there was a specific one defined
- * in the module for the last error.
- *
- * The app-tag always corresponds to the error message available via ::ly_errmsg(), so
- * whenever a subsequent error message is printed, the app-tag is erased or rewritten.
- *
- * @param[in] ctx Relative context.
- * @return Error-app-tag of the last error, empty string if the error-app-tag does not apply to the last error.
- */
-LIBYANG_API_DECL const char *ly_errapptag(const struct ly_ctx *ctx);
+LIBYANG_API_DECL const char *ly_last_logmsg(void);
 
 /**
  * @brief Get the first (thread, context-specific) generated error structure.
  *
  * @param[in] ctx Relative context.
- * @return The first error structure (can be NULL), do not modify!
+ * @return First error structure, NULL if none available.
  */
-LIBYANG_API_DECL struct ly_err_item *ly_err_first(const struct ly_ctx *ctx);
+LIBYANG_API_DECL const struct ly_err_item *ly_err_first(const struct ly_ctx *ctx);
 
 /**
  * @brief Get the latest (thread, context-specific) generated error structure.
  *
  * @param[in] ctx Relative context.
- * @return The last error structure (can be NULL), do not modify!
+ * @return Last error structure, NULL if none available.
  */
-LIBYANG_API_DECL struct ly_err_item *ly_err_last(const struct ly_ctx *ctx);
+LIBYANG_API_DECL const struct ly_err_item *ly_err_last(const struct ly_ctx *ctx);
 
 /**
  * @brief Print the error structure as if just generated.
@@ -407,12 +351,12 @@
  * @param[in] ctx Optional context to store the message in.
  * @param[in] eitem Error item structure to print.
  */
-LIBYANG_API_DECL void ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem);
+LIBYANG_API_DECL void ly_err_print(const struct ly_ctx *ctx, const struct ly_err_item *eitem);
 
 /**
  * @brief Free error structures from a context.
  *
- * If \p eitem is not set, free all the error structures.
+ * If @p eitem is not set, free all the error structures.
  *
  * @param[in] ctx Relative context.
  * @param[in] eitem Oldest error structure to remove, optional.
diff --git a/src/ly_common.h b/src/ly_common.h
index 358efb8..00ac506 100644
--- a/src/ly_common.h
+++ b/src/ly_common.h
@@ -72,11 +72,10 @@
 extern ATOMIC_T ly_log_opts;
 
 struct ly_log_location_s {
-    uint64_t line;                   /**< One-time line value being reset after use - replaces whatever is in inputs */
     struct ly_set inputs;            /**< Set of const struct ly_in *in pointers providing the input handler with the line information (LIFO) */
     struct ly_set scnodes;           /**< Set of const struct lysc_node *scnode pointers providing the compiled schema node to generate path (LIFO) */
     struct ly_set dnodes;            /**< Set of const struct lyd_node *dnode pointers providing the data node to generate path (LIFO) */
-    struct ly_set paths;             /**< Set of path strings (LIFO) */
+    struct ly_set spaths;            /**< Set of schema path strings (LIFO) */
 };
 
 /**
@@ -84,10 +83,10 @@
  *
  * @param[in] ctx libyang context to store the error record. If not provided, the error is just printed.
  * @param[in] level Log message level (error, warning, etc.)
- * @param[in] no Error type code.
+ * @param[in] err Error code.
  * @param[in] format Format string to print.
  */
-void ly_log(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR no, const char *format, ...) _FORMAT_PRINTF(4, 5);
+void ly_log(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR err, const char *format, ...) _FORMAT_PRINTF(4, 5);
 
 /**
  * @brief Generate data path based on the data and schema nodes stored in the log location.
@@ -117,26 +116,27 @@
 void ly_err_move(struct ly_ctx *src_ctx, struct ly_ctx *trg_ctx);
 
 /**
- * @brief Logger's location data setter.
+ * @brief Logger location data setter.
+ *
+ * If all the parameter are NULL, a root @p dnode is added (NULL).
  *
  * @param[in] scnode Compiled schema node.
  * @param[in] dnode Data node.
- * @param[in] path Direct path string to print.
- * @param[in] in Input handler (providing line number)
- * @param[in] line One-time line value to be reset when used.
+ * @param[in] spath Direct schema path string to print.
+ * @param[in] in Input handler (providing line number).
  */
 void ly_log_location(const struct lysc_node *scnode, const struct lyd_node *dnode,
-        const char *path, const struct ly_in *in, uint64_t line);
+        const char *spath, const struct ly_in *in);
 
 /**
- * @brief Revert the specific logger's location data by number of changes made by ::ly_log_location().
+ * @brief Revert the specific logger location data by number of changes made by ::ly_log_location().
  *
  * @param[in] scnode_steps Number of items in ::ly_log_location_s.scnodes to forget.
  * @param[in] dnode_steps Number of items in ::ly_log_location_s.dnodes to forget.
- * @param[in] path_steps Number of path strings in ::ly_log_location_s.paths to forget.
+ * @param[in] spath_steps Number of path strings in ::ly_log_location_s.spaths to forget.
  * @param[in] in_steps Number of input handlers ::ly_log_location_s.inputs to forget.
  */
-void ly_log_location_revert(uint32_t scnode_steps, uint32_t dnode_steps, uint32_t path_steps, uint32_t in_steps);
+void ly_log_location_revert(uint32_t scnode_steps, uint32_t dnode_steps, uint32_t spath_steps, uint32_t in_steps);
 
 /**
  * @brief Get the stored data node for logging at the index.
@@ -154,26 +154,22 @@
 uint32_t ly_log_location_dnode_count(void);
 
 /**
- * @brief Update location data for logger, not provided arguments (NULLs) are kept (does not override).
+ * @brief Update location schema/data nodes for logger, not provided arguments (NULLs) are kept (does not override).
  *
  * @param[in] SCNODE Compiled schema node.
  * @param[in] DNODE Data node.
- * @param[in] PATH Direct path string to print.
- * @param[in] IN Input handler (providing line number)
  */
-#define LOG_LOCSET(SCNODE, DNODE, PATH, IN) \
-    ly_log_location(SCNODE, DNODE, PATH, IN, 0)
+#define LOG_LOCSET(SCNODE, DNODE) \
+    ly_log_location(SCNODE, DNODE, NULL, NULL)
 
 /**
- * @brief Update location data for logger, not provided arguments (NULLs) are kept (does not override).
+ * @brief Update location schema/data nodes for logger, not provided arguments (NULLs) are kept (does not override).
  *
  * @param[in] SCNODE_STEPS Number of the compiled schema nodes to remove from the stack.
  * @param[in] DNODE_STEPS Number of the data nodes to remove from the stack.
- * @param[in] PATH_STEPS Number of the direct path strings to remove from the stack.
- * @param[in] IN_STEPS Number of the input handlers (providing line number) to remove from the stack.
  */
-#define LOG_LOCBACK(SCNODE_STEPS, DNODE_STEPS, PATH_STEPS, IN_STEPS) \
-    ly_log_location_revert(SCNODE_STEPS, DNODE_STEPS, PATH_STEPS, IN_STEPS)
+#define LOG_LOCBACK(SCNODE_STEPS, DNODE_STEPS) \
+    ly_log_location_revert(SCNODE_STEPS, DNODE_STEPS, 0, 0)
 
 #define LOGERR(ctx, errno, ...) ly_log(ctx, LY_LLERR, errno, __VA_ARGS__)
 #define LOGWRN(ctx, ...) ly_log(ctx, LY_LLWRN, 0, __VA_ARGS__)
@@ -201,20 +197,6 @@
 #define LOGARG(CTX, ARG) LOGERR(CTX, LY_EINVAL, "Invalid argument %s (%s()).", #ARG, __func__)
 #define LOGVAL(CTX, ...) ly_vlog(CTX, NULL, __VA_ARGS__)
 #define LOGVAL_APPTAG(CTX, APPTAG, ...) ly_vlog(CTX, APPTAG, __VA_ARGS__)
-#define LOGVAL_LINE(CTX, LINE, ...) \
-    ly_log_location(NULL, NULL, NULL, NULL, LINE); \
-    ly_vlog(CTX, NULL, __VA_ARGS__)
-
-/**
- * @brief Print Validation error from struct ly_err_item.
- *
- * String ::ly_err_item.msg cannot be used directly because it may contain the % character,
- * which is incorrectly interpreted in this situation as a conversion specification.
- *
- * @param[in] CTX libyang context to store the error record. If not provided, the error is just printed.
- * @param[in] ERRITEM pointer to ly_err_item that contains an error message.
- */
-#define LOGVAL_ERRITEM(CTX, ERRITEM) ly_vlog(CTX, ERRITEM->apptag, ERRITEM->vecode, "%s", ERRITEM->msg)
 
 #define LOGMEM_RET(CTX) LOGMEM(CTX); return LY_EMEM
 #define LOGINT_RET(CTX) LOGINT(CTX); return LY_EINT
diff --git a/src/parser_common.c b/src/parser_common.c
index 47810a0..39d93e3 100644
--- a/src/parser_common.c
+++ b/src/parser_common.c
@@ -102,7 +102,7 @@
 cleanup:
     FREE_ARRAY(&cctx.free_ctx, patterns, lysc_pattern_free);
     if (rc && err) {
-        LOGVAL_ERRITEM(ctx, err);
+        ly_err_print(ctx, err);
         ly_err_free(err);
         LOGVAL(ctx, LYVE_DATA, "Invalid \"eventTime\" in the notification.");
     }
@@ -219,7 +219,7 @@
 {
     LY_ERR rc = LY_SUCCESS;
 
-    LOG_LOCSET(snode, NULL, NULL, NULL);
+    LOG_LOCSET(snode, NULL);
 
     if (lydctx->int_opts & LYD_INTOPT_ANY) {
         /* nothing to check, everything is allowed */
@@ -274,7 +274,7 @@
     rc = LY_EVALID;
 
 cleanup:
-    LOG_LOCBACK(1, 0, 0, 0);
+    LOG_LOCBACK(1, 0);
     return rc;
 }
 
@@ -321,7 +321,7 @@
         rc = LY_EMEM;
         goto cleanup;
     }
-    LOG_LOCSET(NULL, NULL, path, NULL);
+    ly_log_location(NULL, NULL, path, NULL);
 
     LY_CHECK_GOTO(rc = lyd_create_meta(parent, meta, mod, name, name_len, value, value_len, 1, dynamic, format,
             prefix_data, hints, ctx_node, 0, &incomplete), cleanup);
@@ -336,7 +336,7 @@
     }
 
 cleanup:
-    LOG_LOCBACK(0, 0, 1, 0);
+    ly_log_location_revert(0, 0, 1, 0);
     free(dpath);
     free(path);
     return rc;
diff --git a/src/parser_internal.h b/src/parser_internal.h
index 92412e2..0c026a0 100644
--- a/src/parser_internal.h
+++ b/src/parser_internal.h
@@ -38,8 +38,9 @@
 #define LY_DPARSER_ERR_GOTO(r, err_cmd, lydctx, label) \
         if (r) { \
             err_cmd; \
+            const struct ly_err_item *__eitem = ly_err_last(((struct lyd_ctx *)lydctx)->data_ctx->ctx); \
             if ((r != LY_EVALID) || !lydctx || !(lydctx->val_opts & LYD_VALIDATE_MULTI_ERROR) || \
-                    (ly_vecode(((struct lyd_ctx *)lydctx)->data_ctx->ctx) == LYVE_SYNTAX)) { \
+                    (__eitem->vecode == LYVE_SYNTAX)) { \
                 goto label; \
             } \
         }
diff --git a/src/parser_json.c b/src/parser_json.c
index 858ec99..6d22be7 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -580,7 +580,7 @@
             continue;
         }
 
-        LOG_LOCSET(NULL, attr, NULL, NULL);
+        LOG_LOCSET(NULL, attr);
         log_location_items++;
 
         if (prev != meta_container->name.name) {
@@ -696,14 +696,14 @@
             lyd_free_tree(attr);
         }
 
-        LOG_LOCBACK(0, log_location_items, 0, 0);
+        LOG_LOCBACK(0, log_location_items);
         log_location_items = 0;
     }
 
 cleanup:
     lydict_remove(lydctx->jsonctx->ctx, prev);
 
-    LOG_LOCBACK(0, log_location_items, 0, 0);
+    LOG_LOCBACK(0, log_location_items);
     return ret;
 }
 
@@ -738,7 +738,9 @@
     assert(snode || node);
 
     nodetype = snode ? snode->nodetype : LYS_CONTAINER;
-    LOG_LOCSET(snode, NULL, NULL, NULL);
+    if (snode) {
+        LOG_LOCSET(snode, NULL);
+    }
 
     /* move to the second item in the name/X pair */
     LY_CHECK_GOTO(rc = lyjson_ctx_next(lydctx->jsonctx, &status), cleanup);
@@ -904,7 +906,7 @@
         }
     }
     free(dynamic_prefname);
-    LOG_LOCBACK(1, 0, 0, 0);
+    LOG_LOCBACK(snode ? 1 : 0, 0);
     return rc;
 }
 
@@ -1029,7 +1031,7 @@
     LY_CHECK_GOTO(ret = lydjson_create_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_inner_p, node_p), cleanup);
 
     assert(*node_p);
-    LOG_LOCSET(NULL, *node_p, NULL, NULL);
+    LOG_LOCSET(NULL, *node_p);
 
     if ((*status_p == LYJSON_ARRAY) && (*status_inner_p == LYJSON_NULL)) {
         /* special array null value */
@@ -1073,12 +1075,12 @@
         assert(*node_p);
         lydjson_maintain_children(parent, first_p, node_p, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0, NULL);
 
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
 
         LY_CHECK_GOTO(ret = lydjson_create_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_inner_p, node_p), cleanup);
 
         assert(*node_p);
-        LOG_LOCSET(NULL, *node_p, NULL, NULL);
+        LOG_LOCSET(NULL, *node_p);
     }
 
     if (*status_p == LYJSON_OBJECT) {
@@ -1095,7 +1097,7 @@
 
 cleanup:
     if (*node_p) {
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
     }
     return ret;
 }
@@ -1288,7 +1290,7 @@
         LY_CHECK_ERR_GOTO(r, rc = r, cleanup);
 
         assert(*node);
-        LOG_LOCSET(NULL, *node, NULL, NULL);
+        LOG_LOCSET(NULL, *node);
         log_node = 1;
 
         /* parse any data tree with correct options, first backup the current options and then make the parser
@@ -1374,7 +1376,7 @@
 
 cleanup:
     if (log_node) {
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
     }
     lydctx->parse_opts = prev_parse_opts;
     lydctx->int_opts = prev_int_opts;
@@ -1409,7 +1411,7 @@
     LY_CHECK_RET(lyd_create_inner(snode, node));
 
     /* use it for logging */
-    LOG_LOCSET(NULL, *node, NULL, NULL);
+    LOG_LOCSET(NULL, *node);
 
     if (ext) {
         /* only parse these extension data and validate afterwards */
@@ -1447,7 +1449,7 @@
 
 cleanup:
     lydctx->parse_opts = prev_parse_opts;
-    LOG_LOCBACK(0, 1, 0, 0);
+    LOG_LOCBACK(0, 1);
     if (!(*node)->hash) {
         /* list without keys is unusable */
         lyd_free_tree(*node);
@@ -1483,7 +1485,7 @@
     LY_ERR r, rc = LY_SUCCESS;
     uint32_t type_hints = 0;
 
-    LOG_LOCSET(snode, NULL, NULL, NULL);
+    LOG_LOCSET(snode, NULL);
 
     r = lydjson_data_check_opaq(lydctx, snode, &type_hints);
     if (r == LY_SUCCESS) {
@@ -1548,7 +1550,7 @@
     }
 
 cleanup:
-    LOG_LOCBACK(1, 0, 0, 0);
+    LOG_LOCBACK(1, 0);
     return rc;
 }
 
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index b0f6dcb..119b6f4 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -1172,7 +1172,7 @@
     LY_CHECK_GOTO(ret, cleanup);
 
     assert(node);
-    LOG_LOCSET(NULL, node, NULL, NULL);
+    LOG_LOCSET(NULL, node);
 
     /* process children */
     ret = lyb_parse_siblings(lybctx, node, NULL, NULL);
@@ -1181,11 +1181,11 @@
     /* register parsed opaq node */
     lyb_finish_opaq(lybctx, parent, flags, &attr, &node, first_p, parsed);
     assert(!attr && !node);
-    LOG_LOCBACK(0, 1, 0, 0);
+    LOG_LOCBACK(0, 1);
 
 cleanup:
     if (node) {
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
     }
     free(prefix);
     free(module_key);
@@ -1273,12 +1273,12 @@
     }
 
     assert(node);
-    LOG_LOCSET(NULL, node, NULL, NULL);
+    LOG_LOCSET(NULL, node);
 
     /* register parsed anydata node */
     lyb_finish_node(lybctx, parent, flags, &meta, &node, first_p, parsed);
 
-    LOG_LOCBACK(0, 1, 0, 0);
+    LOG_LOCBACK(0, 1);
     return LY_SUCCESS;
 
 error:
@@ -1316,7 +1316,7 @@
     LY_CHECK_GOTO(ret, error);
 
     assert(node);
-    LOG_LOCSET(NULL, node, NULL, NULL);
+    LOG_LOCSET(NULL, node);
 
     /* process children */
     ret = lyb_parse_siblings(lybctx, node, NULL, NULL);
@@ -1334,12 +1334,12 @@
     /* register parsed node */
     lyb_finish_node(lybctx, parent, flags, &meta, &node, first_p, parsed);
 
-    LOG_LOCBACK(0, 1, 0, 0);
+    LOG_LOCBACK(0, 1);
     return LY_SUCCESS;
 
 error:
     if (node) {
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
     }
     lyd_free_meta_siblings(meta);
     lyd_free_tree(node);
@@ -1374,11 +1374,11 @@
     LY_CHECK_GOTO(ret, error);
 
     assert(node);
-    LOG_LOCSET(NULL, node, NULL, NULL);
+    LOG_LOCSET(NULL, node);
 
     lyb_finish_node(lybctx, parent, flags, &meta, &node, first_p, parsed);
 
-    LOG_LOCBACK(0, 1, 0, 0);
+    LOG_LOCBACK(0, 1);
     return LY_SUCCESS;
 
 error:
@@ -1454,7 +1454,7 @@
         LY_CHECK_GOTO(ret, error);
 
         assert(node);
-        LOG_LOCSET(NULL, node, NULL, NULL);
+        LOG_LOCSET(NULL, node);
         log_node = 1;
 
         /* process children */
@@ -1473,7 +1473,7 @@
         /* register parsed list node */
         lyb_finish_node(lybctx, parent, flags, &meta, &node, first_p, parsed);
 
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
         log_node = 0;
     }
 
@@ -1485,7 +1485,7 @@
 
 error:
     if (log_node) {
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
     }
     lyd_free_meta_siblings(meta);
     lyd_free_tree(node);
diff --git a/src/parser_xml.c b/src/parser_xml.c
index 6978475..02c6be6 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -75,7 +75,7 @@
 
     *meta = NULL;
 
-    LOG_LOCSET(sparent, NULL, NULL, NULL);
+    LOG_LOCSET(sparent, NULL);
 
     /* check for NETCONF filter unqualified attributes */
     if (!strcmp(sparent->module->name, "notifications")) {
@@ -165,7 +165,7 @@
     }
 
 cleanup:
-    LOG_LOCBACK(1, 0, 0, 0);
+    LOG_LOCBACK(1, 0);
     if (ret) {
         lyd_free_meta_siblings(*meta);
         *meta = NULL;
@@ -672,7 +672,7 @@
     LY_CHECK_GOTO(rc, cleanup);
 
     assert(*node);
-    LOG_LOCSET(NULL, *node, NULL, NULL);
+    LOG_LOCSET(NULL, *node);
 
     /* parser next */
     rc = lyxml_ctx_next(xmlctx);
@@ -709,7 +709,7 @@
 
 cleanup:
     if (*node) {
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
     }
     ly_free_prefix_data(format, val_prefix_data);
     if (dynamic) {
@@ -747,7 +747,7 @@
     LY_DPARSER_ERR_GOTO(r, rc = r, lydctx, cleanup);
 
     if (*node) {
-        LOG_LOCSET(NULL, *node, NULL, NULL);
+        LOG_LOCSET(NULL, *node);
     }
 
     if (*node && parent && (snode->flags & LYS_KEY)) {
@@ -778,7 +778,7 @@
 
 cleanup:
     if (*node) {
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
     }
     if (rc && (!(lydctx->val_opts & LYD_VALIDATE_MULTI_ERROR) || (rc != LY_EVALID))) {
         lyd_free_tree(*node);
@@ -819,7 +819,7 @@
     LY_CHECK_GOTO(rc, cleanup);
 
     assert(*node);
-    LOG_LOCSET(NULL, *node, NULL, NULL);
+    LOG_LOCSET(NULL, *node);
 
     /* parser next */
     rc = lyxml_ctx_next(xmlctx);
@@ -863,7 +863,7 @@
 
 cleanup:
     if (*node) {
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
     }
     lydctx->parse_opts = prev_parse_opts;
     if (rc && ((*node && !(*node)->hash) || !(lydctx->val_opts & LYD_VALIDATE_MULTI_ERROR) || (rc != LY_EVALID))) {
@@ -923,7 +923,7 @@
         LY_CHECK_ERR_GOTO(r, rc = r, cleanup);
 
         assert(*node);
-        LOG_LOCSET(NULL, *node, NULL, NULL);
+        LOG_LOCSET(NULL, *node);
         log_node = 1;
 
         /* parser next */
@@ -948,7 +948,7 @@
 
 cleanup:
     if (log_node) {
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
     }
     lydctx->parse_opts = prev_parse_opts;
     lydctx->int_opts = prev_int_opts;
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 91f9a93..a6d1d79 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -4717,7 +4717,7 @@
     (*context)->parsed_mods = main_ctx->parsed_mods;
     ly_set_add((*context)->parsed_mods, mod_p, 1, NULL);
 
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
 
     /* skip redundant but valid characters at the beginning */
     ret = skip_redundant_chars(*context);
@@ -4754,7 +4754,7 @@
     *submod = mod_p;
 
 cleanup:
-    LOG_LOCBACK(0, 0, 0, 1);
+    ly_log_location_revert(0, 0, 0, 1);
     if (ret) {
         lysp_module_free(&fctx, (struct lysp_module *)mod_p);
         lysp_yang_ctx_free(*context);
@@ -4787,7 +4787,7 @@
     mod_p->mod = mod;
     ly_set_add((*context)->parsed_mods, mod_p, 1, NULL);
 
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
 
     /* skip redundant but valid characters at the beginning */
     ret = skip_redundant_chars(*context);
@@ -4823,7 +4823,7 @@
     mod->parsed = mod_p;
 
 cleanup:
-    LOG_LOCBACK(0, 0, 0, 1);
+    ly_log_location_revert(0, 0, 0, 1);
     if (ret) {
         lysp_module_free(&fctx, mod_p);
         lysp_yang_ctx_free(*context);
diff --git a/src/parser_yin.c b/src/parser_yin.c
index ac4c820..3924d0e 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -3937,7 +3937,7 @@
     *submod = mod_p;
 
 cleanup:
-    LOG_LOCBACK(0, 0, 0, 1);
+    ly_log_location_revert(0, 0, 0, 1);
     if (ret) {
         lysp_module_free(&fctx, (struct lysp_module *)mod_p);
         lysp_yin_ctx_free(*yin_ctx);
@@ -4001,7 +4001,7 @@
     mod->parsed = mod_p;
 
 cleanup:
-    LOG_LOCBACK(0, 0, 0, 1);
+    ly_log_location_revert(0, 0, 0, 1);
     if (ret) {
         lysp_module_free(&fctx, mod_p);
         lysp_yin_ctx_free(*yin_ctx);
diff --git a/src/path.c b/src/path.c
index 2ef2fbd..2214ed0 100644
--- a/src/path.c
+++ b/src/path.c
@@ -56,7 +56,9 @@
     const char *name;
     size_t name_len;
 
-    LOG_LOCSET(cur_node, NULL, NULL, NULL);
+    if (cur_node) {
+        LOG_LOCSET(cur_node, NULL);
+    }
 
     if (!lyxp_next_token(NULL, exp, tok_idx, LYXP_TOKEN_BRACK1)) {
         /* '[' */
@@ -254,12 +256,12 @@
     }
 
 cleanup:
-    LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
+    LOG_LOCBACK(cur_node ? 1 : 0, 0);
     ly_set_free(set, NULL);
     return ret;
 
 token_error:
-    LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
+    LOG_LOCBACK(cur_node ? 1 : 0, 0);
     ly_set_free(set, NULL);
     return LY_EVALID;
 }
@@ -333,7 +335,9 @@
             (prefix == LY_PATH_PREFIX_FIRST) || (prefix == LY_PATH_PREFIX_STRICT_INHERIT));
     assert((pred == LY_PATH_PRED_KEYS) || (pred == LY_PATH_PRED_SIMPLE) || (pred == LY_PATH_PRED_LEAFREF));
 
-    LOG_LOCSET(ctx_node, NULL, NULL, NULL);
+    if (ctx_node) {
+        LOG_LOCSET(ctx_node, NULL);
+    }
 
     /* parse as a generic XPath expression, reparse is performed manually */
     LY_CHECK_GOTO(ret = lyxp_expr_parse(ctx, str_path, path_len, 0, &exp), error);
@@ -438,12 +442,12 @@
 
     *expr = exp;
 
-    LOG_LOCBACK(ctx_node ? 1 : 0, 0, 0, 0);
+    LOG_LOCBACK(ctx_node ? 1 : 0, 0);
     return LY_SUCCESS;
 
 error:
     lyxp_expr_free(ctx, exp);
-    LOG_LOCBACK(ctx_node ? 1 : 0, 0, 0, 0);
+    LOG_LOCBACK(ctx_node ? 1 : 0, 0);
     return ret;
 }
 
@@ -458,7 +462,9 @@
     assert((prefix == LY_PATH_PREFIX_OPTIONAL) || (prefix == LY_PATH_PREFIX_MANDATORY));
     assert((pred == LY_PATH_PRED_KEYS) || (pred == LY_PATH_PRED_SIMPLE) || (pred == LY_PATH_PRED_LEAFREF));
 
-    LOG_LOCSET(cur_node, NULL, NULL, NULL);
+    if (cur_node) {
+        LOG_LOCSET(cur_node, NULL);
+    }
 
     /* parse as a generic XPath expression, reparse is performed manually */
     LY_CHECK_GOTO(ret = lyxp_expr_parse(ctx, str_path, path_len, 0, &exp), error);
@@ -480,12 +486,12 @@
 
     *expr = exp;
 
-    LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
+    LOG_LOCBACK(cur_node ? 1 : 0, 0);
     return LY_SUCCESS;
 
 error:
     lyxp_expr_free(ctx, exp);
-    LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
+    LOG_LOCBACK(cur_node ? 1 : 0, 0);
     return ret;
 }
 
@@ -545,7 +551,9 @@
 
     /* find node module */
     if (pref) {
-        LOG_LOCSET(cur_node, NULL, NULL, NULL);
+        if (cur_node) {
+            LOG_LOCSET(cur_node, NULL);
+        }
 
         mod = ly_resolve_prefix(prev_ctx_node ? prev_ctx_node->module->ctx : ctx, pref, len, format, prefix_data);
         if ((!mod || !mod->implemented) && prev_ctx_node) {
@@ -569,7 +577,7 @@
             goto error;
         }
 
-        LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
+        LOG_LOCBACK(cur_node ? 1 : 0, 0);
     } else {
         switch (format) {
         case LY_VALUE_SCHEMA:
@@ -618,7 +626,7 @@
     return LY_SUCCESS;
 
 error:
-    LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
+    LOG_LOCBACK(cur_node ? 1 : 0, 0);
     return ret;
 }
 
@@ -635,7 +643,9 @@
 
     assert(ctx && ctx_node);
 
-    LOG_LOCSET(cur_node, NULL, NULL, NULL);
+    if (cur_node) {
+        LOG_LOCSET(cur_node, NULL);
+    }
 
     *predicates = NULL;
 
@@ -697,10 +707,12 @@
                 }
 
                 /* store the value */
-                LOG_LOCSET(key, NULL, NULL, NULL);
+                if (key) {
+                    LOG_LOCSET(key, NULL);
+                }
                 ret = lyd_value_store(ctx, &p->value, ((struct lysc_node_leaf *)key)->type, val, val_len, 0, NULL,
                         format, prefix_data, LYD_HINT_DATA, key, NULL);
-                LOG_LOCBACK(key ? 1 : 0, 0, 0, 0);
+                LOG_LOCBACK(key ? 1 : 0, 0);
                 LY_CHECK_ERR_GOTO(ret, p->value.realtype = NULL, cleanup);
 
                 /* "allocate" the type to avoid problems when freeing the value after the type was freed */
@@ -761,10 +773,12 @@
         }
 
         /* store the value */
-        LOG_LOCSET(ctx_node, NULL, NULL, NULL);
+        if (ctx_node) {
+            LOG_LOCSET(ctx_node, NULL);
+        }
         ret = lyd_value_store(ctx, &p->value, ((struct lysc_node_leaflist *)ctx_node)->type, val, val_len, 0, NULL,
                 format, prefix_data, LYD_HINT_DATA, ctx_node, NULL);
-        LOG_LOCBACK(ctx_node ? 1 : 0, 0, 0, 0);
+        LOG_LOCBACK(ctx_node ? 1 : 0, 0);
         LY_CHECK_ERR_GOTO(ret, p->value.realtype = NULL, cleanup);
         ++(*tok_idx);
 
@@ -802,7 +816,7 @@
     }
 
 cleanup:
-    LOG_LOCBACK(cur_node ? 1 : 0, 0, 0, 0);
+    LOG_LOCBACK(cur_node ? 1 : 0, 0);
     return ret;
 }
 
@@ -1170,7 +1184,9 @@
 
     /* remember original context node */
     cur_node = ctx_node;
-    LOG_LOCSET(cur_node, NULL, NULL, NULL);
+    if (cur_node) {
+        LOG_LOCSET(cur_node, NULL);
+    }
 
     if (oper == LY_PATH_OPER_OUTPUT) {
         getnext_opts = LYS_GETNEXT_OUTPUT;
@@ -1272,7 +1288,7 @@
         ly_path_free(ctx, *path);
         *path = NULL;
     }
-    LOG_LOCBACK(1, 0, 0, 0);
+    LOG_LOCBACK(cur_node ? 1 : 0, 0);
     return (ret == LY_ENOTFOUND) ? LY_EVALID : ret;
 }
 
diff --git a/src/plugins_exts.h b/src/plugins_exts.h
index a2783ff..78c6e6f 100644
--- a/src/plugins_exts.h
+++ b/src/plugins_exts.h
@@ -488,12 +488,12 @@
  * @param[in] pctx Parse context to use.
  * @param[in] ext Parsed extensiopn instance.
  * @param[in] level Log message level (error, warning, etc.)
- * @param[in] err_no Error type code.
+ * @param[in] err Error type code.
  * @param[in] format Format string to print.
  * @param[in] ... Format variable parameters.
  */
 LIBYANG_API_DECL void lyplg_ext_parse_log(const struct lysp_ctx *pctx, const struct lysp_ext_instance *ext,
-        LY_LOG_LEVEL level, LY_ERR err_no, const char *format, ...);
+        LY_LOG_LEVEL level, LY_ERR err, const char *format, ...);
 
 /**
  * @brief Get current parsed module from a parse context.
@@ -579,27 +579,27 @@
  * @param[in] format Format string to print.
  */
 LIBYANG_API_DECL void lyplg_ext_compile_log(const struct lysc_ctx *cctx, const struct lysc_ext_instance *ext,
-        LY_LOG_LEVEL level, LY_ERR err_no, const char *format, ...);
+        LY_LOG_LEVEL level, LY_ERR err, const char *format, ...);
 
 /**
  * @brief Log a message from an extension plugin using the compiled extension instance with an explicit error path.
  *
- * @param[in] path Log error path to use.
+ * @param[in] path Log error schema path to use.
  * @param[in] ext Compiled extension instance.
  * @param[in] level Log message level (error, warning, etc.)
  * @param[in] err_no Error type code.
  * @param[in] format Format string to print.
  */
 LIBYANG_API_DECL void lyplg_ext_compile_log_path(const char *path, const struct lysc_ext_instance *ext,
-        LY_LOG_LEVEL level, LY_ERR err_no, const char *format, ...);
+        LY_LOG_LEVEL level, LY_ERR err, const char *format, ...);
 
 /**
  * @brief Log a message from an extension plugin using the compiled extension instance and a generated error item.
  *
- * @param[in] err Error item to log.
+ * @param[in] eitem Error item to log.
  * @param[in] ext Compiled extension instance.
  */
-LIBYANG_API_DEF void lyplg_ext_compile_log_err(const struct ly_err_item *err, const struct lysc_ext_instance *ext);
+LIBYANG_API_DEF void lyplg_ext_compile_log_err(const struct ly_err_item *eitem, const struct lysc_ext_instance *ext);
 
 /**
  * @brief YANG schema compilation context getter for libyang context.
diff --git a/src/plugins_exts/schema_mount.c b/src/plugins_exts/schema_mount.c
index fada1c2..b349921 100644
--- a/src/plugins_exts/schema_mount.c
+++ b/src/plugins_exts/schema_mount.c
@@ -904,7 +904,7 @@
 {
     LY_ERR ret = LY_SUCCESS;
     uint32_t *prev_lo, temp_lo = LY_LOSTORE_LAST, i;
-    struct ly_err_item *err;
+    const struct ly_err_item *err;
     struct lyd_node *iter, *ext_data = NULL, *ref_first = NULL, *orig_parent = lyd_parent(sibling), *op_tree;
     struct lyd_node *ext_diff = NULL, *diff_parent = NULL;
     ly_bool ext_data_free = 0;
diff --git a/src/plugins_types.c b/src/plugins_types.c
index aa31530..4af984e 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -826,7 +826,7 @@
     }
 
     /* remember the current last error */
-    e = ly_err_last(ctx);
+    e = (struct ly_err_item *)ly_err_last(ctx);
 
     /* parse the value */
     ret = ly_path_parse(ctx, ctx_node, value, value_len, 0, LY_PATH_BEGIN_ABSOLUTE, prefix_opt, LY_PATH_PRED_SIMPLE, &exp);
@@ -856,7 +856,7 @@
     lyxp_expr_free(ctx, exp);
     if (ret) {
         /* generate error, spend the context error, if any */
-        e = e ? e->next : ly_err_last(ctx);
+        e = e ? e->next : (struct ly_err_item *)ly_err_last(ctx);
         ret = ly_err_new(err, LY_EVALID, LYVE_DATA, NULL, NULL, err_fmt, (int)value_len, value, e ? ": " : ".", e ? e->msg : "");
         if (e) {
             ly_err_clean((struct ly_ctx *)ctx, e);
@@ -992,6 +992,7 @@
 {
     LY_ERR rc = LY_SUCCESS;
     struct lyxp_expr *target_path = NULL;
+    const struct ly_err_item *e;
     struct lyxp_set set = {0};
     const char *val_str, *xp_err_msg;
     uint32_t i;
@@ -1023,8 +1024,9 @@
     rc = lyxp_eval(LYD_CTX(node), target_path ? target_path : lref->path, node->schema->module,
             LY_VALUE_SCHEMA_RESOLVED, lref->prefixes, node, node, tree, NULL, &set, LYXP_IGNORE_WHEN);
     if (rc) {
-        if (ly_errcode(LYD_CTX(node)) == rc) {
-            xp_err_msg = ly_errmsg(LYD_CTX(node));
+        e = ly_err_last(LYD_CTX(node));
+        if (e && (e->err == rc)) {
+            xp_err_msg = e->msg;
         } else {
             xp_err_msg = NULL;
         }
diff --git a/src/plugins_types.h b/src/plugins_types.h
index c7ee194..8808f58 100644
--- a/src/plugins_types.h
+++ b/src/plugins_types.h
@@ -211,11 +211,11 @@
  *
  * Helper function for various plugin functions to generate error information structure.
  *
- * @param[in, out] err Pointer to store a new error structure filled according to the input parameters. If the storage
+ * @param[in,out] err Pointer to store a new error structure filled according to the input parameters. If the storage
  * already contains error information, the new record is appended into the errors list.
  * @param[in] ecode Code of the error to fill. In case LY_SUCCESS value, nothing is done and LY_SUCCESS is returned.
  * @param[in] vecode Validity error code in case of LY_EVALID error code.
- * @param[in] path Path to the node causing the error.
+ * @param[in] data_path Path to the data node causing the error.
  * @param[in] apptag Error-app-tag value.
  * @param[in] err_format Format string (same like at printf) or string literal.
  * If you want to print just an unknown string, use "%s" for the @p err_format, otherwise undefined behavior may occur
@@ -225,7 +225,7 @@
  * @return LY_EMEM If there is not enough memory for allocating error record, the @p err is not touched in that case.
  * @return LY_SUCCESS if @p ecode is LY_SUCCESS, the @p err is not touched in this case.
  */
-LIBYANG_API_DECL LY_ERR ly_err_new(struct ly_err_item **err, LY_ERR ecode, LY_VECODE vecode, char *path, char *apptag,
+LIBYANG_API_DECL LY_ERR ly_err_new(struct ly_err_item **err, LY_ERR ecode, LY_VECODE vecode, char *data_path, char *apptag,
         const char *err_format, ...) _FORMAT_PRINTF(6, 7);
 
 /**
diff --git a/src/plugins_types/date_and_time.c b/src/plugins_types/date_and_time.c
index 4fb0c95..596bb9c 100644
--- a/src/plugins_types/date_and_time.c
+++ b/src/plugins_types/date_and_time.c
@@ -114,7 +114,7 @@
     /* convert to UNIX time and fractions of second */
     ret = ly_time_str2time(value, &val->time, &val->fractions_s);
     if (ret) {
-        ret = ly_err_new(err, ret, 0, NULL, NULL, "%s", ly_last_errmsg());
+        ret = ly_err_new(err, ret, 0, NULL, NULL, "%s", ly_last_logmsg());
         goto cleanup;
     }
 
diff --git a/src/plugins_types/instanceid_keys.c b/src/plugins_types/instanceid_keys.c
index 5d8f5a4..9490344 100644
--- a/src/plugins_types/instanceid_keys.c
+++ b/src/plugins_types/instanceid_keys.c
@@ -140,6 +140,7 @@
     struct lysc_type_str *type_str = (struct lysc_type_str *)type;
     struct lyd_value_instance_identifier_keys *val;
     uint32_t *prev_lo, temp_lo = LY_LOSTORE;
+    const struct ly_err_item *eitem;
     char *canon;
 
     /* init storage */
@@ -176,7 +177,8 @@
             LY_PATH_PRED_KEYS, &val->keys);
     ly_temp_log_options(prev_lo);
     if (ret) {
-        ret = ly_err_new(err, ret, LYVE_DATA, NULL, NULL, "%s", ly_errmsg(ctx));
+        eitem = ly_err_last(ctx);
+        ret = ly_err_new(err, ret, LYVE_DATA, eitem->data_path, NULL, "%s", eitem->msg);
         ly_err_clean((struct ly_ctx *)ctx, NULL);
         goto cleanup;
     }
diff --git a/src/plugins_types/xpath1.0.c b/src/plugins_types/xpath1.0.c
index e574862..02b2449 100644
--- a/src/plugins_types/xpath1.0.c
+++ b/src/plugins_types/xpath1.0.c
@@ -386,6 +386,7 @@
     struct ly_set *set = NULL;
     uint32_t i;
     const char *pref, *uri;
+    const struct ly_err_item *eitem;
 
     *err = NULL;
     LYD_VALUE_GET(storage, val);
@@ -429,7 +430,8 @@
     if (ret == LY_EMEM) {
         ly_err_new(err, LY_EMEM, LYVE_DATA, NULL, NULL, LY_EMEM_MSG);
     } else if (ret) {
-        ly_err_new(err, ret, LYVE_DATA, NULL, NULL, "%s", ly_errmsg(LYD_CTX(ctx_node)));
+        eitem = ly_err_last(LYD_CTX(ctx_node));
+        ly_err_new(err, ret, LYVE_DATA, eitem->data_path, NULL, "%s", eitem->msg);
     }
     return ret;
 }
@@ -460,7 +462,7 @@
     /* print in the specific format */
     if (lyplg_type_print_xpath10_value(val, format, prefix_data, &ret, &err)) {
         if (err) {
-            LOGVAL_ERRITEM(ctx, err);
+            ly_err_print(ctx, err);
             ly_err_free(err);
         }
         return NULL;
diff --git a/src/schema_compile.c b/src/schema_compile.c
index 18e7a96..9d71afc 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -88,9 +88,11 @@
         if (nextlevel != 2) {
             if ((parent_module && (parent_module == ctx->cur_mod)) || (!parent_module && (ctx->path_len > 1) && (name[0] == '{'))) {
                 /* module not changed, print the name unprefixed */
-                len = snprintf(&ctx->path[ctx->path_len], LYSC_CTX_BUFSIZE - ctx->path_len, "%s%s", nextlevel ? "/" : "", name);
+                len = snprintf(&ctx->path[ctx->path_len], LYSC_CTX_BUFSIZE - ctx->path_len, "%s%s",
+                        nextlevel ? "/" : "", name);
             } else {
-                len = snprintf(&ctx->path[ctx->path_len], LYSC_CTX_BUFSIZE - ctx->path_len, "%s%s:%s", nextlevel ? "/" : "", ctx->cur_mod->name, name);
+                len = snprintf(&ctx->path[ctx->path_len], LYSC_CTX_BUFSIZE - ctx->path_len, "%s%s:%s",
+                        nextlevel ? "/" : "", ctx->cur_mod->name, name);
             }
         } else {
             len = snprintf(&ctx->path[ctx->path_len], LYSC_CTX_BUFSIZE - ctx->path_len, "='%s'}", name);
@@ -103,8 +105,8 @@
         }
     }
 
-    LOG_LOCBACK(0, 0, 1, 0);
-    LOG_LOCSET(NULL, NULL, ctx->path, NULL);
+    ly_log_location_revert(0, 0, 1, 0);
+    ly_log_location(NULL, NULL, ctx->path, NULL);
 }
 
 /**
@@ -523,7 +525,7 @@
         do {
             struct lysc_when **when_list, *when;
 
-            LOG_LOCSET(node, NULL, NULL, NULL);
+            LOG_LOCSET(node, NULL);
             when_list = lysc_node_when(node);
             LY_ARRAY_FOR(when_list, u) {
                 when = when_list[u];
@@ -531,7 +533,7 @@
                         when->context, when->context, &tmp_set, LYXP_SCNODE_SCHEMA);
                 if (ret != LY_SUCCESS) {
                     LOGVAL(set->ctx, LYVE_SEMANTICS, "Invalid when condition \"%s\".", when->cond->expr);
-                    LOG_LOCBACK(1, 0, 0, 0);
+                    LOG_LOCBACK(1, 0);
                     goto cleanup;
                 }
 
@@ -548,7 +550,7 @@
                         LOGVAL(set->ctx, LYVE_SEMANTICS, "When condition cyclic dependency on the node \"%s\".",
                                 tmp_set.val.scnodes[j].scnode->name);
                         ret = LY_EVALID;
-                        LOG_LOCBACK(1, 0, 0, 0);
+                        LOG_LOCBACK(1, 0);
                         goto cleanup;
                     }
 
@@ -565,14 +567,14 @@
                     } else {
                         /* context node was traversed, so just add the dependent node */
                         ret = lyxp_set_scnode_insert_node(&tmp_set, node, LYXP_SET_SCNODE_START_USED, LYXP_AXIS_CHILD, NULL);
-                        LY_CHECK_ERR_GOTO(ret, LOG_LOCBACK(1, 0, 0, 0), cleanup);
+                        LY_CHECK_ERR_GOTO(ret, LOG_LOCBACK(1, 0), cleanup);
                     }
                 }
 
                 /* merge this set into the global when set */
                 lyxp_set_scnode_merge(set, &tmp_set);
             }
-            LOG_LOCBACK(1, 0, 0, 0);
+            LOG_LOCBACK(1, 0);
 
             /* check when of non-data parents as well */
             node = node->parent;
@@ -706,7 +708,7 @@
     LY_ERR ret = LY_SUCCESS;
     uint16_t flg;
 
-    LOG_LOCSET(node, NULL, NULL, NULL);
+    LOG_LOCSET(node, NULL);
 
     memset(&tmp_set, 0, sizeof tmp_set);
     opts = LYXP_SCNODE_SCHEMA | ((node->flags & LYS_IS_OUTPUT) ? LYXP_SCNODE_OUTPUT : 0);
@@ -750,7 +752,7 @@
 
 cleanup:
     lyxp_set_free_content(&tmp_set);
-    LOG_LOCBACK(1, 0, 0, 0);
+    LOG_LOCBACK(1, 0);
     return ret;
 }
 
@@ -946,14 +948,14 @@
     }
 
     if (ret) {
-        LOG_LOCSET(node, NULL, NULL, NULL);
+        LOG_LOCSET(node, NULL);
         if (err) {
             LOGVAL(ctx->ctx, LYVE_SEMANTICS, "Invalid default - value does not fit the type (%s).", err->msg);
             ly_err_free(err);
         } else {
             LOGVAL(ctx->ctx, LYVE_SEMANTICS, "Invalid default - value does not fit the type.");
         }
-        LOG_LOCBACK(1, 0, 0, 0);
+        LOG_LOCBACK(1, 0);
         return ret;
     }
 
@@ -1245,12 +1247,12 @@
         l = ds_unres->disabled_leafrefs.objs[i];
         LYSC_CTX_INIT_PMOD(cctx, l->node->module->parsed, l->ext);
 
-        LOG_LOCSET(l->node, NULL, NULL, NULL);
+        LOG_LOCSET(l->node, NULL);
         v = 0;
         while ((ret == LY_SUCCESS) && (lref = lys_type_leafref_next(l->node, &v))) {
             ret = lys_compile_unres_leafref(&cctx, l->node, lref, l->local_mod);
         }
-        LOG_LOCBACK(1, 0, 0, 0);
+        LOG_LOCBACK(1, 0);
         LY_CHECK_GOTO(ret, cleanup);
 
         ly_set_rm_index(&ds_unres->disabled_leafrefs, i, free);
@@ -1264,12 +1266,12 @@
         l = ds_unres->leafrefs.objs[i];
         LYSC_CTX_INIT_PMOD(cctx, l->node->module->parsed, l->ext);
 
-        LOG_LOCSET(l->node, NULL, NULL, NULL);
+        LOG_LOCSET(l->node, NULL);
         v = 0;
         while ((ret == LY_SUCCESS) && (lref = lys_type_leafref_next(l->node, &v))) {
             ret = lys_compile_unres_leafref(&cctx, l->node, lref, l->local_mod);
         }
-        LOG_LOCBACK(1, 0, 0, 0);
+        LOG_LOCBACK(1, 0);
         LY_CHECK_GOTO(ret, cleanup);
     }
     for (i = processed_leafrefs; i < ds_unres->leafrefs.count; ++i) {
@@ -1297,9 +1299,11 @@
         w = ds_unres->whens.objs[i];
         LYSC_CTX_INIT_PMOD(cctx, w->node->module->parsed, NULL);
 
-        LOG_LOCSET(w->node, NULL, NULL, NULL);
+        if (w->node) {
+            LOG_LOCSET(w->node, NULL);
+        }
         ret = lys_compile_unres_when(&cctx, w->when, w->node);
-        LOG_LOCBACK(w->node ? 1 : 0, 0, 0, 0);
+        LOG_LOCBACK(w->node ? 1 : 0, 0);
         LY_CHECK_GOTO(ret, cleanup);
 
         free(w);
@@ -1312,9 +1316,9 @@
         m = ds_unres->musts.objs[i];
         LYSC_CTX_INIT_PMOD(cctx, m->node->module->parsed, m->ext);
 
-        LOG_LOCSET(m->node, NULL, NULL, NULL);
+        LOG_LOCSET(m->node, NULL);
         ret = lys_compile_unres_must(&cctx, m->node, m->local_mods);
-        LOG_LOCBACK(1, 0, 0, 0);
+        LOG_LOCBACK(1, 0);
         LY_CHECK_GOTO(ret, cleanup);
 
         lysc_unres_must_free(m);
@@ -1327,9 +1331,9 @@
         node = ds_unres->disabled_bitenums.objs[i];
         LYSC_CTX_INIT_PMOD(cctx, node->module->parsed, NULL);
 
-        LOG_LOCSET(node, NULL, NULL, NULL);
+        LOG_LOCSET(node, NULL);
         ret = lys_compile_unres_disabled_bitenum(&cctx, (struct lysc_node_leaf *)node);
-        LOG_LOCBACK(1, 0, 0, 0);
+        LOG_LOCBACK(1, 0);
         LY_CHECK_GOTO(ret, cleanup);
 
         ly_set_rm_index(&ds_unres->disabled_bitenums, i, NULL);
@@ -1341,13 +1345,13 @@
         d = ds_unres->dflts.objs[i];
         LYSC_CTX_INIT_PMOD(cctx, d->leaf->module->parsed, NULL);
 
-        LOG_LOCSET(&d->leaf->node, NULL, NULL, NULL);
+        LOG_LOCSET(&d->leaf->node, NULL);
         if (d->leaf->nodetype == LYS_LEAF) {
             ret = lys_compile_unres_leaf_dlft(&cctx, d->leaf, d->dflt, unres);
         } else {
             ret = lys_compile_unres_llist_dflts(&cctx, d->llist, d->dflt, d->dflts, unres);
         }
-        LOG_LOCBACK(1, 0, 0, 0);
+        LOG_LOCBACK(1, 0);
         LY_CHECK_GOTO(ret, cleanup);
 
         lysc_unres_dflt_free(ctx, d);
@@ -1364,9 +1368,9 @@
     for (i = 0; i < ds_unres->disabled.count; ++i) {
         node = ds_unres->disabled.snodes[i];
         if (node->flags & LYS_KEY) {
-            LOG_LOCSET(node, NULL, NULL, NULL);
+            LOG_LOCSET(node, NULL);
             LOGVAL(ctx, LYVE_REFERENCE, "Key \"%s\" is disabled.", node->name);
-            LOG_LOCBACK(1, 0, 0, 0);
+            LOG_LOCBACK(1, 0);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -1389,10 +1393,10 @@
 
             assert(ret != LY_ERECOMPILE);
             if (ret) {
-                LOG_LOCSET(l->node, NULL, NULL, NULL);
+                LOG_LOCSET(l->node, NULL);
                 LOGVAL(ctx, LYVE_REFERENCE, "Target of leafref \"%s\" cannot be referenced because it is disabled.",
                         l->node->name);
-                LOG_LOCBACK(1, 0, 0, 0);
+                LOG_LOCBACK(1, 0);
                 ret = LY_EVALID;
                 goto cleanup;
             }
@@ -1727,13 +1731,13 @@
     }
     ctx.pmod = sp;
 
-    LOG_LOCBACK(0, 0, 1, 0);
+    ly_log_location_revert(0, 0, 1, 0);
 
     /* finish compilation for all unresolved module items in the context */
     LY_CHECK_GOTO(ret = lys_compile_unres_mod(&ctx), cleanup);
 
 cleanup:
-    LOG_LOCBACK(0, 0, 1, 0);
+    ly_log_location_revert(0, 0, 1, 0);
     lys_compile_unres_mod_erase(&ctx, ret);
     if (ret) {
         lysc_module_free(&ctx.free_ctx, mod_c);
@@ -1784,7 +1788,7 @@
 
 cleanup:
     /* always needed when using lysc_update_path() */
-    LOG_LOCBACK(0, 0, 1, 0);
+    ly_log_location_revert(0, 0, 1, 0);
     return rc;
 }
 
diff --git a/src/tree_data.c b/src/tree_data.c
index 2d63f8d..24b5715 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -103,6 +103,7 @@
     struct lyd_ctx *lydctx = NULL;
     struct ly_set parsed = {0};
     uint32_t i, int_opts = 0;
+    const struct ly_err_item *eitem;
     ly_bool subtree_sibling = 0;
 
     assert(ctx && (parent || first_p));
@@ -141,8 +142,14 @@
     }
     if (r) {
         rc = r;
-        if ((r != LY_EVALID) || !lydctx || !(lydctx->val_opts & LYD_VALIDATE_MULTI_ERROR) ||
-                (ly_vecode(ctx) == LYVE_SYNTAX)) {
+        if ((r != LY_EVALID) || !lydctx || !(lydctx->val_opts & LYD_VALIDATE_MULTI_ERROR)) {
+            goto cleanup;
+        }
+
+        eitem = ly_err_last(ctx);
+        assert(eitem);
+        if (eitem->vecode == LYVE_SYNTAX) {
+            /* cannot get more errors on a syntax error */
             goto cleanup;
         }
     }
diff --git a/src/tree_data_common.c b/src/tree_data_common.c
index 26b6016..85744e7 100644
--- a/src/tree_data_common.c
+++ b/src/tree_data_common.c
@@ -474,6 +474,35 @@
     return mod;
 }
 
+/**
+ * @brief Log generated error item and use log location information if not in the error item.
+ *
+ * @param[in] ctx Context to use.
+ * @param[in] node Optional data node to log.
+ * @param[in] scnode Optional schema node to log.
+ * @param[in] eitem Error item to log.
+ */
+static void
+ly_err_print_build_path(const struct ly_ctx *ctx, const struct lyd_node *node, const struct lysc_node *scnode,
+        struct ly_err_item *eitem)
+{
+    if (eitem->data_path || eitem->schema_path || eitem->line) {
+        ly_err_print(ctx, eitem);
+    } else {
+        if (node) {
+            LOG_LOCSET(NULL, node);
+        } else if (scnode) {
+            LOG_LOCSET(scnode, NULL);
+        }
+        ly_vlog(ctx, eitem->apptag, eitem->err == LY_EVALID ? eitem->vecode : LYVE_DATA, "%s", eitem->msg);
+        if (node) {
+            LOG_LOCBACK(0, 1);
+        } else if (scnode) {
+            LOG_LOCBACK(1, 0);
+        }
+    }
+}
+
 LY_ERR
 lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct lysc_type *type, const void *value,
         size_t value_len, ly_bool is_utf8, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
@@ -508,7 +537,7 @@
         }
     } else if (ret) {
         if (err) {
-            LOGVAL_ERRITEM(ctx, err);
+            ly_err_print_build_path(ctx, NULL, ctx_node, err);
             ly_err_free(err);
         } else {
             LOGVAL(ctx, LYVE_OTHER, "Storing value failed.");
@@ -531,7 +560,7 @@
     ret = type->plugin->validate(ctx, type, ctx_node, tree, val, &err);
     if (ret) {
         if (err) {
-            LOGVAL_ERRITEM(ctx, err);
+            ly_err_print_build_path(ctx, ctx_node, NULL, err);
             ly_err_free(err);
         } else {
             LOGVAL(ctx, LYVE_OTHER, "Resolving value \"%s\" failed.",
@@ -569,17 +598,7 @@
     } else if (rc && err) {
         if (ctx) {
             /* log only in case the ctx was provided as input parameter */
-            if (err->path) {
-                LOG_LOCSET(NULL, NULL, err->path, NULL);
-            } else {
-                LOG_LOCSET(node, NULL, NULL, NULL);
-            }
-            LOGVAL_ERRITEM(ctx, err);
-            if (err->path) {
-                LOG_LOCBACK(0, 0, 1, 0);
-            } else {
-                LOG_LOCBACK(1, 0, 1, 0);
-            }
+            ly_err_print_build_path(ctx, NULL, node, err);
         }
         ly_err_free(err);
     }
@@ -626,21 +645,7 @@
     if (rc && (rc != LY_EINCOMPLETE) && err) {
         if (log) {
             /* log error */
-            if (err->path) {
-                LOG_LOCSET(NULL, NULL, err->path, NULL);
-            } else if (ctx_node) {
-                LOG_LOCSET(NULL, ctx_node, NULL, NULL);
-            } else {
-                LOG_LOCSET(schema, NULL, NULL, NULL);
-            }
-            LOGVAL_ERRITEM(ctx, err);
-            if (err->path) {
-                LOG_LOCBACK(0, 0, 1, 0);
-            } else if (ctx_node) {
-                LOG_LOCBACK(0, 1, 0, 0);
-            } else {
-                LOG_LOCBACK(1, 0, 0, 0);
-            }
+            ly_err_print_build_path(ctx, ctx_node, schema, err);
         }
         ly_err_free(err);
     }
@@ -682,9 +687,9 @@
     type = ((struct lysc_node_leaf *)node->schema)->type;
 
     /* store the value */
-    LOG_LOCSET(node->schema, &node->node, NULL, NULL);
+    LOG_LOCSET(NULL, &node->node);
     ret = lyd_value_store(ctx, &val, type, value, value_len, 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, node->schema, NULL);
-    LOG_LOCBACK(1, 1, 0, 0);
+    LOG_LOCBACK(0, 1);
     LY_CHECK_RET(ret);
 
     /* compare values */
@@ -850,7 +855,7 @@
     const struct lyd_node *parent;
     const struct lys_module *mod;
     const struct lysc_node *sparent, *snode;
-    uint32_t loc_node = 0, loc_path = 0;
+    uint32_t loc_scnode = 0, loc_dnode = 0;
 
     LY_CHECK_ARG_RET(LYD_CTX(node), node, !node->schema, LY_EINVAL);
 
@@ -859,13 +864,9 @@
     parent = lyd_parent(node);
     sparent = lyd_node_schema(parent);
 
-    if (parent) {
-        LOG_LOCSET(NULL, parent, NULL, NULL);
-        ++loc_node;
-    } else {
-        LOG_LOCSET(NULL, NULL, "/", NULL);
-        ++loc_path;
-    }
+    /* if parent is NULL, it is still added as root */
+    LOG_LOCSET(NULL, parent);
+    loc_dnode = 1;
 
     if (!opaq->name.module_ns) {
         LOGVAL(ctx, LYVE_REFERENCE, "Unknown module of node \"%s\".", opaq->name.name);
@@ -928,11 +929,10 @@
     }
 
     /* schema node exists */
-    LOG_LOCBACK(0, loc_node, loc_path, 0);
-    loc_node = 0;
-    loc_path = 0;
-    LOG_LOCSET(NULL, node, NULL, NULL);
-    ++loc_node;
+    LOG_LOCBACK(0, 1);
+    loc_dnode = 0;
+    LOG_LOCSET(snode, NULL);
+    loc_scnode = 1;
 
     if (snode->nodetype & LYD_NODE_TERM) {
         /* leaf / leaf-list */
@@ -960,7 +960,7 @@
     rc = LY_EINVAL;
 
 cleanup:
-    LOG_LOCBACK(0, loc_node, loc_path, 0);
+    LOG_LOCBACK(loc_scnode, loc_dnode);
     return rc;
 }
 
diff --git a/src/tree_data_new.c b/src/tree_data_new.c
index a7d26db..1f283e1 100644
--- a/src/tree_data_new.c
+++ b/src/tree_data_new.c
@@ -66,10 +66,10 @@
     term->prev = &term->node;
     term->flags = LYD_NEW;
 
-    LOG_LOCSET(schema, NULL, NULL, NULL);
+    LOG_LOCSET(schema, NULL);
     ret = lyd_value_store(schema->module->ctx, &term->value, ((struct lysc_node_leaf *)term->schema)->type, value,
             value_len, is_utf8, dynamic, format, prefix_data, hints, schema, incomplete);
-    LOG_LOCBACK(1, 0, 0, 0);
+    LOG_LOCBACK(1, 0);
     LY_CHECK_ERR_RET(ret, free(term), ret);
     lyd_hash(&term->node);
 
@@ -149,7 +149,7 @@
     /* create list */
     LY_CHECK_GOTO(ret = lyd_create_inner(schema, &list), cleanup);
 
-    LOG_LOCSET(schema, NULL, NULL, NULL);
+    LOG_LOCSET(schema, NULL);
 
     /* create and insert all the keys */
     LY_ARRAY_FOR(predicates, u) {
@@ -160,10 +160,10 @@
             }
 
             /* store the value */
-            LOG_LOCSET(predicates[u].key, NULL, NULL, NULL);
+            LOG_LOCSET(predicates[u].key, NULL);
             ret = lyd_value_store(schema->module->ctx, &val, ((struct lysc_node_leaf *)predicates[u].key)->type,
                     var->value, strlen(var->value), 0, NULL, LY_VALUE_JSON, NULL, LYD_HINT_DATA, predicates[u].key, NULL);
-            LOG_LOCBACK(1, 0, 0, 0);
+            LOG_LOCBACK(1, 0);
             LY_CHECK_GOTO(ret, cleanup);
 
             value = &val;
@@ -189,7 +189,7 @@
     list = NULL;
 
 cleanup:
-    LOG_LOCBACK(1, 0, 0, 0);
+    LOG_LOCBACK(1, 0);
     lyd_free_tree(list);
     return ret;
 }
@@ -202,7 +202,7 @@
     uint32_t exp_idx = 0;
     struct ly_path_predicate *predicates = NULL;
 
-    LOG_LOCSET(schema, NULL, NULL, NULL);
+    LOG_LOCSET(schema, NULL);
 
     /* parse keys */
     LY_CHECK_GOTO(ret = ly_path_parse_predicate(schema->module->ctx, NULL, keys, keys_len, LY_PATH_PREFIX_OPTIONAL,
@@ -216,7 +216,7 @@
     LY_CHECK_GOTO(ret = lyd_create_list(schema, predicates, NULL, node), cleanup);
 
 cleanup:
-    LOG_LOCBACK(1, 0, 0, 0);
+    LOG_LOCBACK(1, 0);
     lyxp_expr_free(schema->module->ctx, expr);
     ly_path_predicates_free(schema->module->ctx, predicates);
     return ret;
@@ -1302,10 +1302,10 @@
     type = ((struct lysc_node_leaf *)term->schema)->type;
 
     /* parse the new value */
-    LOG_LOCSET(term->schema, term, NULL, NULL);
+    LOG_LOCSET(term->schema, term);
     ret = lyd_value_store(LYD_CTX(term), &val, type, value, value_len, 0, NULL, format, NULL, LYD_HINT_DATA,
             term->schema, NULL);
-    LOG_LOCBACK(term->schema ? 1 : 0, 1, 0, 0);
+    LOG_LOCBACK(1, 1);
     LY_CHECK_GOTO(ret, cleanup);
 
     /* compare original and new value */
@@ -1541,19 +1541,19 @@
                 create = 1;
                 new_count = u;
             } else if (path[u].predicates[0].type != LY_PATH_PREDTYPE_POSITION) {
-                LOG_LOCSET(schema, NULL, NULL, NULL);
+                LOG_LOCSET(schema, NULL);
                 LOGVAL(schema->module->ctx, LYVE_XPATH, "Invalid predicate for state %s \"%s\" in path \"%s\".",
                         lys_nodetype2str(schema->nodetype), schema->name, str_path);
-                LOG_LOCBACK(1, 0, 0, 0);
+                LOG_LOCBACK(1, 0);
                 return LY_EINVAL;
             }
         } else if ((schema->nodetype == LYS_LIST) &&
                 (!path[u].predicates || (path[u].predicates[0].type != LY_PATH_PREDTYPE_LIST))) {
             if ((u < LY_ARRAY_COUNT(path) - 1) || !(options & LYD_NEW_PATH_OPAQ)) {
-                LOG_LOCSET(schema, NULL, NULL, NULL);
+                LOG_LOCSET(schema, NULL);
                 LOGVAL(schema->module->ctx, LYVE_XPATH, "Predicate missing for %s \"%s\" in path \"%s\".",
                         lys_nodetype2str(schema->nodetype), schema->name, str_path);
-                LOG_LOCBACK(1, 0, 0, 0);
+                LOG_LOCBACK(1, 0);
                 return LY_EINVAL;
             } /* else creating an opaque list */
         } else if ((schema->nodetype == LYS_LEAFLIST) &&
@@ -1665,9 +1665,9 @@
             if (orig_count == LY_ARRAY_COUNT(p)) {
                 /* the node exists, are we supposed to update it or is it just a default? */
                 if (!(options & LYD_NEW_PATH_UPDATE) && !(node->flags & LYD_DEFAULT)) {
-                    LOG_LOCSET(NULL, node, NULL, NULL);
+                    LOG_LOCSET(NULL, node);
                     LOGVAL(ctx, LYVE_REFERENCE, "Path \"%s\" already exists.", path);
-                    LOG_LOCBACK(0, 1, 0, 0);
+                    LOG_LOCBACK(0, 1);
                     ret = LY_EEXIST;
                     goto cleanup;
                 } else if ((options & LYD_NEW_PATH_UPDATE) && lysc_is_key(node->schema)) {
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 488a03f..77bbd8e 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -1380,12 +1380,12 @@
             if ((r = lysp_resolve_ext_instance_log_path(pctx, ext, &path))) {
                 return r;
             }
-            LOG_LOCSET(NULL, NULL, path, NULL);
+            ly_log_location(NULL, NULL, path, NULL);
 
             /* parse */
             r = ext->record->plugin.parse(pctx, ext);
 
-            LOG_LOCBACK(0, 0, 1, 0);
+            ly_log_location_revert(0, 0, 1, 0);
             free(path);
 
             if (r == LY_ENOT) {
@@ -1886,9 +1886,9 @@
         if (mod && mod->name) {
             /* there are cases when path is not available for parsing error, so this additional
              * message tries to add information about the module where the error occurred */
-            struct ly_err_item *e = ly_err_last(ctx);
+            const struct ly_err_item *e = ly_err_last(ctx);
 
-            if (e && (!e->path || !strncmp(e->path, "Line ", ly_strlen_const("Line ")))) {
+            if (e && (!e->schema_path || e->line)) {
                 LOGERR(ctx, ret, "Parsing module \"%s\" failed.", mod->name);
             }
         }
diff --git a/src/validation.c b/src/validation.c
index f150784..93a79c7 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -276,7 +276,7 @@
     do {
         --i;
         node = node_when->dnodes[i];
-        LOG_LOCSET(node->schema, node, NULL, NULL);
+        LOG_LOCSET(node->schema, node);
 
         /* evaluate all when expressions that affect this node's existence */
         r = lyd_validate_node_when(*tree, node, node->schema, xpath_options, &disabled);
@@ -307,13 +307,13 @@
             LY_VAL_ERR_GOTO(r, rc = r, val_opts, error);
         }
 
-        LOG_LOCBACK(1, 1, 0, 0);
+        LOG_LOCBACK(1, 1);
     } while (i);
 
     return rc;
 
 error:
-    LOG_LOCBACK(1, 1, 0, 0);
+    LOG_LOCBACK(1, 1);
     return rc;
 }
 
@@ -385,9 +385,9 @@
             struct lysc_type *type = ((struct lysc_node_leaf *)node->schema)->type;
 
             /* resolve the value of the node */
-            LOG_LOCSET(NULL, &node->node, NULL, NULL);
+            LOG_LOCSET(NULL, &node->node);
             r = lyd_value_validate_incomplete(LYD_CTX(node), type, &node->value, &node->node, *tree);
-            LOG_LOCBACK(0, 1, 0, 0);
+            LOG_LOCBACK(0, 1);
             LY_VAL_ERR_GOTO(r, rc = r, val_opts, cleanup);
 
             /* remove this node from the set */
@@ -471,13 +471,13 @@
     if (fail) {
         if ((node->schema->nodetype & (LYS_LIST | LYS_LEAFLIST)) && (val_opts & LYD_VALIDATE_OPERATIONAL)) {
             /* only a warning */
-            LOG_LOCSET(NULL, node, NULL, NULL);
+            LOG_LOCSET(NULL, node);
             LOGWRN(node->schema->module->ctx, "Duplicate instance of \"%s\".", node->schema->name);
-            LOG_LOCBACK(0, 1, 0, 0);
+            LOG_LOCBACK(0, 1);
         } else {
-            LOG_LOCSET(NULL, node, NULL, NULL);
+            LOG_LOCSET(NULL, node);
             LOGVAL(node->schema->module->ctx, LY_VCODE_DUP, node->schema->name);
-            LOG_LOCBACK(0, 1, 0, 0);
+            LOG_LOCBACK(0, 1);
             return LY_EVALID;
         }
     }
@@ -501,7 +501,7 @@
     struct lyd_node *match, *to_del;
     ly_bool found;
 
-    LOG_LOCSET(&choic->node, NULL, NULL, NULL);
+    LOG_LOCSET(&choic->node, NULL);
 
     LY_LIST_FOR((struct lysc_node *)choic->cases, scase) {
         found = 0;
@@ -525,7 +525,7 @@
             if (old_case) {
                 /* old data from 2 cases */
                 LOGVAL(choic->module->ctx, LY_VCODE_DUPCASE, old_case->name, scase->name);
-                LOG_LOCBACK(1, 0, 0, 0);
+                LOG_LOCBACK(1, 0);
                 return LY_EVALID;
             }
 
@@ -535,7 +535,7 @@
             if (new_case) {
                 /* new data from 2 cases */
                 LOGVAL(choic->module->ctx, LY_VCODE_DUPCASE, new_case->name, scase->name);
-                LOG_LOCBACK(1, 0, 0, 0);
+                LOG_LOCBACK(1, 0);
                 return LY_EVALID;
             }
 
@@ -544,7 +544,7 @@
         }
     }
 
-    LOG_LOCBACK(1, 0, 0, 0);
+    LOG_LOCBACK(1, 0);
 
     if (old_case && new_case) {
         /* auto-delete old case */
@@ -964,22 +964,22 @@
     if (!disabled) {
         if (val_opts & LYD_VALIDATE_OPERATIONAL) {
             /* only a warning */
-            LOG_LOCSET(parent ? NULL : snode, parent, NULL, NULL);
+            LOG_LOCSET(parent ? NULL : snode, parent);
             if (snode->nodetype == LYS_CHOICE) {
                 LOGWRN(snode->module->ctx, "Mandatory choice \"%s\" data do not exist.", snode->name);
             } else {
                 LOGWRN(snode->module->ctx, "Mandatory node \"%s\" instance does not exist.", snode->name);
             }
-            LOG_LOCBACK(parent ? 0 : 1, parent ? 1 : 0, 0, 0);
+            LOG_LOCBACK(parent ? 0 : 1, parent ? 1 : 0);
         } else {
             /* node instance not found */
-            LOG_LOCSET(parent ? NULL : snode, parent, NULL, NULL);
+            LOG_LOCSET(parent ? NULL : snode, parent);
             if (snode->nodetype == LYS_CHOICE) {
                 LOGVAL_APPTAG(snode->module->ctx, "missing-choice", LY_VCODE_NOMAND_CHOIC, snode->name);
             } else {
                 LOGVAL(snode->module->ctx, LY_VCODE_NOMAND, snode->name);
             }
-            LOG_LOCBACK(parent ? 0 : 1, parent ? 1 : 0, 0, 0);
+            LOG_LOCBACK(parent ? 0 : 1, parent ? 1 : 0);
             return LY_EVALID;
         }
     }
@@ -1047,25 +1047,25 @@
     if (min) {
         if (val_opts & LYD_VALIDATE_OPERATIONAL) {
             /* only a warning */
-            LOG_LOCSET(snode, NULL, NULL, NULL);
+            LOG_LOCSET(snode, NULL);
             LOGWRN(snode->module->ctx, "Too few \"%s\" instances.", snode->name);
-            LOG_LOCBACK(1, 0, 0, 0);
+            LOG_LOCBACK(1, 0);
         } else {
-            LOG_LOCSET(snode, NULL, NULL, NULL);
+            LOG_LOCSET(snode, NULL);
             LOGVAL_APPTAG(snode->module->ctx, "too-few-elements", LY_VCODE_NOMIN, snode->name);
-            LOG_LOCBACK(1, 0, 0, 0);
+            LOG_LOCBACK(1, 0);
             return LY_EVALID;
         }
     } else if (max) {
         if (val_opts & LYD_VALIDATE_OPERATIONAL) {
             /* only a warning */
-            LOG_LOCSET(NULL, iter, NULL, NULL);
+            LOG_LOCSET(NULL, iter);
             LOGWRN(snode->module->ctx, "Too many \"%s\" instances.", snode->name);
-            LOG_LOCBACK(0, 1, 0, 0);
+            LOG_LOCBACK(0, 1);
         } else {
-            LOG_LOCSET(NULL, iter, NULL, NULL);
+            LOG_LOCSET(NULL, iter);
             LOGVAL_APPTAG(snode->module->ctx, "too-many-elements", LY_VCODE_NOMAX, snode->name);
-            LOG_LOCBACK(0, 1, 0, 0);
+            LOG_LOCBACK(0, 1);
             return LY_EVALID;
         }
     }
@@ -1201,14 +1201,14 @@
 
                 ptr += strlen(ptr);
             }
-            LOG_LOCSET(NULL, second, NULL, NULL);
+            LOG_LOCSET(NULL, second);
             if (arg->val_opts & LYD_VALIDATE_OPERATIONAL) {
                 /* only a warning */
                 LOGWRN(ctx, "Unique data leaf(s) \"%s\" not satisfied in \"%s\" and \"%s\".", uniq_str, path1, path2);
             } else {
                 LOGVAL_APPTAG(ctx, "data-not-unique", LY_VCODE_NOUNIQ, uniq_str, path1, path2);
             }
-            LOG_LOCBACK(0, 1, 0, 0);
+            LOG_LOCBACK(0, 1);
 
             free(path1);
             free(path2);
@@ -1434,9 +1434,9 @@
     snode = node->schema;
     do {
         if (snode->flags & LYS_STATUS_OBSLT) {
-            LOG_LOCSET(NULL, node, NULL, NULL);
+            LOG_LOCSET(NULL, node);
             LOGWRN(snode->module->ctx, "Obsolete schema node \"%s\" instantiated in data.", snode->name);
-            LOG_LOCBACK(0, 1, 0, 0);
+            LOG_LOCBACK(0, 1);
             break;
         }
 
@@ -1506,24 +1506,24 @@
             if (val_opts & LYD_VALIDATE_OPERATIONAL) {
                 /* only a warning */
                 emsg = musts[u].emsg;
-                LOG_LOCSET(NULL, node, NULL, NULL);
+                LOG_LOCSET(NULL, node);
                 if (emsg) {
                     LOGWRN(LYD_CTX(node), "%s", emsg);
                 } else {
                     LOGWRN(LYD_CTX(node), "Must condition \"%s\" not satisfied.", musts[u].cond->expr);
                 }
-                LOG_LOCBACK(0, 1, 0, 0);
+                LOG_LOCBACK(0, 1);
             } else {
                 /* use specific error information */
                 emsg = musts[u].emsg;
                 eapptag = musts[u].eapptag ? musts[u].eapptag : "must-violation";
-                LOG_LOCSET(NULL, node, NULL, NULL);
+                LOG_LOCSET(NULL, node);
                 if (emsg) {
                     LOGVAL_APPTAG(LYD_CTX(node), eapptag, LYVE_DATA, "%s", emsg);
                 } else {
                     LOGVAL_APPTAG(LYD_CTX(node), eapptag, LY_VCODE_NOMUST, musts[u].cond->expr);
                 }
-                LOG_LOCBACK(0, 1, 0, 0);
+                LOG_LOCBACK(0, 1);
                 r = LY_EVALID;
                 LY_VAL_ERR_GOTO(r, rc = r, val_opts, cleanup);
             }
@@ -1588,9 +1588,9 @@
             innode = "notification";
         }
         if (innode) {
-            LOG_LOCSET(NULL, node, NULL, NULL);
+            LOG_LOCSET(NULL, node);
             LOGVAL(LYD_CTX(node), LY_VCODE_UNEXPNODE, innode, node->schema->name);
-            LOG_LOCBACK(0, 1, 0, 0);
+            LOG_LOCBACK(0, 1);
             r = LY_EVALID;
             goto next_iter;
         }
diff --git a/src/xml.c b/src/xml.c
index 004dbb9..ac9e72b 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -922,7 +922,7 @@
     xmlctx->ctx = ctx;
     xmlctx->in = in;
 
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
 
     /* parse next element, if any */
     LY_CHECK_GOTO(ret = lyxml_next_element(xmlctx, &xmlctx->prefix, &xmlctx->prefix_len, &xmlctx->name,
@@ -1169,7 +1169,7 @@
         return;
     }
 
-    LOG_LOCBACK(0, 0, 0, 1);
+    ly_log_location_revert(0, 0, 0, 1);
 
     if (((xmlctx->status == LYXML_ELEM_CONTENT) || (xmlctx->status == LYXML_ATTR_CONTENT)) && xmlctx->dynamic) {
         free((char *)xmlctx->value);
diff --git a/src/xpath.c b/src/xpath.c
index f549b49..bfadbb9 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -4951,10 +4951,12 @@
 
     LY_ARRAY_NEW_RET(set->ctx, patterns, pattern, LY_EMEM);
     *pattern = calloc(1, sizeof **pattern);
-    LOG_LOCSET(NULL, set->cur_node, NULL, NULL);
+    if (set->cur_node) {
+        LOG_LOCSET(NULL, set->cur_node);
+    }
     rc = lys_compile_type_pattern_check(set->ctx, args[1]->val.str, &(*pattern)->code);
     if (set->cur_node) {
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
     }
     if (rc != LY_SUCCESS) {
         LY_ARRAY_FREE(patterns);
@@ -9731,7 +9733,9 @@
     set->prefix_data = prefix_data;
     set->vars = vars;
 
-    LOG_LOCSET(NULL, set->cur_node, NULL, NULL);
+    if (set->cur_node) {
+        LOG_LOCSET(NULL, set->cur_node);
+    }
 
     /* evaluate */
     rc = eval_expr_select(exp, &tok_idx, 0, set, options);
@@ -9743,7 +9747,7 @@
     }
 
     if (set->cur_node) {
-        LOG_LOCBACK(0, 1, 0, 0);
+        LOG_LOCBACK(0, 1);
     }
     return rc;
 }
@@ -10004,7 +10008,9 @@
     set->format = format;
     set->prefix_data = prefix_data;
 
-    LOG_LOCSET(set->cur_scnode, NULL, NULL, NULL);
+    if (set->cur_scnode) {
+        LOG_LOCSET(set->cur_scnode, NULL);
+    }
 
     /* evaluate */
     rc = eval_expr_select(exp, &tok_idx, 0, set, options);
@@ -10012,7 +10018,9 @@
         rc = LY_ENOTFOUND;
     }
 
-    LOG_LOCBACK(set->cur_scnode ? 1 : 0, 0, 0, 0);
+    if (set->cur_scnode) {
+        LOG_LOCBACK(1, 0);
+    }
     return rc;
 }
 
diff --git a/tests/utests/basic/test_context.c b/tests/utests/basic/test_context.c
index c37c7e4..789c80a 100644
--- a/tests/utests/basic/test_context.c
+++ b/tests/utests/basic/test_context.c
@@ -20,7 +20,9 @@
 #include "schema_compile.h"
 #include "tests_config.h"
 #include "tree_schema_internal.h"
+
 #ifdef _WIN32
+
 static void
 slashes_to_backslashes(char *path)
 {
@@ -40,11 +42,11 @@
     slashes_to_backslashes(path2);
 
     assert_int_equal(LY_EINVAL, ly_ctx_set_searchdir(NULL, NULL));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_set_searchdir()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_set_searchdir()).");
     assert_null(ly_ctx_get_searchdirs(NULL));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_get_searchdirs()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_get_searchdirs()).");
     assert_int_equal(LY_EINVAL, ly_ctx_unset_searchdir(NULL, NULL));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_unset_searchdir()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_unset_searchdir()).");
 
     /* correct path */
     assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(UTEST_LYCTX, path1));
@@ -71,7 +73,7 @@
     /* removing searchpaths */
     /* nonexisting */
     assert_int_equal(LY_EINVAL, ly_ctx_unset_searchdir(UTEST_LYCTX, "/nonexistingfile"));
-    CHECK_LOG_CTX("Invalid argument value (ly_ctx_unset_searchdir()).", NULL);
+    CHECK_LOG_CTX("Invalid argument value (ly_ctx_unset_searchdir()).", NULL, 0);
 
     /* first */
     assert_int_equal(LY_SUCCESS, ly_ctx_unset_searchdir(UTEST_LYCTX, path1));
@@ -95,18 +97,18 @@
 
     /* invalid arguments */
     assert_int_equal(LY_EINVAL, ly_ctx_set_searchdir(NULL, NULL));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_set_searchdir()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_set_searchdir()).");
     assert_null(ly_ctx_get_searchdirs(NULL));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_get_searchdirs()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_get_searchdirs()).");
     assert_int_equal(LY_EINVAL, ly_ctx_unset_searchdir(NULL, NULL));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_unset_searchdir()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_unset_searchdir()).");
 
     /* readable and executable, but not a directory */
     assert_int_equal(LY_EINVAL, ly_ctx_set_searchdir(UTEST_LYCTX, TESTS_BIN "/utest_context"));
-    CHECK_LOG_CTX("Given search directory \""TESTS_BIN "/utest_context\" is not a directory.", NULL);
+    CHECK_LOG_CTX("Given search directory \""TESTS_BIN "/utest_context\" is not a directory.", NULL, 0);
     /* not existing */
     assert_int_equal(LY_EINVAL, ly_ctx_set_searchdir(UTEST_LYCTX, "/nonexistingfile"));
-    CHECK_LOG_CTX("Unable to use search directory \"/nonexistingfile\" (No such file or directory).", NULL);
+    CHECK_LOG_CTX("Unable to use search directory \"/nonexistingfile\" (No such file or directory).", NULL, 0);
 
     /* ly_set_add() fails */
     /* no change */
@@ -143,7 +145,7 @@
     /* removing searchpaths */
     /* nonexisting */
     assert_int_equal(LY_EINVAL, ly_ctx_unset_searchdir(UTEST_LYCTX, "/nonexistingfile"));
-    CHECK_LOG_CTX("Invalid argument value (ly_ctx_unset_searchdir()).", NULL);
+    CHECK_LOG_CTX("Invalid argument value (ly_ctx_unset_searchdir()).", NULL, 0);
     /* first */
     assert_int_equal(LY_SUCCESS, ly_ctx_unset_searchdir(UTEST_LYCTX, TESTS_BIN "/utests"));
     assert_string_not_equal(TESTS_BIN "/utests", list[0]);
@@ -166,7 +168,7 @@
 
     /* test searchdir list in ly_ctx_new() */
     assert_int_equal(LY_EINVAL, ly_ctx_new("/nonexistingfile", 0, &UTEST_LYCTX));
-    CHECK_LOG("Unable to use search directory \"/nonexistingfile\" (No such file or directory).", NULL);
+    CHECK_LOG_LASTMSG("Unable to use search directory \"/nonexistingfile\" (No such file or directory).");
     assert_int_equal(LY_SUCCESS,
             ly_ctx_new(TESTS_SRC PATH_SEPARATOR TESTS_BIN PATH_SEPARATOR TESTS_BIN PATH_SEPARATOR TESTS_SRC,
             LY_CTX_DISABLE_SEARCHDIRS, &UTEST_LYCTX));
@@ -187,12 +189,12 @@
 
     /* invalid arguments */
     assert_int_equal(0, ly_ctx_get_options(NULL));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_get_options()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_get_options()).");
 
     assert_int_equal(LY_EINVAL, ly_ctx_set_options(NULL, 0));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_set_options()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_set_options()).");
     assert_int_equal(LY_EINVAL, ly_ctx_unset_options(NULL, 0));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_unset_options()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_unset_options()).");
 
     /* unset */
     /* LY_CTX_ALL_IMPLEMENTED */
@@ -279,7 +281,7 @@
 
     /* invalid arguments */
     assert_int_equal(0, ly_ctx_get_change_count(NULL));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_get_change_count()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_get_change_count()).");
 
     assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &UTEST_LYCTX));
     assert_int_equal(UTEST_LYCTX->change_count, ly_ctx_get_change_count(UTEST_LYCTX));
@@ -288,7 +290,7 @@
     assert_int_equal(LY_EINVAL, lys_parse_in(UTEST_LYCTX, in, 4, NULL, NULL, &unres.creating, &mod1));
     lys_unres_glob_erase(&unres);
     ly_in_free(in, 0);
-    CHECK_LOG_CTX("Invalid schema input format.", NULL);
+    CHECK_LOG_CTX("Invalid schema input format.", NULL, 0);
 
     /* import callback */
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, (void *)(str = "test"));
@@ -307,8 +309,8 @@
     assert_int_equal(LY_EVALID, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres.creating, &mod1));
     lys_unres_glob_erase(&unres);
     ly_in_free(in, 0);
-    CHECK_LOG_CTX("Parsing module \"y\" failed.", NULL);
-    CHECK_LOG_CTX("Name collision between module and submodule of name \"y\".", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"y\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Name collision between module and submodule of name \"y\".", NULL, 1);
 
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("module a {namespace urn:a;prefix a;include y;revision 2018-10-30; }", &in));
     assert_int_equal(LY_SUCCESS, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres.creating, &mod1));
@@ -317,8 +319,8 @@
     assert_int_equal(LY_EVALID, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres.creating, &mod1));
     lys_unres_glob_erase(&unres);
     ly_in_free(in, 0);
-    CHECK_LOG_CTX("Parsing module \"y\" failed.", NULL);
-    CHECK_LOG_CTX("Name collision between module and submodule of name \"y\".", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"y\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Name collision between module and submodule of name \"y\".", NULL, 1);
 
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule y {belongs-to b {prefix b;}}");
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("module b {namespace urn:b;prefix b;include y;}", &in));
@@ -326,10 +328,10 @@
     lys_unres_glob_revert(UTEST_LYCTX, &unres);
     lys_unres_glob_erase(&unres);
     ly_in_free(in, 0);
-    CHECK_LOG_CTX("Parsing module \"b\" failed.", NULL);
-    CHECK_LOG_CTX("Including \"y\" submodule into \"b\" failed.", NULL);
-    CHECK_LOG_CTX("Parsing submodule failed.", NULL);
-    CHECK_LOG_CTX("Name collision between submodules of name \"y\".", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"b\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Including \"y\" submodule into \"b\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Parsing submodule failed.", NULL, 0);
+    CHECK_LOG_CTX("Name collision between submodules of name \"y\".", NULL, 1);
 
     /* selecting correct revision of the submodules */
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule y {belongs-to a {prefix a;} revision 2018-10-31;}");
@@ -395,7 +397,7 @@
     ly_log_level(LY_LLVRB);
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module c {namespace urn:c;prefix c;import a {prefix a;}}",
             LYS_IN_YANG, &mod3));
-    CHECK_LOG("Implemented module \"a@2019-09-17\" is not used for import, revision \"2019-09-16\" is imported instead.", NULL);
+    CHECK_LOG_LASTMSG("Implemented module \"a@2019-09-17\" is not used for import, revision \"2019-09-16\" is imported instead.");
     ly_log_level(LY_LLWRN);
     assert_true(LYS_MOD_LATEST_SEARCHDIRS & mod1->latest_revision);
     assert_int_equal(1, mod1->implemented);
@@ -445,13 +447,13 @@
 
     /* invalid arguments */
     assert_ptr_equal(NULL, ly_ctx_get_module(NULL, NULL, NULL));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_get_module()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_get_module()).");
     assert_ptr_equal(NULL, ly_ctx_get_module(UTEST_LYCTX, NULL, NULL));
-    CHECK_LOG_CTX("Invalid argument name (ly_ctx_get_module()).", NULL);
+    CHECK_LOG_CTX("Invalid argument name (ly_ctx_get_module()).", NULL, 0);
     assert_ptr_equal(NULL, ly_ctx_get_module_ns(NULL, NULL, NULL));
-    CHECK_LOG("Invalid argument ctx (ly_ctx_get_module_ns()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (ly_ctx_get_module_ns()).");
     assert_ptr_equal(NULL, ly_ctx_get_module_ns(UTEST_LYCTX, NULL, NULL));
-    CHECK_LOG_CTX("Invalid argument ns (ly_ctx_get_module_ns()).", NULL);
+    CHECK_LOG_CTX("Invalid argument ns (ly_ctx_get_module_ns()).", NULL, 0);
     assert_null(ly_ctx_get_module(UTEST_LYCTX, "nonsence", NULL));
 
     /* internal modules */
@@ -472,7 +474,7 @@
     /* invalid attempts - implementing module of the same name and inserting the same module */
     assert_int_equal(LY_SUCCESS, lys_parse_in(UTEST_LYCTX, in2, LYS_IN_YANG, NULL, NULL, &unres.creating, &mod2));
     assert_int_equal(LY_EDENIED, lys_implement(mod2, NULL, &unres));
-    CHECK_LOG_CTX("Module \"a@2018-10-24\" is already implemented in revision \"2018-10-23\".", NULL);
+    CHECK_LOG_CTX("Module \"a@2018-10-24\" is already implemented in revision \"2018-10-23\".", NULL, 0);
     lys_unres_glob_erase(&unres);
     ly_in_reset(in1);
     /* it is already there, fine */
@@ -498,7 +500,7 @@
     ly_in_free(in1, 0);
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str1, &in1));
     assert_int_equal(LY_EINVAL, lys_parse_in(UTEST_LYCTX, in1, LYS_IN_YANG, NULL, NULL, &unres.creating, &mod));
-    CHECK_LOG_CTX("Input data contains submodule which cannot be parsed directly without its main module.", NULL);
+    CHECK_LOG_CTX("Input data contains submodule which cannot be parsed directly without its main module.", NULL, 0);
     lys_unres_glob_erase(&unres);
 
     while ((mod = (struct lys_module *)ly_ctx_get_module_iter(UTEST_LYCTX, &index))) {
diff --git a/tests/utests/basic/test_hash_table.c b/tests/utests/basic/test_hash_table.c
index cebea4f..2ea34fa 100644
--- a/tests/utests/basic/test_hash_table.c
+++ b/tests/utests/basic/test_hash_table.c
@@ -23,12 +23,12 @@
 test_invalid_arguments(void **state)
 {
     assert_int_equal(LY_EINVAL, lydict_insert(NULL, NULL, 0, NULL));
-    CHECK_LOG("Invalid argument ctx (lydict_insert()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (lydict_insert()).");
 
     assert_int_equal(LY_EINVAL, lydict_insert_zc(NULL, NULL, NULL));
-    CHECK_LOG("Invalid argument ctx (lydict_insert_zc()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument ctx (lydict_insert_zc()).");
     assert_int_equal(LY_EINVAL, lydict_insert_zc(UTEST_LYCTX, NULL, NULL));
-    CHECK_LOG_CTX("Invalid argument str_p (lydict_insert_zc()).", NULL);
+    CHECK_LOG_CTX("Invalid argument str_p (lydict_insert_zc()).", NULL, 0);
 }
 
 static void
@@ -55,7 +55,7 @@
     /* destroy dictionary - should raise warning about data presence */
     ly_ctx_destroy(UTEST_LYCTX);
     UTEST_LYCTX = NULL;
-    CHECK_LOG("String \"test1\" not freed from the dictionary, refcount 1.", NULL);
+    CHECK_LOG_LASTMSG("String \"test1\" not freed from the dictionary, refcount 1.");
 
 #ifndef NDEBUG
     /* cleanup */
@@ -78,7 +78,7 @@
 }
 
 static void
-test_ht_basic(void **state)
+test_ht_basic(void **UNUSED(state))
 {
     uint32_t i;
     struct ly_ht *ht;
@@ -92,13 +92,13 @@
     assert_int_equal(LY_SUCCESS, lyht_remove(ht, &i, i));
     assert_int_equal(LY_ENOTFOUND, lyht_find(ht, &i, i, NULL));
     assert_int_equal(LY_ENOTFOUND, lyht_remove(ht, &i, i));
-    CHECK_LOG("Invalid argument hash (lyht_remove_with_resize_cb()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument hash (lyht_remove_with_resize_cb()).");
 
     lyht_free(ht, NULL);
 }
 
 static void
-test_ht_resize(void **state)
+test_ht_resize(void **UNUSED(state))
 {
     uint32_t i;
     struct ly_ht *ht;
@@ -128,9 +128,8 @@
 
     /* removing not present data should fail */
     for (i = 0; i < 2; ++i) {
-        UTEST_LOG_CLEAN;
         assert_int_equal(LY_ENOTFOUND, lyht_remove(ht, &i, i));
-        CHECK_LOG("Invalid argument hash (lyht_remove_with_resize_cb()).", NULL);
+        CHECK_LOG_LASTMSG("Invalid argument hash (lyht_remove_with_resize_cb()).");
     }
     /* removing present data, resize should happened
      * when we are below 25% of the table filled, so with 3 records left */
diff --git a/tests/utests/basic/test_json.c b/tests/utests/basic/test_json.c
index 08b7719..a760b38 100644
--- a/tests/utests/basic/test_json.c
+++ b/tests/utests/basic/test_json.c
@@ -28,12 +28,12 @@
     str = "";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Empty JSON file.", "Line number 1.");
+    CHECK_LOG_CTX("Empty JSON file.", NULL, 1);
 
     str = "  \n\t \n";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Empty JSON file.", "Line number 3.");
+    CHECK_LOG_CTX("Empty JSON file.", NULL, 3);
 
     /* constant values */
     str = "true";
@@ -457,62 +457,62 @@
     str = "-x";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Invalid character in JSON Number value (\"x\").", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character in JSON Number value (\"x\").", NULL, 1);
 
     str = "  -";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Unexpected end-of-input.", "Line number 1.");
+    CHECK_LOG_CTX("Unexpected end-of-input.", NULL, 1);
 
     str = "--1";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Invalid character in JSON Number value (\"-\").", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character in JSON Number value (\"-\").", NULL, 1);
 
     str = "+1";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Invalid character sequence \"+1\", expected a JSON value.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"+1\", expected a JSON value.", NULL, 1);
 
     str = "  1.x ";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Invalid character in JSON Number value (\"x\").", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character in JSON Number value (\"x\").", NULL, 1);
 
     str = "1.";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Unexpected end-of-input.", "Line number 1.");
+    CHECK_LOG_CTX("Unexpected end-of-input.", NULL, 1);
 
     str = "  1eo ";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Invalid character in JSON Number value (\"o\").", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character in JSON Number value (\"o\").", NULL, 1);
 
     str = "1e";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Unexpected end-of-input.", "Line number 1.");
+    CHECK_LOG_CTX("Unexpected end-of-input.", NULL, 1);
 
     str = "1E1000";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Number encoded as a string exceeded the LY_NUMBER_MAXLEN limit.", "Line number 1.");
+    CHECK_LOG_CTX("Number encoded as a string exceeded the LY_NUMBER_MAXLEN limit.", NULL, 1);
 
     str = "1e9999999999999999999";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Exponent out-of-bounds in a JSON Number value (1e9999999999999999999).", "Line number 1.");
+    CHECK_LOG_CTX("Exponent out-of-bounds in a JSON Number value (1e9999999999999999999).", NULL, 1);
 
     str = "1.1e66000";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Exponent out-of-bounds in a JSON Number value (1.1e66000).", "Line number 1.");
+    CHECK_LOG_CTX("Exponent out-of-bounds in a JSON Number value (1.1e66000).", NULL, 1);
 
     str = "1.1e-66000";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Exponent out-of-bounds in a JSON Number value (1.1e-66000).", "Line number 1.");
+    CHECK_LOG_CTX("Exponent out-of-bounds in a JSON Number value (1.1e-66000).", NULL, 1);
 
     ly_in_free(in, 0);
 }
@@ -532,8 +532,8 @@
     str = "\"unterminated string";
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
-    CHECK_LOG_CTX("Missing quotation-mark at the end of a JSON string.", "Line number 1.");
-    CHECK_LOG_CTX("Unexpected end-of-input.", "Line number 1.");
+    CHECK_LOG_CTX("Missing quotation-mark at the end of a JSON string.", NULL, 1);
+    CHECK_LOG_CTX("Unexpected end-of-input.", NULL, 1);
 
     ly_in_free(in, 0);
 }
@@ -662,7 +662,7 @@
     assert_int_equal(LYJSON_OBJECT, lyjson_ctx_status(jsonctx));
 
     assert_int_equal(LY_EVALID, lyjson_ctx_next(jsonctx, NULL));
-    CHECK_LOG_CTX("Invalid character sequence \"unquoted : \"data\"}\", expected a JSON object name.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"unquoted : \"data\"}\", expected a JSON object name.", NULL, 1);
     lyjson_ctx_free(jsonctx);
 
     ly_in_free(in, 0);
@@ -752,7 +752,7 @@
     assert_non_null(ly_in_memory(in, str));
     assert_int_equal(LY_SUCCESS, lyjson_ctx_new(UTEST_LYCTX, in, &jsonctx));
     assert_int_equal(LY_EVALID, lyjson_ctx_next(jsonctx, NULL));
-    CHECK_LOG_CTX("Invalid character sequence \", null]\", expected a JSON value.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \", null]\", expected a JSON value.", NULL, 1);
     lyjson_ctx_free(jsonctx);
 
     ly_in_free(in, 0);
diff --git a/tests/utests/basic/test_plugins.c b/tests/utests/basic/test_plugins.c
index d533a07..cf2e87b 100644
--- a/tests/utests/basic/test_plugins.c
+++ b/tests/utests/basic/test_plugins.c
@@ -91,7 +91,7 @@
     free(printed);
 
     assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
 
     lyd_free_all(tree);
 }
diff --git a/tests/utests/basic/test_set.c b/tests/utests/basic/test_set.c
index 9485927..04ea6bc 100644
--- a/tests/utests/basic/test_set.c
+++ b/tests/utests/basic/test_set.c
@@ -70,42 +70,31 @@
 }
 
 static void
-test_inval(void **state)
+test_inval(void **UNUSED(state))
 {
-    struct ly_set set;
-
-    memset(&set, 0, sizeof set);
-
-    ly_set_clean(NULL, NULL);
-    CHECK_LOG(NULL, NULL);
-
-    ly_set_erase(NULL, NULL);
-    CHECK_LOG(NULL, NULL);
-
-    ly_set_free(NULL, NULL);
-    CHECK_LOG(NULL, NULL);
+    struct ly_set set = {0};
 
     assert_int_equal(LY_EINVAL, ly_set_dup(NULL, NULL, NULL));
-    CHECK_LOG("Invalid argument set (ly_set_dup()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument set (ly_set_dup()).");
 
     assert_int_equal(LY_EINVAL, ly_set_add(NULL, NULL, 0, NULL));
-    CHECK_LOG("Invalid argument set (ly_set_add()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument set (ly_set_add()).");
 
     assert_int_equal(LY_EINVAL, ly_set_merge(NULL, NULL, 0, NULL));
-    CHECK_LOG("Invalid argument trg (ly_set_merge()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument trg (ly_set_merge()).");
     assert_int_equal(LY_SUCCESS, ly_set_merge(&set, NULL, 0, NULL));
 
     assert_int_equal(LY_EINVAL, ly_set_rm_index(NULL, 0, NULL));
-    CHECK_LOG("Invalid argument set (ly_set_rm_index()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument set (ly_set_rm_index()).");
     assert_int_equal(LY_EINVAL, ly_set_rm_index(&set, 1, NULL));
-    CHECK_LOG("Invalid argument index (ly_set_rm_index()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument index (ly_set_rm_index()).");
 
     assert_int_equal(LY_EINVAL, ly_set_rm(NULL, NULL, NULL));
-    CHECK_LOG("Invalid argument set (ly_set_rm()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument set (ly_set_rm()).");
     assert_int_equal(LY_EINVAL, ly_set_rm(&set, NULL, NULL));
-    CHECK_LOG("Invalid argument object (ly_set_rm()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument object (ly_set_rm()).");
     assert_int_equal(LY_EINVAL, ly_set_rm(&set, &set, NULL));
-    CHECK_LOG("Invalid argument object (ly_set_rm()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument object (ly_set_rm()).");
 }
 
 static void
diff --git a/tests/utests/basic/test_xml.c b/tests/utests/basic/test_xml.c
index 071846a..25aed03 100644
--- a/tests/utests/basic/test_xml.c
+++ b/tests/utests/basic/test_xml.c
@@ -43,43 +43,42 @@
     str = "</element>";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EVALID, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
-    CHECK_LOG_CTX("Stray closing element tag (\"element\").", "Line number 1.");
+    CHECK_LOG_CTX("Stray closing element tag (\"element\").", NULL, 1);
     ly_in_free(in, 0);
 
     /* no element */
-    UTEST_LOG_CLEAN;
     str = "no data present";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EVALID, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
-    CHECK_LOG_CTX("Invalid character sequence \"no data present\", expected element tag start ('<').", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"no data present\", expected element tag start ('<').", NULL, 1);
     ly_in_free(in, 0);
 
     /* not supported DOCTYPE */
     str = "<!DOCTYPE greeting SYSTEM \"hello.dtd\"><greeting/>";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EVALID, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
-    CHECK_LOG_CTX("Document Type Declaration not supported.", "Line number 1.");
+    CHECK_LOG_CTX("Document Type Declaration not supported.", NULL, 1);
     ly_in_free(in, 0);
 
     /* invalid XML */
     str = "<!NONSENSE/>";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EVALID, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
-    CHECK_LOG_CTX("Unknown XML section \"<!NONSENSE/>\".", "Line number 1.");
+    CHECK_LOG_CTX("Unknown XML section \"<!NONSENSE/>\".", NULL, 1);
     ly_in_free(in, 0);
 
     /* namespace ambiguity */
     str = "<element xmlns=\"urn1\" xmlns=\"urn2\"/>";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EVALID, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
-    CHECK_LOG_CTX("Duplicate default XML namespaces \"urn1\" and \"urn2\".", "Line number 1.");
+    CHECK_LOG_CTX("Duplicate default XML namespaces \"urn1\" and \"urn2\".", NULL, 1);
     ly_in_free(in, 0);
 
     /* prefix duplicate */
     str = "<element xmlns:a=\"urn1\" xmlns:a=\"urn2\"/>";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EVALID, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
-    CHECK_LOG_CTX("Duplicate XML NS prefix \"a\" used for namespaces \"urn1\" and \"urn2\".", "Line number 1.");
+    CHECK_LOG_CTX("Duplicate XML NS prefix \"a\" used for namespaces \"urn1\" and \"urn2\".", NULL, 1);
     ly_in_free(in, 0);
 
     /* unqualified element */
@@ -210,7 +209,7 @@
     assert_int_equal(LYXML_ELEM_CONTENT, xmlctx->status);
 
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Opening (\"yin:element\") and closing (\"element\") elements tag mismatch.", "Line number 1.");
+    CHECK_LOG_CTX("Opening (\"yin:element\") and closing (\"element\") elements tag mismatch.", NULL, 1);
     lyxml_ctx_free(xmlctx);
     ly_in_free(in, 0);
 
@@ -220,7 +219,7 @@
     assert_int_equal(LY_SUCCESS, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
     assert_int_equal(LY_SUCCESS, lyxml_ctx_next(xmlctx));
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Invalid character sequence \"/>\", expected element tag termination ('>').", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"/>\", expected element tag termination ('>').", NULL, 1);
     lyxml_ctx_free(xmlctx);
     ly_in_free(in, 0);
 
@@ -246,14 +245,14 @@
     str = "<¢:element>";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EVALID, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
-    CHECK_LOG_CTX("Identifier \"¢:element>\" starts with an invalid character.", "Line number 1.");
+    CHECK_LOG_CTX("Identifier \"¢:element>\" starts with an invalid character.", NULL, 1);
     ly_in_free(in, 0);
 
     str = "<yin:c⁐element>";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_SUCCESS, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Invalid character sequence \"⁐element>\", expected element tag end ('>' or '/>') or an attribute.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"⁐element>\", expected element tag end ('>' or '/>') or an attribute.", NULL, 1);
     lyxml_ctx_free(xmlctx);
     ly_in_free(in, 0);
 
@@ -302,7 +301,7 @@
     assert_true(!strncmp("text", xmlctx->value, xmlctx->value_len));
 
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Opening (\"a\") and closing (\"b\") elements tag mismatch.", "Line number 1.");
+    CHECK_LOG_CTX("Opening (\"a\") and closing (\"b\") elements tag mismatch.", NULL, 1);
     lyxml_ctx_free(xmlctx);
     ly_in_free(in, 0);
 }
@@ -319,19 +318,19 @@
     str = "<e unknown/>";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EVALID, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
-    CHECK_LOG_CTX("Invalid character sequence \"/>\", expected '='.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"/>\", expected '='.", NULL, 1);
     ly_in_free(in, 0);
 
     str = "<e xxx=/>";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EVALID, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
-    CHECK_LOG_CTX("Invalid character sequence \"/>\", expected either single or double quotation mark.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"/>\", expected either single or double quotation mark.", NULL, 1);
     ly_in_free(in, 0);
 
     str = "<e xxx\n = yyy/>";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EVALID, lyxml_ctx_new(UTEST_LYCTX, in, &xmlctx));
-    CHECK_LOG_CTX("Invalid character sequence \"yyy/>\", expected either single or double quotation mark.", "Line number 2.");
+    CHECK_LOG_CTX("Invalid character sequence \"yyy/>\", expected either single or double quotation mark.", NULL, 2);
     ly_in_free(in, 0);
 
     /* valid attribute */
@@ -390,7 +389,7 @@
     /* empty value but in single quotes */
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'\'", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ATTRIBUTE;
     assert_int_equal(LY_SUCCESS, lyxml_ctx_next(xmlctx));
     assert_int_equal(LYXML_ATTR_CONTENT, xmlctx->status);
@@ -402,7 +401,7 @@
     /* empty element content - only formating before defining child */
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(">\n  <y>", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ELEMENT;
     assert_int_equal(LY_SUCCESS, lyxml_ctx_next(xmlctx));
     assert_int_equal(LYXML_ELEM_CONTENT, xmlctx->status);
@@ -414,22 +413,22 @@
     /* empty element content is invalid - missing content terminating character < */
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ELEM_CONTENT;
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Unexpected end-of-input.", "Line number 1.");
+    CHECK_LOG_CTX("Unexpected end-of-input.", NULL, 1);
     ly_in_free(in, 0);
 
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("xxx", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ELEM_CONTENT;
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Invalid character sequence \"xxx\", expected element tag start ('<').", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"xxx\", expected element tag start ('<').", NULL, 1);
     ly_in_free(in, 0);
 
     lyxml_ctx_free(xmlctx);
-    LOG_LOCBACK(0, 0, 0, 4);
+    ly_log_location_revert(0, 0, 0, 4);
 
     /* valid strings */
     str = "<a>€𠜎Øn \n&lt;&amp;&quot;&apos;&gt; &#82;&#x4f;&#x4B;</a>";
@@ -448,7 +447,7 @@
     /* test using n-bytes UTF8 hexadecimal code points */
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'&#x0024;&#x00A2;&#x20ac;&#x10348;\'", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ATTRIBUTE;
     assert_int_equal(LY_SUCCESS, lyxml_ctx_next(xmlctx));
     assert_int_equal(LYXML_ATTR_CONTENT, xmlctx->status);
@@ -460,7 +459,7 @@
     /* CDATA value */
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(">   <![CDATA[    special non-escaped chars <>&\"'  ]]>  </a>", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ATTR_CONTENT;
     assert_int_equal(LY_SUCCESS, lyxml_ctx_next(xmlctx));
     assert_int_equal(LYXML_ELEM_CONTENT, xmlctx->status);
@@ -473,62 +472,62 @@
     /* invalid characters in string */
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'&#x52\'", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ATTRIBUTE;
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Invalid character sequence \"'\", expected ;.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"'\", expected ;.", NULL, 1);
     ly_in_free(in, 0);
 
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\"&#82\"", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ATTRIBUTE;
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Invalid character sequence \"\"\", expected ;.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"\"\", expected ;.", NULL, 1);
     ly_in_free(in, 0);
 
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\"&nonsense;\"", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ATTRIBUTE;
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Entity reference \"&nonsense;\" not supported, only predefined references allowed.", "Line number 1.");
+    CHECK_LOG_CTX("Entity reference \"&nonsense;\" not supported, only predefined references allowed.", NULL, 1);
     ly_in_free(in, 0);
 
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(">&#o122;", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ELEMENT;
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Invalid character reference \"&#o122;\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character reference \"&#o122;\".", NULL, 1);
     ly_in_free(in, 0);
 
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'&#x06;\'", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ATTRIBUTE;
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Invalid character reference \"&#x06;\'\" (0x00000006).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character reference \"&#x06;\'\" (0x00000006).", NULL, 1);
     ly_in_free(in, 0);
 
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'&#xfdd0;\'", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ATTRIBUTE;
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Invalid character reference \"&#xfdd0;\'\" (0x0000fdd0).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character reference \"&#xfdd0;\'\" (0x0000fdd0).", NULL, 1);
     ly_in_free(in, 0);
 
     assert_int_equal(LY_SUCCESS, ly_in_new_memory("=\'&#xffff;\'", &in));
     xmlctx->in = in;
-    LOG_LOCSET(NULL, NULL, NULL, in);
+    ly_log_location(NULL, NULL, NULL, in);
     xmlctx->status = LYXML_ATTRIBUTE;
     assert_int_equal(LY_EVALID, lyxml_ctx_next(xmlctx));
-    CHECK_LOG_CTX("Invalid character reference \"&#xffff;\'\" (0x0000ffff).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character reference \"&#xffff;\'\" (0x0000ffff).", NULL, 1);
     ly_in_free(in, 0);
 
     lyxml_ctx_free(xmlctx);
-    LOG_LOCBACK(0, 0, 0, 9);
+    ly_log_location_revert(0, 0, 0, 9);
 }
 
 static void
diff --git a/tests/utests/basic/test_xpath.c b/tests/utests/basic/test_xpath.c
index 754abf2..7a2785b 100644
--- a/tests/utests/basic/test_xpath.c
+++ b/tests/utests/basic/test_xpath.c
@@ -267,11 +267,11 @@
 
     assert_int_equal(LY_EVALID, lyd_find_xpath(tree, "/a:foo2[.=]", &set));
     assert_null(set);
-    CHECK_LOG_CTX("Unexpected XPath token \"]\" (\"]\").", NULL);
+    CHECK_LOG_CTX("Unexpected XPath token \"]\" (\"]\").", NULL, 0);
 
     assert_int_equal(LY_EVALID, lyd_find_xpath(tree, "/a:", &set));
     assert_null(set);
-    CHECK_LOG_CTX("Invalid character 'a'[2] of expression '/a:'.", NULL);
+    CHECK_LOG_CTX("Invalid character 'a'[2] of expression '/a:'.", NULL, 0);
 
     lyd_free_all(tree);
 }
@@ -938,7 +938,7 @@
     LOCAL_SETUP(data, tree);
     assert_int_equal(LY_SUCCESS, lyxp_vars_set(&vars, "var1", "\"mstr\""));
     assert_int_equal(LY_ENOTFOUND, lyd_find_xpath2(tree, "/foo[text() = $var55]", vars, &set));
-    CHECK_LOG_CTX("Variable \"var55\" not defined.", NULL);
+    CHECK_LOG_CTX("Variable \"var55\" not defined.", NULL, 0);
     LOCAL_TEARDOWN(set, tree, vars);
 
     /* Syntax error in value. */
@@ -947,7 +947,7 @@
     LOCAL_SETUP(data, tree);
     assert_int_equal(LY_SUCCESS, lyxp_vars_set(&vars, "var", "\""));
     assert_int_equal(LY_EVALID, lyd_find_xpath2(tree, "/foo[$var]", vars, &set));
-    CHECK_LOG_CTX("Unterminated string delimited with \" (\").", "Data location \"/a:foo\".");
+    CHECK_LOG_CTX("Unterminated string delimited with \" (\").", "/a:foo", 0);
     LOCAL_TEARDOWN(set, tree, vars);
 
     /* Prefix is not supported. */
@@ -956,7 +956,7 @@
     LOCAL_SETUP(data, tree);
     assert_int_equal(LY_SUCCESS, lyxp_vars_set(&vars, "var", "\""));
     assert_int_equal(LY_EVALID, lyd_find_xpath2(tree, "/foo[$pref:var]", vars, &set));
-    CHECK_LOG_CTX("Variable with prefix is not supported.", NULL);
+    CHECK_LOG_CTX("Variable with prefix is not supported.", NULL, 0);
     LOCAL_TEARDOWN(set, tree, vars);
 
 #undef LOCAL_SETUP
diff --git a/tests/utests/data/test_diff.c b/tests/utests/data/test_diff.c
index 4400b5d..0edd6bd 100644
--- a/tests/utests/data/test_diff.c
+++ b/tests/utests/data/test_diff.c
@@ -318,7 +318,7 @@
     struct lyd_node *diff = NULL;
 
     assert_int_equal(lyd_diff_siblings(model_1, lyd_child(model_1), 0, &diff), LY_EINVAL);
-    CHECK_LOG_CTX("Invalid arguments - cannot create diff for unrelated data (lyd_diff()).", NULL);
+    CHECK_LOG_CTX("Invalid arguments - cannot create diff for unrelated data (lyd_diff()).", NULL, 0);
 
     assert_int_equal(lyd_diff_siblings(NULL, NULL, 0, NULL), LY_EINVAL);
 
diff --git a/tests/utests/data/test_new.c b/tests/utests/data/test_new.c
index 5cee903..d75f667 100644
--- a/tests/utests/data/test_new.c
+++ b/tests/utests/data/test_new.c
@@ -106,16 +106,16 @@
     lyd_free_tree(node);
 
     assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[]", 0, &node), LY_EVALID);
-    CHECK_LOG_CTX("Unexpected XPath token \"]\" (\"]\").", "Schema location \"/a:l1\".");
+    CHECK_LOG_CTX("Unexpected XPath token \"]\" (\"]\").", "/a:l1", 0);
 
     assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[key1='a'][key2='b']", 0, &node), LY_ENOTFOUND);
-    CHECK_LOG_CTX("Not found node \"key1\" in path.", "Schema location \"/a:l1\".");
+    CHECK_LOG_CTX("Not found node \"key1\" in path.", "/a:l1", 0);
 
     assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a='a'][b='b'][c='c']", 0, &node), LY_EVALID);
-    CHECK_LOG_CTX("Key expected instead of leaf \"c\" in path.", "Schema location \"/a:l1\".");
+    CHECK_LOG_CTX("Key expected instead of leaf \"c\" in path.", "/a:l1", 0);
 
     assert_int_equal(lyd_new_list2(NULL, mod, "c", "[a='a'][b='b']", 0, &node), LY_ENOTFOUND);
-    CHECK_LOG_CTX("List node \"c\" not found.", NULL);
+    CHECK_LOG_CTX("List node \"c\" not found.", NULL, 0);
 
     assert_int_equal(lyd_new_list2(NULL, mod, "l1", "[a='a'][b='b']", 0, &node), LY_SUCCESS);
     lyd_free_tree(node);
@@ -141,10 +141,10 @@
 
     /* leaf */
     assert_int_equal(lyd_new_term(NULL, mod, "foo", "[a='a'][b='b'][c='c']", 0, &node), LY_EVALID);
-    CHECK_LOG_CTX("Invalid type uint16 value \"[a='a'][b='b'][c='c']\".", "Schema location \"/a:foo\".");
+    CHECK_LOG_CTX("Invalid type uint16 value \"[a='a'][b='b'][c='c']\".", "/a:foo", 0);
 
     assert_int_equal(lyd_new_term(NULL, mod, "c", "value", 0, &node), LY_ENOTFOUND);
-    CHECK_LOG_CTX("Term node \"c\" not found.", NULL);
+    CHECK_LOG_CTX("Term node \"c\" not found.", NULL, 0);
 
     assert_int_equal(lyd_new_term(NULL, mod, "foo", "256", 0, &node), LY_SUCCESS);
     lyd_free_tree(node);
@@ -158,10 +158,10 @@
     lyd_free_tree(node);
 
     assert_int_equal(lyd_new_inner(NULL, mod, "l1", 0, &node), LY_ENOTFOUND);
-    CHECK_LOG_CTX("Inner node (container, notif, RPC, or action) \"l1\" not found.", NULL);
+    CHECK_LOG_CTX("Inner node (container, notif, RPC, or action) \"l1\" not found.", NULL, 0);
 
     assert_int_equal(lyd_new_inner(NULL, mod, "l2", 0, &node), LY_ENOTFOUND);
-    CHECK_LOG_CTX("Inner node (container, notif, RPC, or action) \"l2\" not found.", NULL);
+    CHECK_LOG_CTX("Inner node (container, notif, RPC, or action) \"l2\" not found.", NULL, 0);
 
     /* anydata */
     assert_int_equal(lyd_new_any(NULL, mod, "any", "{\"node\":\"val\"}", 0, LYD_ANYDATA_STRING, 0, &node), LY_SUCCESS);
@@ -171,7 +171,7 @@
 
     /* key-less list */
     assert_int_equal(lyd_new_list2(NULL, mod, "l2", "[a='a'][b='b']", 0, &node), LY_EVALID);
-    CHECK_LOG_CTX("List predicate defined for keyless list \"l2\" in path.", "Schema location \"/a:l2\".");
+    CHECK_LOG_CTX("List predicate defined for keyless list \"l2\" in path.", "/a:l2", 0);
 
     assert_int_equal(lyd_new_list2(NULL, mod, "l2", "", 0, &node), LY_SUCCESS);
     lyd_free_tree(node);
@@ -255,7 +255,7 @@
     /* try LYD_NEWOPT_OPAQ */
     ret = lyd_new_path2(NULL, UTEST_LYCTX, "/a:l1", NULL, 0, 0, 0, NULL, NULL);
     assert_int_equal(ret, LY_EINVAL);
-    CHECK_LOG_CTX("Predicate missing for list \"l1\" in path \"/a:l1\".", "Schema location \"/a:l1\".");
+    CHECK_LOG_CTX("Predicate missing for list \"l1\" in path \"/a:l1\".", "/a:l1", 0);
 
     ret = lyd_new_path2(NULL, UTEST_LYCTX, "/a:l1", NULL, 0, 0, LYD_NEW_PATH_OPAQ, NULL, &root);
     assert_int_equal(ret, LY_SUCCESS);
@@ -266,7 +266,7 @@
 
     ret = lyd_new_path2(NULL, UTEST_LYCTX, "/a:foo", NULL, 0, 0, 0, NULL, NULL);
     assert_int_equal(ret, LY_EVALID);
-    CHECK_LOG_CTX("Invalid type uint16 empty value.", "Schema location \"/a:foo\".");
+    CHECK_LOG_CTX("Invalid type uint16 empty value.", "/a:foo", 0);
 
     ret = lyd_new_path2(NULL, UTEST_LYCTX, "/a:foo", NULL, 0, 0, LYD_NEW_PATH_OPAQ, NULL, &root);
     assert_int_equal(ret, LY_SUCCESS);
@@ -301,7 +301,7 @@
 
     ret = lyd_new_path2(root, NULL, "/a:c2/l3[1]", NULL, 0, 0, 0, NULL, &node);
     assert_int_equal(ret, LY_EEXIST);
-    CHECK_LOG_CTX("Path \"/a:c2/l3[1]\" already exists.", "Data location \"/a:c2/l3[1]\".");
+    CHECK_LOG_CTX("Path \"/a:c2/l3[1]\" already exists.", "/a:c2/l3[1]", 0);
 
     ret = lyd_new_path2(root, NULL, "/a:c2/l3[2]/x", "val2", 0, 0, 0, NULL, &node);
     assert_int_equal(ret, LY_SUCCESS);
@@ -360,7 +360,7 @@
 
     ret = lyd_new_path2(root, NULL, "/a:ll2[1]", "", 0, 0, 0, NULL, &node);
     assert_int_equal(ret, LY_EEXIST);
-    CHECK_LOG_CTX("Path \"/a:ll2[1]\" already exists.", "Data location \"/a:ll2[1]\".");
+    CHECK_LOG_CTX("Path \"/a:ll2[1]\" already exists.", "/a:ll2[1]", 0);
 
     ret = lyd_new_path2(root, NULL, "/a:ll2[2]", "val2", 0, 0, 0, NULL, &node);
     assert_int_equal(ret, LY_SUCCESS);
@@ -375,7 +375,7 @@
 
     ret = lyd_new_path2(root, NULL, "/a:ll2[3][.='val3']", NULL, 0, 0, 0, NULL, &node);
     assert_int_equal(ret, LY_EVALID);
-    CHECK_LOG_CTX("Unparsed characters \"[.='val3']\" left at the end of path.", NULL);
+    CHECK_LOG_CTX("Unparsed characters \"[.='val3']\" left at the end of path.", NULL, 0);
 
     lyd_print_mem(&str, root, LYD_XML, LYD_PRINT_WITHSIBLINGS);
     assert_string_equal(str,
diff --git a/tests/utests/data/test_parser_json.c b/tests/utests/data/test_parser_json.c
index 8feed9c..0361b6a 100644
--- a/tests/utests/data/test_parser_json.c
+++ b/tests/utests/data/test_parser_json.c
@@ -61,9 +61,9 @@
 #define CHECK_PARSE_LYD(INPUT, PARSE_OPTION, VALIDATE_OPTION, TREE) \
     CHECK_PARSE_LYD_PARAM(INPUT, LYD_JSON, PARSE_OPTION, VALIDATE_OPTION, LY_SUCCESS, TREE)
 
-#define PARSER_CHECK_ERROR(INPUT, PARSE_OPTION, VALIDATE_OPTION, MODEL, RET_VAL, ERR_MESSAGE, ERR_PATH) \
+#define PARSER_CHECK_ERROR(INPUT, PARSE_OPTION, VALIDATE_OPTION, MODEL, RET_VAL, ERR_MESSAGE, ERR_PATH, ERR_LINE) \
     assert_int_equal(RET_VAL, lyd_parse_data_mem(UTEST_LYCTX, INPUT, LYD_JSON, PARSE_OPTION, VALIDATE_OPTION, &MODEL));\
-    CHECK_LOG_CTX(ERR_MESSAGE, ERR_PATH);\
+    CHECK_LOG_CTX(ERR_MESSAGE, ERR_PATH, ERR_LINE);\
     assert_null(MODEL)
 
 #define CHECK_LYD_STRING(IN_MODEL, PRINT_OPTION, TEXT) \
@@ -144,27 +144,25 @@
     lyd_free_all(tree);
 
     PARSER_CHECK_ERROR(data, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Unknown (or not implemented) YANG module \"x\" of metadata \"x:xxx\".", "Data location \"/@a:foo\", line number 1.");
+            "Unknown (or not implemented) YANG module \"x\" of metadata \"x:xxx\".", "/@a:foo", 1);
 
     /* missing referenced metadata node */
     PARSER_CHECK_ERROR("{\"@a:foo\" : { \"a:hint\" : 1 }}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Missing JSON data instance to be coupled with @a:foo metadata.", "Data location \"/@a:foo\", line number 1.");
+            "Missing JSON data instance to be coupled with @a:foo metadata.", "/@a:foo", 1);
 
     /* missing namespace for meatadata*/
     PARSER_CHECK_ERROR("{\"a:foo\" : \"value\", \"@a:foo\" : { \"hint\" : 1 }}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Metadata in JSON must be namespace-qualified, missing prefix for \"hint\".",
-            "Schema location \"/a:foo\", line number 1.");
+            "Metadata in JSON must be namespace-qualified, missing prefix for \"hint\".", "/a:foo", 1);
 
     /* invalid JSON type */
     data = "{\"a:l1\" : [{ \"a\" : \"val-a\", \"b\" : \"val-b\", \"c\" : 1, \"cont\" : { \"e\" : \"0\" } }]}";
     PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Invalid non-boolean-encoded boolean value \"0\".",
-            "Data location \"/a:l1[a='val-a'][b='val-b'][c='1']/cont/e\", line number 1.");
+            "Invalid non-boolean-encoded boolean value \"0\".", "/a:l1[a='val-a'][b='val-b'][c='1']/cont/e", 1);
 
     /* reverse solidus in JSON object member name */
     data = "{\"@a:foo\":{\"a:hi\\nt\":1},\"a:foo\":\"xxx\"}";
     assert_int_equal(LY_EINVAL, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree));
-    CHECK_LOG_CTX("Annotation definition for attribute \"a:hi\nt\" not found.", "Path \"/@a:foo/@a:hi\nt\", line number 1.");
+    CHECK_LOG_CTX("Annotation definition for attribute \"a:hi\nt\" not found.", "/@a:foo/@a:hi\nt", 1);
 }
 
 static void
@@ -253,14 +251,13 @@
 
     /* missing referenced metadata node */
     PARSER_CHECK_ERROR("{\"@a:ll1\":[{\"a:hint\":1}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Missing JSON data instance to be coupled with @a:ll1 metadata.", "Data location \"/@a:ll1\", line number 1.");
+            "Missing JSON data instance to be coupled with @a:ll1 metadata.", "/@a:ll1", 1);
 
     PARSER_CHECK_ERROR("{\"a:ll1\":[1],\"@a:ll1\":[{\"a:hint\":1},{\"a:hint\":2}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Missing JSON data instance #2 of a:ll1 to be coupled with metadata.", "Schema location \"/a:ll1\", line number 1.");
+            "Missing JSON data instance #2 of a:ll1 to be coupled with metadata.", "/a:ll1", 1);
 
     PARSER_CHECK_ERROR("{\"@a:ll1\":[{\"a:hint\":1},{\"a:hint\":2},{\"a:hint\":3}],\"a:ll1\" : [1, 2]}", 0, LYD_VALIDATE_PRESENT,
-            tree, LY_EVALID, "Missing JSON data instance #3 to be coupled with @a:ll1 metadata.",
-            "Data location \"/@a:ll1\", line number 1.");
+            tree, LY_EVALID, "Missing JSON data instance #3 to be coupled with @a:ll1 metadata.", "/@a:ll1", 1);
 }
 
 static void
@@ -404,19 +401,17 @@
 
     /* missing keys */
     PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"c\" : 1, \"b\" : \"b\"}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"a\".",
-            "Data location \"/a:l1[b='b'][c='1']\", line number 1.");
+            "List instance is missing its key \"a\".", "/a:l1[b='b'][c='1']", 1);
 
     PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"a\" : \"a\"}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"b\".", "Data location \"/a:l1[a='a']\", line number 1.");
+            "List instance is missing its key \"b\".", "/a:l1[a='a']", 1);
 
     PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"b\" : \"b\", \"a\" : \"a\"}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"c\".", "Data location \"/a:l1[a='a'][b='b']\", line number 1.");
+            "List instance is missing its key \"c\".", "/a:l1[a='a'][b='b']", 1);
 
     /* key duplicate */
     PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"c\" : 1, \"b\" : \"b\", \"a\" : \"a\", \"c\" : 1}]}", 0, LYD_VALIDATE_PRESENT,
-            tree, LY_EVALID, "Duplicate instance of \"c\".",
-            "Data location \"/a:l1[a='a'][b='b'][c='1'][c='1']/c\", line number 1.");
+            tree, LY_EVALID, "Duplicate instance of \"c\".", "/a:l1[a='a'][b='b'][c='1'][c='1']/c", 1);
 
     /* keys order, in contrast to XML, JSON accepts keys in any order even in strict mode */
     CHECK_PARSE_LYD("{ \"a:l1\": [ {\"d\" : \"d\", \"a\" : \"a\", \"c\" : 1, \"b\" : \"b\"}]}", 0, LYD_VALIDATE_PRESENT, tree);
@@ -431,7 +426,7 @@
     CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "c", 1, LYS_LEAF, 1, 0, NULL, 0);
     assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
     CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "d", 1, LYS_LEAF, 1, 0, NULL, 0);
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
     CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS,
             "{\"a:l1\":[{\"a\":\"a\",\"b\":\"b\",\"c\":1,\"d\":\"d\"}]}");
     lyd_free_all(tree);
@@ -449,7 +444,7 @@
     assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
     CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "c",
             1, LYS_LEAF, 1, 0, NULL, 0);
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
     CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS,
             "{\"a:l1\":[{\"a\":\"a\",\"b\":\"b\",\"c\":1}]}");
     lyd_free_all(tree);
@@ -515,7 +510,7 @@
     /* invalid value, no flags */
     data = "{\"a:foo3\":[null]}";
     PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Invalid non-number-encoded uint32 value \"\".", "Schema location \"/a:foo3\", line number 1.");
+            "Invalid non-number-encoded uint32 value \"\".", "/a:foo3", 1);
 
     /* opaq flag */
     CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
@@ -545,8 +540,7 @@
     /* missing key, no flags */
     data = "{\"a:l1\":[{\"a\":\"val_a\",\"b\":\"val_b\",\"d\":\"val_d\"}]}";
     PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"c\".",
-            "Data location \"/a:l1[a='val_a'][b='val_b']\", line number 1.");
+            "List instance is missing its key \"c\".", "/a:l1[a='val_a'][b='val_b']", 1);
 
     /* opaq flag */
     CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
@@ -557,8 +551,7 @@
     /* invalid key, no flags */
     data = "{\"a:l1\":[{\"a\":\"val_a\",\"b\":\"val_b\",\"c\":\"val_c\"}]}";
     PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Invalid non-number-encoded int16 value \"val_c\".",
-            "Data location \"/a:l1[a='val_a'][b='val_b']/c\", line number 1.");
+            "Invalid non-number-encoded int16 value \"val_c\".", "/a:l1[a='val_a'][b='val_b']/c", 1);
 
     /* opaq flag */
     CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
@@ -580,13 +573,12 @@
 
     /* invalid metadata */
     data = "{\"@a:foo\":\"str\",\"@a:foo3\":1,\"a:foo3\":2}";
-    PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Unknown module of node \"@a:foo\".", "Path \"/\".");
-    CHECK_LOG_CTX("Missing JSON data instance to be coupled with @a:foo metadata.", "Data location \"/@a:foo\", line number 1.");
+    PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID, "Unknown module of node \"@a:foo\".", "/", 0);
+    CHECK_LOG_CTX("Missing JSON data instance to be coupled with @a:foo metadata.", "/@a:foo", 1);
 
     /* empty name */
     PARSER_CHECK_ERROR("{\"@a:foo\":{\"\":0}}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "JSON object member name cannot be a zero-length string.", "Data location \"/@a:foo\", line number 1.");
+            "JSON object member name cannot be a zero-length string.", "/@a:foo", 1);
 
     /* opaque data tree format print */
     data =
@@ -911,7 +903,7 @@
     data = "{\"a:c\":{\"x\":\"xval\",\"@x\":{\"a:hint\":\"value\"}}}";
     assert_int_equal(LY_EVALID, lyd_parse_data_mem(_UC->ctx, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree));
     assert_null(tree);
-    CHECK_LOG_CTX("Invalid non-number-encoded int8 value \"value\".", "Path \"/a:c/x/@a:hint\", line number 1.");
+    CHECK_LOG_CTX("Invalid non-number-encoded int8 value \"value\".", "/a:c/x/@a:hint", 1);
 }
 
 int
diff --git a/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index 4f33f00..d5336c0 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -61,9 +61,9 @@
 #define CHECK_PARSE_LYD(INPUT, PARSE_OPTION, VALIDATE_OPTION, TREE) \
     CHECK_PARSE_LYD_PARAM(INPUT, LYD_XML, PARSE_OPTION, VALIDATE_OPTION, LY_SUCCESS, TREE)
 
-#define PARSER_CHECK_ERROR(INPUT, PARSE_OPTION, VALIDATE_OPTION, MODEL, RET_VAL, ERR_MESSAGE, ERR_PATH) \
+#define PARSER_CHECK_ERROR(INPUT, PARSE_OPTION, VALIDATE_OPTION, MODEL, RET_VAL, ERR_MESSAGE, ERR_PATH, ERR_LINE) \
     assert_int_equal(RET_VAL, lyd_parse_data_mem(UTEST_LYCTX, INPUT, LYD_XML, PARSE_OPTION, VALIDATE_OPTION, &MODEL));\
-    CHECK_LOG_CTX(ERR_MESSAGE, ERR_PATH);\
+    CHECK_LOG_CTX(ERR_MESSAGE, ERR_PATH, ERR_LINE);\
     assert_null(MODEL)
 
 #define CHECK_LYD_STRING(IN_MODEL, PRINT_OPTION, TEXT) \
@@ -118,8 +118,7 @@
     /* invalid value */
     data = "<l1 xmlns=\"urn:tests:a\"><a>val-a</a><b>val-b</b><c>1</c><cont><e>0</e></cont></l1>";
     PARSER_CHECK_ERROR(data, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Invalid boolean value \"0\".",
-            "Data location \"/a:l1[a='val-a'][b='val-b'][c='1']/cont/e\", line number 1.");
+            "Invalid boolean value \"0\".", "/a:l1[a='val-a'][b='val-b'][c='1']/cont/e", 1);
 }
 
 static void
@@ -217,22 +216,21 @@
 
     /* missing keys */
     PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"a\".", "Data location \"/a:l1[b='b'][c='1']\", line number 1.");
-    CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL);
+            "List instance is missing its key \"a\".", "/a:l1[b='b'][c='1']", 1);
+    CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL, 0);
 
     PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><a>a</a></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"b\".", "Data location \"/a:l1[a='a']\", line number 1.");
+            "List instance is missing its key \"b\".", "/a:l1[a='a']", 1);
 
     PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><b>b</b><a>a</a></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"c\".", "Data location \"/a:l1[a='a'][b='b']\", line number 1.");
-    CHECK_LOG_CTX("Invalid position of the key \"a\" in a list.", NULL);
+            "List instance is missing its key \"c\".", "/a:l1[a='a'][b='b']", 1);
+    CHECK_LOG_CTX("Invalid position of the key \"a\" in a list.", NULL, 0);
 
     /* key duplicate */
     PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b><a>a</a><c>1</c></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Duplicate instance of \"c\".",
-            "Data location \"/a:l1[a='a'][b='b'][c='1'][c='1']/c\", line number 1.");
-    CHECK_LOG_CTX("Invalid position of the key \"a\" in a list.", NULL);
-    CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL);
+            "Duplicate instance of \"c\".", "/a:l1[a='a'][b='b'][c='1'][c='1']/c", 1);
+    CHECK_LOG_CTX("Invalid position of the key \"a\" in a list.", NULL, 0);
+    CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL, 0);
 
     /* keys order */
     CHECK_PARSE_LYD("<l1 xmlns=\"urn:tests:a\"><d>d</d><a>a</a><c>1</c><b>b</b></l1>", 0, LYD_VALIDATE_PRESENT, tree);
@@ -247,7 +245,7 @@
     CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "c", 1, LYS_LEAF, 1, 0, NULL, 0);
     assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
     CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "d", 1, LYS_LEAF, 1, 0, NULL, 0);
-    CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL);
+    CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL, 0);
     lyd_free_all(tree);
 
     data = "<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b><a>a</a></l1>";
@@ -260,12 +258,12 @@
     CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "b", 1, LYS_LEAF, 1, 0, NULL, 0);
     assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
     CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "c", 1, LYS_LEAF, 1, 0, NULL, 0);
-    CHECK_LOG_CTX("Invalid position of the key \"a\" in a list.", NULL);
-    CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL);
+    CHECK_LOG_CTX("Invalid position of the key \"a\" in a list.", NULL, 0);
+    CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL, 0);
     lyd_free_all(tree);
 
     PARSER_CHECK_ERROR(data, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Invalid position of the key \"b\" in a list.", "Data location \"/a:l1[c='1']/b\", line number 1.");
+            "Invalid position of the key \"b\" in a list.", "/a:l1[c='1']/b", 1);
 }
 
 static void
@@ -299,7 +297,7 @@
     /* invalid value, no flags */
     data = "<foo3 xmlns=\"urn:tests:a\"/>";
     PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Invalid type uint32 empty value.", "Schema location \"/a:foo3\", line number 1.");
+            "Invalid type uint32 empty value.", "/a:foo3", 1);
 
     /* opaq flag */
     CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
@@ -321,8 +319,7 @@
             "  <d>val_d</d>\n"
             "</l1>\n";
     PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "List instance is missing its key \"c\".",
-            "Data location \"/a:l1[a='val_a'][b='val_b']\", line number 5.");
+            "List instance is missing its key \"c\".", "/a:l1[a='val_a'][b='val_b']", 5);
 
     /* opaq flag */
     CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
@@ -337,8 +334,7 @@
             "  <c>val_c</c>\n"
             "</l1>\n";
     PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
-            "Invalid type int16 value \"val_c\".",
-            "Data location \"/a:l1[a='val_a'][b='val_b']/c\", line number 4.");
+            "Invalid type int16 value \"val_c\".", "/a:l1[a='val_a'][b='val_b']/c", 4);
 
     /* opaq flag */
     CHECK_PARSE_LYD(data, LYD_PARSE_OPAQ | LYD_PARSE_ONLY, 0, tree);
@@ -353,7 +349,7 @@
             "  <c xmld:id=\"D\">1</c>\n"
             "</a>\n",
             LYD_XML, LYD_PARSE_OPAQ, LYD_VALIDATE_PRESENT, &tree));
-    CHECK_LOG_CTX("Unknown XML prefix \"xmld\".", "Data location \"/a\", line number 3.");
+    CHECK_LOG_CTX("Unknown XML prefix \"xmld\".", "/a", 3);
 }
 
 static void
@@ -658,7 +654,7 @@
     assert_int_equal(LY_EVALID, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_XML, LYD_TYPE_RPC_NETCONF, &tree, &op));
     ly_in_free(in, 0);
     CHECK_LOG_CTX("Invalid enumeration value \"merge2\".",
-            "Path \"/ietf-netconf:copy-config/source/config/a:l1[a='val_a'][b='val_b'][c='5']/cont/e/@ietf-netconf:operation\", line number 13.");
+            "/ietf-netconf:copy-config/source/config/a:l1[a='val_a'][b='val_b'][c='5']/cont/e/@ietf-netconf:operation", 13);
     lyd_free_all(tree);
     assert_null(op);
 }
@@ -974,7 +970,7 @@
     data = "<c xmlns=\"urn:tests:a\" xmlns:a=\"urn:tests:a\"><x a:attr=\"value\">xval</x></c>";
     assert_int_equal(LY_EVALID, lyd_parse_data_mem(_UC->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
     assert_null(tree);
-    CHECK_LOG_CTX("Invalid enumeration value \"value\".", "Path \"/a:c/x/@a:attr\", line number 1.");
+    CHECK_LOG_CTX("Invalid enumeration value \"value\".", "/a:c/x/@a:attr", 1);
 }
 
 static void
@@ -1004,7 +1000,7 @@
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
     assert_int_equal(LY_EVALID, lyd_parse_data(UTEST_LYCTX, tree, in, LYD_XML, 0, LYD_VALIDATE_PRESENT, NULL));
     ly_in_free(in, 0);
-    CHECK_LOG_CTX("Duplicate instance of \"cont\".", "Data location \"/a:l1[a='val_a'][b='val_b'][c='1']/cont\".");
+    CHECK_LOG_CTX("Duplicate instance of \"cont\".", "/a:l1[a='val_a'][b='val_b'][c='1']/cont", 0);
 
     lyd_free_all(tree);
 }
diff --git a/tests/utests/data/test_tree_data.c b/tests/utests/data/test_tree_data.c
index 5dd3473..fabd170 100644
--- a/tests/utests/data/test_tree_data.c
+++ b/tests/utests/data/test_tree_data.c
@@ -370,8 +370,7 @@
     CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree1);
     assert_int_equal(LY_EINVAL, lyd_dup_single(((struct lyd_node_inner *)tree1)->child->prev,
             (struct lyd_node_inner *)tree1->next, LYD_DUP_WITH_PARENTS, NULL));
-    CHECK_LOG_CTX("None of the duplicated node \"c\" schema parents match the provided parent \"c\".",
-            NULL);
+    CHECK_LOG_CTX("None of the duplicated node \"c\" schema parents match the provided parent \"c\".", NULL, 0);
     lyd_free_all(tree1);
 }
 
@@ -499,7 +498,7 @@
     assert_int_equal(LY_SUCCESS, lyd_find_path(root, "/c:cont/pref[.='fc00::/64']", 0, NULL));
 
     assert_int_equal(LY_EVALID, lyd_find_path(root, "/cont", 0, NULL));
-    CHECK_LOG_CTX("Prefix missing for \"cont\" in path.", "Schema location \"/c:cont\".");
+    CHECK_LOG_CTX("Prefix missing for \"cont\" in path.", "/c:cont", 0);
     assert_int_equal(LY_SUCCESS, lyd_find_path(root, "nexthop[gateway='2100::1']", 0, NULL));
 
     lyd_free_all(root);
@@ -539,7 +538,7 @@
 
     /* The run must not crash due to the assert that checks the hash. */
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"ll\".", "Data location \"/test-data-hash:c/ll[.='']\", line number 1.");
+    CHECK_LOG_CTX("Duplicate instance of \"ll\".", "/test-data-hash:c/ll[.='']", 1);
     lyd_free_all(tree);
 }
 
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index d0dcae5..17fd078 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -57,7 +57,7 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     CHECK_PARSE_LYD_PARAM("<c xmlns=\"urn:tests:a\">hey</c>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("When condition \"/cont/b = 'val_b'\" not satisfied.", "Data location \"/a:c\".");
+    CHECK_LOG_CTX("When condition \"/cont/b = 'val_b'\" not satisfied.", "/a:c", 0);
 
     LYD_TREE_CREATE("<cont xmlns=\"urn:tests:a\"><b>val_b</b></cont><c xmlns=\"urn:tests:a\">hey</c>", tree);
     CHECK_LYSC_NODE(tree->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "c", 0, LYS_LEAF, 0, 0, NULL, 1);
@@ -105,10 +105,10 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     CHECK_PARSE_LYD_PARAM("<d xmlns=\"urn:tests:a\">hey</d>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("When condition \"../c = 'val_c'\" not satisfied.", "Data location \"/a:d\".");
+    CHECK_LOG_CTX("When condition \"../c = 'val_c'\" not satisfied.", "/a:d", 0);
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:a\"><b>hey</b></cont>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("When condition \"../a = 'val_a'\" not satisfied.", "Data location \"/a:cont/b\".");
+    CHECK_LOG_CTX("When condition \"../a = 'val_a'\" not satisfied.", "/a:cont/b", 0);
 
     LYD_TREE_CREATE("<c xmlns=\"urn:tests:a\">val_c</c><d xmlns=\"urn:tests:a\">hey</d>", tree);
     CHECK_LYSC_NODE(tree->next->next->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_MAND_TRUE, 1, "d", 0, LYS_LEAF, 0, 0, NULL, 1);
@@ -196,13 +196,13 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     CHECK_PARSE_LYD_PARAM("<d xmlns=\"urn:tests:b\"/>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX_APPTAG("Mandatory choice \"choic\" data do not exist.", "Schema location \"/b:choic\".", "missing-choice");
+    CHECK_LOG_CTX_APPTAG("Mandatory choice \"choic\" data do not exist.", "/b:choic", 0, "missing-choice");
 
     CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:b\">string</l><d xmlns=\"urn:tests:b\"/>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Mandatory node \"c\" instance does not exist.", "Schema location \"/b:c\".");
+    CHECK_LOG_CTX("Mandatory node \"c\" instance does not exist.", "/b:c", 0);
 
     CHECK_PARSE_LYD_PARAM("<a xmlns=\"urn:tests:b\">string</a>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Mandatory node \"c\" instance does not exist.", "Schema location \"/b:c\".");
+    CHECK_LOG_CTX("Mandatory node \"c\" instance does not exist.", "/b:c", 0);
 
     LYD_TREE_CREATE("<a xmlns=\"urn:tests:b\">string</a><c xmlns=\"urn:tests:b\">string2</c>", tree);
     lyd_free_siblings(tree);
@@ -246,12 +246,12 @@
     CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:c\">mate</l>"
             "<d xmlns=\"urn:tests:c\"/>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX_APPTAG("Too few \"l\" instances.", "Schema location \"/c:choic/b/l\".", "too-few-elements");
+    CHECK_LOG_CTX_APPTAG("Too few \"l\" instances.", "/c:choic/b/l", 0, "too-few-elements");
 
     CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:c\">val1</l>"
             "<l xmlns=\"urn:tests:c\">val2</l>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX_APPTAG("Too few \"l\" instances.", "Schema location \"/c:choic/b/l\".", "too-few-elements");
+    CHECK_LOG_CTX_APPTAG("Too few \"l\" instances.", "/c:choic/b/l", 0, "too-few-elements");
 
     LYD_TREE_CREATE("<l xmlns=\"urn:tests:c\">val1</l>"
             "<l xmlns=\"urn:tests:c\">val2</l>"
@@ -267,8 +267,7 @@
             "<lt xmlns=\"urn:tests:c\"><k>val4</k></lt>"
             "<lt xmlns=\"urn:tests:c\"><k>val5</k></lt>"
             "<lt xmlns=\"urn:tests:c\"><k>val6</k></lt>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX_APPTAG("Too many \"lt\" instances.", "Data location \"/c:lt[k='val5']\".",
-            "too-many-elements");
+    CHECK_LOG_CTX_APPTAG("Too many \"lt\" instances.", "/c:lt[k='val5']", 0, "too-many-elements");
 }
 
 const char *schema_d =
@@ -356,7 +355,7 @@
             "    <l1>same</l1>\n"
             "</lt>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX_APPTAG("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val1']\" and \"/d:lt[k='val2']\".",
-            "Data location \"/d:lt[k='val2']\".", "data-not-unique");
+            "/d:lt[k='val2']", 0, "data-not-unique");
 
     /* now try with more instances */
     LYD_TREE_CREATE("<lt xmlns=\"urn:tests:d\">\n"
@@ -454,7 +453,7 @@
             "    <l1>8</l1>\n"
             "</lt>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX_APPTAG("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val7']\" and \"/d:lt[k='val2']\".",
-            "Data location \"/d:lt[k='val2']\".", "data-not-unique");
+            "/d:lt[k='val2']", 0, "data-not-unique");
 }
 
 static void
@@ -579,8 +578,7 @@
             "    </lt3>\n"
             "</lt2>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX_APPTAG("Unique data leaf(s) \"l3\" not satisfied in \"/d:lt2[k='val2']/lt3[kk='val3']\" and "
-            "\"/d:lt2[k='val2']/lt3[kk='val1']\".",
-            "Data location \"/d:lt2[k='val2']/lt3[kk='val1']\".", "data-not-unique");
+            "\"/d:lt2[k='val2']/lt3[kk='val1']\".", "/d:lt2[k='val2']/lt3[kk='val1']", 0, "data-not-unique");
 
     CHECK_PARSE_LYD_PARAM("<lt2 xmlns=\"urn:tests:d\">\n"
             "    <k>val1</k>\n"
@@ -618,7 +616,7 @@
             "    <l4>5</l4>\n"
             "</lt2>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX_APPTAG("Unique data leaf(s) \"cont/l2 l4\" not satisfied in \"/d:lt2[k='val4']\" and \"/d:lt2[k='val2']\".",
-            "Data location \"/d:lt2[k='val2']\".", "data-not-unique");
+            "/d:lt2[k='val2']", 0, "data-not-unique");
 
     CHECK_PARSE_LYD_PARAM("<lt2 xmlns=\"urn:tests:d\">\n"
             "    <k>val1</k>\n"
@@ -664,7 +662,7 @@
             "    <l6>3</l6>\n"
             "</lt2>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     CHECK_LOG_CTX_APPTAG("Unique data leaf(s) \"l5 l6\" not satisfied in \"/d:lt2[k='val5']\" and \"/d:lt2[k='val3']\".",
-            "Data location \"/d:lt2[k='val3']\".", "data-not-unique");
+            "/d:lt2[k='val3']", 0, "data-not-unique");
 }
 
 static void
@@ -725,28 +723,28 @@
 
     CHECK_PARSE_LYD_PARAM("<d xmlns=\"urn:tests:e\">25</d><d xmlns=\"urn:tests:e\">50</d>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"d\".", "Data location \"/e:d\".");
+    CHECK_LOG_CTX("Duplicate instance of \"d\".", "/e:d", 0);
 
     CHECK_PARSE_LYD_PARAM("<lt xmlns=\"urn:tests:e\"><k>A</k></lt>"
             "<lt xmlns=\"urn:tests:e\"><k>B</k></lt>"
             "<lt xmlns=\"urn:tests:e\"><k>A</k></lt>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"lt\".", "Data location \"/e:lt[k='A']\".");
+    CHECK_LOG_CTX("Duplicate instance of \"lt\".", "/e:lt[k='A']", 0);
 
     CHECK_PARSE_LYD_PARAM("<ll xmlns=\"urn:tests:e\">A</ll>"
             "<ll xmlns=\"urn:tests:e\">B</ll>"
             "<ll xmlns=\"urn:tests:e\">B</ll>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"ll\".", "Data location \"/e:ll[.='B']\".");
+    CHECK_LOG_CTX("Duplicate instance of \"ll\".", "/e:ll[.='B']", 0);
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"></cont><cont xmlns=\"urn:tests:e\"/>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"cont\".", "Data location \"/e:cont\".");
+    CHECK_LOG_CTX("Duplicate instance of \"cont\".", "/e:cont", 0);
 
     /* same tests again but using hashes */
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"><d>25</d><d>50</d><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll></cont>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"d\".", "Data location \"/e:cont/d\", line number 1.");
+    CHECK_LOG_CTX("Duplicate instance of \"d\".", "/e:cont/d", 1);
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll>"
             "<lt><k>a</k></lt>"
@@ -755,12 +753,12 @@
             "<lt><k>d</k></lt>"
             "<lt><k>c</k></lt></cont>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"lt\".", "Data location \"/e:cont/lt[k='c']\", line number 1.");
+    CHECK_LOG_CTX("Duplicate instance of \"lt\".", "/e:cont/lt[k='c']", 1);
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:e\"><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll>"
             "<ll>a</ll><ll>b</ll><ll>c</ll><ll>d</ll><ll>d</ll></cont>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"ll\".", "Data location \"/e:cont/ll[.='d']\", line number 1.");
+    CHECK_LOG_CTX("Duplicate instance of \"ll\".", "/e:cont/ll[.='d']", 1);
 
     /* cases */
     CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:e\">a</l>"
@@ -768,13 +766,13 @@
             "<l xmlns=\"urn:tests:e\">c</l>"
             "<l xmlns=\"urn:tests:e\">b</l>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Duplicate instance of \"l\".", "Data location \"/e:l[.='b']\".");
+    CHECK_LOG_CTX("Duplicate instance of \"l\".", "/e:l[.='b']", 0);
 
     CHECK_PARSE_LYD_PARAM("<l xmlns=\"urn:tests:e\">a</l><l xmlns=\"urn:tests:e\">b</l>"
             "<l xmlns=\"urn:tests:e\">c</l>"
             "<a xmlns=\"urn:tests:e\">aa</a>",
             LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Data for both cases \"a\" and \"b\" exist.", "Schema location \"/e:choic\".");
+    CHECK_LOG_CTX("Data for both cases \"a\" and \"b\" exist.", "/e:choic", 0);
 }
 
 static void
@@ -1094,13 +1092,11 @@
             "  </cont2>\n"
             "</cont>\n";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_NO_STATE, 0, LY_EVALID, tree);
-    CHECK_LOG_CTX("Unexpected data state node \"cont2\" found.",
-            "Data location \"/h:cont/cont2\", line number 3.");
+    CHECK_LOG_CTX("Unexpected data state node \"cont2\" found.", "/h:cont/cont2", 3);
 
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_ONLY, 0, LY_SUCCESS, tree);
     assert_int_equal(LY_EVALID, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT | LYD_VALIDATE_NO_STATE, NULL));
-    CHECK_LOG_CTX("Unexpected data state node \"cont2\" found.",
-            "Data location \"/h:cont/cont2\".");
+    CHECK_LOG_CTX("Unexpected data state node \"cont2\" found.", "/h:cont/cont2", 0);
     lyd_free_all(tree);
 }
 
@@ -1138,8 +1134,7 @@
             "  <l>wrong</l>\n"
             "  <l2>val</l2>\n"
             "</cont>\n", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.",
-            "Data location \"/i:cont/l2\".", "must-violation");
+    CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.", "/i:cont/l2", 0, "must-violation");
 
     LYD_TREE_CREATE("<cont xmlns=\"urn:tests:i\">\n"
             "  <l>right</l>\n"
@@ -1151,7 +1146,7 @@
             "  <l>wrong</l>\n"
             "  <l3>val</l3>\n"
             "</cont>\n", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX_APPTAG("l leaf is not left", "Data location \"/i:cont/l3\".", "not-left");
+    CHECK_LOG_CTX_APPTAG("l leaf is not left", "/i:cont/l3", 0, "not-left");
 }
 
 static void
@@ -1199,10 +1194,10 @@
             "  <ll>ahoy</ll>\n"
             "</cont>\n";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT | LYD_VALIDATE_MULTI_ERROR, LY_EVALID, tree);
-    CHECK_LOG_CTX_APPTAG("Too few \"ll\" instances.", "Schema location \"/ii:cont/ll\".", "too-few-elements");
-    CHECK_LOG_CTX_APPTAG("l leaf is not left", "Data location \"/ii:cont/l3\".", "not-left");
-    CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.", "Data location \"/ii:cont/l2\".", "must-violation");
-    CHECK_LOG_CTX_APPTAG("Invalid type uint32 value \"ahoy\".", "Data location \"/ii:cont/ll\", line number 6.", NULL);
+    CHECK_LOG_CTX_APPTAG("Too few \"ll\" instances.", "/ii:cont/ll", 0, "too-few-elements");
+    CHECK_LOG_CTX_APPTAG("l leaf is not left", "/ii:cont/l3", 0, "not-left");
+    CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.", "/ii:cont/l2", 0, "must-violation");
+    CHECK_LOG_CTX_APPTAG("Invalid type uint32 value \"ahoy\".", "/ii:cont/ll", 6, NULL);
 
     /* json */
     data = "{\n"
@@ -1215,10 +1210,10 @@
             "  }\n"
             "}\n";
     CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT | LYD_VALIDATE_MULTI_ERROR, LY_EVALID, tree);
-    CHECK_LOG_CTX_APPTAG("Too few \"ll\" instances.", "Schema location \"/ii:cont/ll\".", "too-few-elements");
-    CHECK_LOG_CTX_APPTAG("l leaf is not left", "Data location \"/ii:cont/l3\".", "not-left");
-    CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.", "Data location \"/ii:cont/l2\".", "must-violation");
-    CHECK_LOG_CTX_APPTAG("Invalid non-number-encoded uint32 value \"ahoy\".", "Data location \"/ii:cont/ll\", line number 7.", NULL);
+    CHECK_LOG_CTX_APPTAG("Too few \"ll\" instances.", "/ii:cont/ll", 0, "too-few-elements");
+    CHECK_LOG_CTX_APPTAG("l leaf is not left", "/ii:cont/l3", 0, "not-left");
+    CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.", "/ii:cont/l2", 0, "must-violation");
+    CHECK_LOG_CTX_APPTAG("Invalid non-number-encoded uint32 value \"ahoy\".", "/ii:cont/ll", 7, NULL);
 
     /* validation */
     data = "{\n"
@@ -1233,11 +1228,11 @@
     CHECK_PARSE_LYD_PARAM(data, LYD_JSON, LYD_PARSE_ONLY, 0, LY_SUCCESS, tree);
     assert_int_equal(LY_EVALID, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT | LYD_VALIDATE_MULTI_ERROR, NULL));
     lyd_free_tree(tree);
-    CHECK_LOG_CTX_APPTAG("Too few \"ll\" instances.", "Schema location \"/ii:cont/ll\".", "too-few-elements");
-    CHECK_LOG_CTX_APPTAG("l leaf is not left", "Data location \"/ii:cont/l3\".", "not-left");
-    CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.", "Data location \"/ii:cont/l2\".", "must-violation");
-    CHECK_LOG_CTX_APPTAG("Duplicate instance of \"l\".", "Data location \"/ii:cont/l\".", NULL);
-    CHECK_LOG_CTX_APPTAG("Duplicate instance of \"l\".", "Data location \"/ii:cont/l\".", NULL);
+    CHECK_LOG_CTX_APPTAG("Too few \"ll\" instances.", "/ii:cont/ll", 0, "too-few-elements");
+    CHECK_LOG_CTX_APPTAG("l leaf is not left", "/ii:cont/l3", 0, "not-left");
+    CHECK_LOG_CTX_APPTAG("Must condition \"../l = 'right'\" not satisfied.", "/ii:cont/l2", 0, "must-violation");
+    CHECK_LOG_CTX_APPTAG("Duplicate instance of \"l\".", "/ii:cont/l", 0, NULL);
+    CHECK_LOG_CTX_APPTAG("Duplicate instance of \"l\".", "/ii:cont/l", 0, NULL);
 }
 
 const char *schema_j =
@@ -1315,7 +1310,7 @@
     /* missing leafref */
     assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_TYPE_RPC_YANG, NULL));
     CHECK_LOG_CTX("Invalid leafref value \"target\" - no target instance \"/lf3\" with the same value.",
-            "Data location \"/j:cont/l1[k='val1']/act/lf2\".");
+            "/j:cont/l1[k='val1']/act/lf2", 0);
     ly_in_free(in, 0);
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:j\">\n"
@@ -1326,8 +1321,7 @@
 
     /* input must false */
     assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_TYPE_RPC_YANG, NULL));
-    CHECK_LOG_CTX("Must condition \"../../lf1 = 'true'\" not satisfied.",
-            "Data location \"/j:cont/l1[k='val1']/act\".");
+    CHECK_LOG_CTX("Must condition \"../../lf1 = 'true'\" not satisfied.", "/j:cont/l1[k='val1']/act", 0);
 
     lyd_free_all(tree);
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:j\">\n"
@@ -1380,7 +1374,7 @@
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
     assert_int_equal(LY_EVALID, lyd_parse_op(UTEST_LYCTX, NULL, in, LYD_XML, LYD_TYPE_RPC_YANG, &tree, NULL));
     CHECK_LOG_CTX("Unsatisfied length - string \"123\" length is not allowed.",
-            "Data location \"/val-str:modify-user-password/new-password\", line number 3.");
+            "/val-str:modify-user-password/new-password", 3);
     ly_in_free(in, 0);
 }
 
@@ -1409,7 +1403,7 @@
     /* missing leafref */
     assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_TYPE_REPLY_YANG, NULL));
     CHECK_LOG_CTX("Invalid leafref value \"target\" - no target instance \"/lf4\" with the same value.",
-            "Data location \"/j:cont/l1[k='val1']/act/lf2\".");
+            "/j:cont/l1[k='val1']/act/lf2", 0);
 
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:j\">\n"
             "  <lf1>not true</lf1>\n"
@@ -1419,7 +1413,7 @@
 
     /* input must false */
     assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_TYPE_REPLY_YANG, NULL));
-    CHECK_LOG_CTX("Must condition \"../../lf1 = 'true2'\" not satisfied.", "Data location \"/j:cont/l1[k='val1']/act\".");
+    CHECK_LOG_CTX("Must condition \"../../lf1 = 'true2'\" not satisfied.", "/j:cont/l1[k='val1']/act", 0);
 
     lyd_free_all(tree);
     CHECK_PARSE_LYD_PARAM("<cont xmlns=\"urn:tests:j\">\n"
@@ -1509,8 +1503,7 @@
             "    \"g7\": \"value_g7\"\n"
             "  }\n"
             "}\n", LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Data for both cases \"v0\" and \"v2\" exist.",
-            "Data location \"/k:ch\", line number 6.");
+    CHECK_LOG_CTX("Data for both cases \"v0\" and \"v2\" exist.", "/k:ch", 6);
 
     CHECK_PARSE_LYD_PARAM(
             "{\n"
@@ -1519,8 +1512,7 @@
             "    \"g0\": \"value_g0\"\n"
             "  }\n"
             "}\n", LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Data for both cases \"v0\" and \"v2\" exist.",
-            "Data location \"/k:ch\", line number 6.");
+    CHECK_LOG_CTX("Data for both cases \"v0\" and \"v2\" exist.", "/k:ch", 6);
 }
 
 int
diff --git a/tests/utests/extensions/test_metadata.c b/tests/utests/extensions/test_metadata.c
index f1edd29..fcaa9da 100644
--- a/tests/utests/extensions/test_metadata.c
+++ b/tests/utests/extensions/test_metadata.c
@@ -53,7 +53,7 @@
             "md:annotation aa;}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 metadata v1\": Missing mandatory keyword \"type\" as a child of \"md:annotation aa\".",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+            "/aa:{extension='md:annotation'}/aa", 0);
 
     /* not allowed substatement */
     data = "module aa {yang-version 1.1; namespace urn:tests:extensions:metadata:aa; prefix aa;"
@@ -61,31 +61,28 @@
             "md:annotation aa {default x;}}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Invalid keyword \"default\" as a child of \"md:annotation aa\" extension instance.",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+            "/aa:{extension='md:annotation'}/aa", 0);
 
     /* invalid cardinality of units substatement */
     data = "module aa {yang-version 1.1; namespace urn:tests:extensions:metadata:aa; prefix aa;"
             "import ietf-yang-metadata {prefix md;}"
             "md:annotation aa {type string; units x; units y;}}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate keyword \"units\".",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+    CHECK_LOG_CTX("Duplicate keyword \"units\".", "/aa:{extension='md:annotation'}/aa", 0);
 
     /* invalid cardinality of status substatement */
     data = "module aa {yang-version 1.1; namespace urn:tests:extensions:metadata:aa; prefix aa;"
             "import ietf-yang-metadata {prefix md;}"
             "md:annotation aa {type string; status current; status obsolete;}}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate keyword \"status\".",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+    CHECK_LOG_CTX("Duplicate keyword \"status\".", "/aa:{extension='md:annotation'}/aa", 0);
 
     /* invalid cardinality of status substatement */
     data = "module aa {yang-version 1.1; namespace urn:tests:extensions:metadata:aa; prefix aa;"
             "import ietf-yang-metadata {prefix md;}"
             "md:annotation aa {type string; type uint8;}}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate keyword \"type\".",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+    CHECK_LOG_CTX("Duplicate keyword \"type\".", "/aa:{extension='md:annotation'}/aa", 0);
 
     /* duplication of the same annotation */
     data = "module aa {yang-version 1.1; namespace urn:tests:extensions:metadata:aa; prefix aa;"
@@ -93,7 +90,7 @@
             "md:annotation aa {type string;} md:annotation aa {type uint8;}}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 metadata v1\": Extension md:annotation is instantiated multiple times.",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+            "/aa:{extension='md:annotation'}/aa", 0);
 }
 
 static void
@@ -134,7 +131,7 @@
             "</module>";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 metadata v1\": Missing mandatory keyword \"type\" as a child of \"md:annotation aa\".",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+            "/aa:{extension='md:annotation'}/aa", 0);
 
     /* not allowed substatement */
     data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"aa\">\n"
@@ -145,7 +142,7 @@
             "</md:annotation></module>";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
     CHECK_LOG_CTX("Invalid keyword \"default\" as a child of \"md:annotation aa\" extension instance.",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+            "/aa:{extension='md:annotation'}/aa", 0);
 
     /* invalid cardinality of units substatement */
     data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"aa\">\n"
@@ -157,8 +154,7 @@
             "  <units name=\"y\"/>\n"
             "</md:annotation></module>";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
-    CHECK_LOG_CTX("Duplicate keyword \"units\".",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+    CHECK_LOG_CTX("Duplicate keyword \"units\".", "/aa:{extension='md:annotation'}/aa", 0);
 
     /* invalid cardinality of status substatement */
     data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"aa\">\n"
@@ -170,8 +166,7 @@
             "  <status value=\"obsolete\"/>\n"
             "</md:annotation></module>";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
-    CHECK_LOG_CTX("Duplicate keyword \"status\".",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+    CHECK_LOG_CTX("Duplicate keyword \"status\".", "/aa:{extension='md:annotation'}/aa", 0);
 
     /* invalid cardinality of status substatement */
     data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"aa\">\n"
@@ -182,8 +177,7 @@
             "  <type name=\"uint8\"/>\n"
             "</md:annotation></module>";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
-    CHECK_LOG_CTX("Duplicate keyword \"type\".",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+    CHECK_LOG_CTX("Duplicate keyword \"type\".", "/aa:{extension='md:annotation'}/aa", 0);
 
     /* duplication of the same annotation */
     data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"aa\">\n"
@@ -196,7 +190,7 @@
             "</md:annotation></module>";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 metadata v1\": Extension md:annotation is instantiated multiple times.",
-            "Path \"/aa:{extension='md:annotation'}/aa\".");
+            "/aa:{extension='md:annotation'}/aa", 0);
 }
 
 int
diff --git a/tests/utests/extensions/test_nacm.c b/tests/utests/extensions/test_nacm.c
index 5f7028e..0b1cb8b 100644
--- a/tests/utests/extensions/test_nacm.c
+++ b/tests/utests/extensions/test_nacm.c
@@ -58,7 +58,7 @@
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 NACM v1\": "
             "Extension nacm:default-deny-all is allowed only in a data nodes, but it is placed in \"module\" statement.",
-            "Path \"/b:{extension='nacm:default-deny-all'}\".");
+            "/b:{extension='nacm:default-deny-all'}", 0);
 
     /* invalid */
     data = "module aa {yang-version 1.1; namespace urn:tests:extensions:nacm:aa; prefix en;"
@@ -67,7 +67,7 @@
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 NACM v1\": "
             "Extension nacm:default-deny-write is mixed with nacm:default-deny-all.",
-            "Path \"/aa:l/{extension='nacm:default-deny-all'}\".");
+            "/aa:l/{extension='nacm:default-deny-all'}", 0);
 }
 
 static void
@@ -100,7 +100,7 @@
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 NACM v1\": "
             "Extension nacm:default-deny-write is not allowed in notification statement.",
-            "Path \"/b:notif/{extension='nacm:default-deny-write'}\".");
+            "/b:notif/{extension='nacm:default-deny-write'}", 0);
 
     /* invalid */
     data = "module aa {yang-version 1.1; namespace urn:tests:extensions:nacm:aa; prefix en;"
@@ -109,7 +109,7 @@
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 NACM v1\": "
             "Extension nacm:default-deny-write is instantiated multiple times.",
-            "Path \"/aa:l/{extension='nacm:default-deny-write'}\".");
+            "/aa:l/{extension='nacm:default-deny-write'}", 0);
 }
 
 int
diff --git a/tests/utests/extensions/test_schema_mount.c b/tests/utests/extensions/test_schema_mount.c
index 17a4c94..f27e168 100644
--- a/tests/utests/extensions/test_schema_mount.c
+++ b/tests/utests/extensions/test_schema_mount.c
@@ -75,7 +75,7 @@
     assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
             "Extension \"yangmnt:mount-point\" instance not allowed in YANG version 1 module.",
-            "Path \"/sm:root/{extension='yangmnt:mount-point'}/root\".");
+            "/sm:root/{extension='yangmnt:mount-point'}/root", 0);
 
     schema =
             "module sm {\n"
@@ -92,7 +92,7 @@
     assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
             "Extension \"yangmnt:mount-point\" instance allowed only in container or list statement.",
-            "Path \"/sm:{extension='yangmnt:mount-point'}/root\".");
+            "/sm:{extension='yangmnt:mount-point'}/root", 0);
 
     schema =
             "module sm {\n"
@@ -114,7 +114,7 @@
     assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
             "Extension \"yangmnt:mount-point\" instance allowed only in container or list statement.",
-            "Path \"/sm:root/l/{extension='yangmnt:mount-point'}/root\".");
+            "/sm:root/l/{extension='yangmnt:mount-point'}/root", 0);
 
     schema =
             "module sm {\n"
@@ -138,7 +138,7 @@
     assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
             "Multiple extension \"yangmnt:mount-point\" instances.",
-            "Path \"/sm:l/{extension='yangmnt:mount-point'}/root\".");
+            "/sm:l/{extension='yangmnt:mount-point'}/root", 0);
 
     /* valid */
     schema =
@@ -196,7 +196,7 @@
             "</root>";
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EINVAL, data);
     CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": Failed to get extension data, no callback set.",
-            NULL);
+            NULL, 0);
 
     json =
             "{"
@@ -213,7 +213,7 @@
             "}";
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EINVAL, data);
     CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": Failed to get extension data, no callback set.",
-            NULL);
+            NULL, 0);
 
     /* unknown data */
     ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb, NULL);
@@ -225,8 +225,7 @@
     lyd_free_siblings(data);
 
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
-    CHECK_LOG_CTX("No module with namespace \"unknown\" in the context.",
-            "Data location \"/sm:root\", line number 1.");
+    CHECK_LOG_CTX("No module with namespace \"unknown\" in the context.", "/sm:root", 1);
 
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_SUCCESS, data);
     assert_string_equal(LYD_NAME(data), "root");
@@ -236,8 +235,7 @@
     lyd_free_siblings(data);
 
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
-    CHECK_LOG_CTX("No module named \"unknown\" in the context.",
-            "Data location \"/sm:root\", line number 1.");
+    CHECK_LOG_CTX("No module named \"unknown\" in the context.", "/sm:root", 1);
 
     /* missing required callback data */
     xml =
@@ -249,8 +247,7 @@
             "  </interfaces>"
             "</root>";
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
-    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
-            "Data location \"/sm:root\", line number 1.");
+    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", "/sm:root", 1);
 
     json =
             "{"
@@ -265,8 +262,7 @@
             "  }"
             "}";
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
-    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
-            "Data location \"/sm:root\", line number 1.");
+    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", "/sm:root", 1);
 
     ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb,
             "<yang-library xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\" "
@@ -297,11 +293,9 @@
             "  <module-set-id>1</module-set-id>"
             "</modules-state>");
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
-    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
-            "Data location \"/sm:root\", line number 1.");
+    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", "/sm:root", 1);
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
-    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
-            "Data location \"/sm:root\", line number 1.");
+    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", "/sm:root", 1);
 
     /* missing module in yang-library data */
     ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb,
@@ -340,11 +334,9 @@
             "  </mount-point>"
             "</schema-mounts>");
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
-    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
-            "Data location \"/sm:root\", line number 1.");
+    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", "/sm:root", 1);
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
-    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.",
-            "Data location \"/sm:root\", line number 1.");
+    CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", "/sm:root", 1);
 
     /* callback data correct, invalid YANG data */
     ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb,
@@ -408,27 +400,23 @@
             "  </mount-point>"
             "</schema-mounts>");
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
-    CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
-            "Mandatory node \"type\" instance does not exist.",
-            "Data location \"/ietf-interfaces:interfaces/interface[name='bu']\".");
+    CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": Mandatory node \"type\" instance does not exist.",
+            "/ietf-interfaces:interfaces/interface[name='bu']", 0);
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
-    CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
-            "Mandatory node \"type\" instance does not exist.",
-            "Data location \"/ietf-interfaces:interfaces/interface[name='bu']\".");
+    CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": Mandatory node \"type\" instance does not exist.",
+            "/ietf-interfaces:interfaces/interface[name='bu']", 0);
 
     /* same validation fail in separate validation */
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT | LYD_PARSE_ONLY, 0, LY_SUCCESS, data);
     assert_int_equal(LY_EVALID, lyd_validate_all(&data, NULL, LYD_VALIDATE_PRESENT, NULL));
-    CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
-            "Mandatory node \"type\" instance does not exist.",
-            "Data location \"/ietf-interfaces:interfaces/interface[name='bu']\".");
+    CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": Mandatory node \"type\" instance does not exist.",
+            "/ietf-interfaces:interfaces/interface[name='bu']", 0);
     lyd_free_siblings(data);
 
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT | LYD_PARSE_ONLY, 0, LY_SUCCESS, data);
     assert_int_equal(LY_EVALID, lyd_validate_all(&data, NULL, LYD_VALIDATE_PRESENT, NULL));
-    CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
-            "Mandatory node \"type\" instance does not exist.",
-            "Data location \"/ietf-interfaces:interfaces/interface[name='bu']\".");
+    CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": Mandatory node \"type\" instance does not exist.",
+            "/ietf-interfaces:interfaces/interface[name='bu']", 0);
     lyd_free_siblings(data);
 
     /* success */
@@ -878,7 +866,7 @@
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
     CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
             "Shared-schema yang-library content-id \"2\" differs from \"1\" used previously.",
-            "Path \"/ietf-yang-library:yang-library/content-id\".");
+            "/ietf-yang-library:yang-library/content-id", 0);
 
     /* data for 2 mount points */
     ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb,
@@ -1134,7 +1122,7 @@
     CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
     CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
             "Invalid leafref value \"target-value\" - no target instance \"/sm:target\" with the same value.",
-            "Data location \"/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name\".");
+            "/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name", 0);
 
     json =
             "{\n"
@@ -1159,7 +1147,7 @@
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
     CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
             "Invalid leafref value \"target-value\" - no target instance \"/sm:target\" with the same value.",
-            "Data location \"/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name\".");
+            "/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name", 0);
 
     /* success */
     xml =
diff --git a/tests/utests/extensions/test_structure.c b/tests/utests/extensions/test_structure.c
index 9bad7a7..cc8ed71 100644
--- a/tests/utests/extensions/test_structure.c
+++ b/tests/utests/extensions/test_structure.c
@@ -148,7 +148,7 @@
             "sx:structure struct {import yang;}}";
     UTEST_INVALID_MODULE(data, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid keyword \"import\" as a child of \"sx:structure struct\" extension instance.",
-            "Path \"/a:{extension='sx:structure'}/struct\".");
+            "/a:{extension='sx:structure'}/struct", 0);
 
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:structure:a; prefix self;"
             "import ietf-yang-structure-ext {prefix sx;}"
@@ -156,14 +156,14 @@
     UTEST_INVALID_MODULE(data, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Ext plugin \"ly2 structure v1\": "
             "Extension sx:structure must not be used as a non top-level statement in \"container\" statement.",
-            "Path \"/a:b/{extension='sx:structure'}/struct\".");
+            "/a:b/{extension='sx:structure'}/struct", 0);
 
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:structure:a; prefix self;"
             "import ietf-yang-structure-ext {prefix sx;}"
             "sx:structure { container x { leaf x {type string;}}}}";
     UTEST_INVALID_MODULE(data, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Extension instance \"sx:structure\" missing argument element \"name\".", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Extension instance \"sx:structure\" missing argument element \"name\".", NULL, 0);
 
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:structure:a; prefix self;"
             "import ietf-yang-structure-ext {prefix sx;}"
@@ -171,7 +171,7 @@
             "sx:structure struct { container y { leaf y {type string;}}}}";
     UTEST_INVALID_MODULE(data, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Ext plugin \"ly2 structure v1\": Extension sx:structure is instantiated multiple times.",
-            "Path \"/a:{extension='sx:structure'}/struct\".");
+            "/a:{extension='sx:structure'}/struct", 0);
 
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:structure:a; prefix self;"
             "import ietf-yang-structure-ext {prefix sx;}"
@@ -179,7 +179,7 @@
             "choice struct { container y { leaf y {type string;}}}}";
     UTEST_INVALID_MODULE(data, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Ext plugin \"ly2 structure v1\": Extension sx:structure collides with a choice with the same identifier.",
-            "Path \"/a:{extension='sx:structure'}/struct\".");
+            "/a:{extension='sx:structure'}/struct", 0);
 
     /* augment-structure */
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:structure:a; prefix a;"
@@ -199,7 +199,7 @@
             "}}";
     UTEST_INVALID_MODULE(data, LYS_IN_YANG, NULL, LY_ENOTFOUND);
     CHECK_LOG_CTX("Augment extension target node \"/a:n1\" from module \"b\" was not found.",
-            "Path \"/b:{extension='sx:augment-structure'}/{augment='/a:n1'}\".");
+            "/b:{extension='sx:augment-structure'}/{augment='/a:n1'}", 0);
 }
 
 static void
diff --git a/tests/utests/extensions/test_yangdata.c b/tests/utests/extensions/test_yangdata.c
index 57caaf2..4de8980 100644
--- a/tests/utests/extensions/test_yangdata.c
+++ b/tests/utests/extensions/test_yangdata.c
@@ -119,7 +119,7 @@
     assert_null(mod->compiled->exts);
     CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
             "Extension rc:yang-data is ignored since it appears as a non top-level statement in \"container\" statement.",
-            "Path \"/b:b/{extension='rc:yang-data'}/template\".");
+            "/b:b/{extension='rc:yang-data'}/template", 0);
     assert_int_equal(LY_SUCCESS, lys_print_mem(&printed, mod, LYS_OUT_YANG_COMPILED, 0));
     assert_string_equal(printed, info);
     free(printed);
@@ -168,7 +168,7 @@
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Invalid keyword \"leaf\" as a child of \"rc:yang-data template\" extension instance.",
-            "Path \"/a:{extension='rc:yang-data'}/template\".");
+            "/a:{extension='rc:yang-data'}/template", 0);
 
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:yangdata:a; prefix self;"
             "import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
@@ -176,8 +176,7 @@
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
             "Extension rc:yang-data is instantiated with leaf top level data node (inside a choice), "
-            "but only a single container data node is allowed.",
-            "Path \"/a:{extension='rc:yang-data'}/template\".");
+            "but only a single container data node is allowed.", "/a:{extension='rc:yang-data'}/template", 0);
 
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:yangdata:a; prefix self;"
             "import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
@@ -185,8 +184,7 @@
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
             "Extension rc:yang-data is instantiated with multiple top level data nodes (inside a single choice's case), "
-            "but only a single container data node is allowed.",
-            "Path \"/a:{extension='rc:yang-data'}/template\".");
+            "but only a single container data node is allowed.", "/a:{extension='rc:yang-data'}/template", 0);
 
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:yangdata:a; prefix self;"
             "import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
@@ -194,8 +192,7 @@
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
             "Extension rc:yang-data is instantiated with multiple top level data nodes, "
-            "but only a single container data node is allowed.",
-            "Path \"/a:{extension='rc:yang-data'}/template\".");
+            "but only a single container data node is allowed.", "/a:{extension='rc:yang-data'}/template", 0);
 
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:yangdata:a; prefix self;"
             "import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
@@ -203,15 +200,14 @@
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
             "Extension rc:yang-data is instantiated without any top level data node, "
-            "but exactly one container data node is expected.",
-            "Path \"/a:{extension='rc:yang-data'}/template\".");
+            "but exactly one container data node is expected.", "/a:{extension='rc:yang-data'}/template", 0);
 
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:yangdata:a; prefix self;"
             "import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
             "rc:yang-data { container x { leaf x {type string;}}}}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Extension instance \"rc:yang-data\" missing argument element \"name\".", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Extension instance \"rc:yang-data\" missing argument element \"name\".", NULL, 0);
 
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:yangdata:a; prefix self;"
             "import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
@@ -219,8 +215,7 @@
             "rc:yang-data template { container y { leaf y {type string;}}}}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
-            "Extension rc:yang-data is instantiated multiple times.",
-            "Path \"/a:{extension='rc:yang-data'}/template\".");
+            "Extension rc:yang-data is instantiated multiple times.", "/a:{extension='rc:yang-data'}/template", 0);
 
     data = "module a {yang-version 1.1; namespace urn:tests:extensions:yangdata:a; prefix self;"
             "import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
@@ -229,8 +224,7 @@
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
             "Extension rc:yang-data is instantiated with leaf-list top level data node, "
-            "but only a single container data node is allowed.",
-            "Path \"/a:{extension='rc:yang-data'}/template\".");
+            "but only a single container data node is allowed.", "/a:{extension='rc:yang-data'}/template", 0);
 }
 
 static void
diff --git a/tests/utests/node/list.c b/tests/utests/node/list.c
index 987b416..0f172d2 100644
--- a/tests/utests/node/list.c
+++ b/tests/utests/node/list.c
@@ -169,8 +169,8 @@
             "leaf group{type string;}"
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid value \"-1\" of \"max-elements\".", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid value \"-1\" of \"max-elements\".", NULL, 5);
 
     schema = MODULE_CREATE_YANG("TERR_0", "list user {"
             "key uid;"
@@ -181,8 +181,8 @@
             "leaf group{type string;}"
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
-    CHECK_LOG_CTX("Value \"4294967298\" is out of \"max-elements\" bounds.", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Value \"4294967298\" is out of \"max-elements\" bounds.", NULL, 5);
 
     schema = MODULE_CREATE_YANG("TERR_0", "list user {"
             "key uid;"
@@ -193,7 +193,7 @@
             "leaf group{type string;}"
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("List min-elements 20 is bigger than max-elements 10.", "Path \"/TERR_0:user\".");
+    CHECK_LOG_CTX("List min-elements 20 is bigger than max-elements 10.", "/TERR_0:user", 0);
 
     schema = MODULE_CREATE_YANG("TERR_0", "list user {"
             "key uid;"
@@ -204,8 +204,8 @@
             "leaf group{type string;}"
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid value \"-1\" of \"min-elements\".", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid value \"-1\" of \"min-elements\".", NULL, 5);
 
     schema = MODULE_CREATE_YANG("TERR_0", "list user {"
             "key uid;"
@@ -215,8 +215,8 @@
             "leaf group{type string;}"
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate keyword \"key\".", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate keyword \"key\".", NULL, 5);
 
     schema = MODULE_CREATE_YANG("T6", "list user {"
             "config false;"
@@ -282,8 +282,8 @@
             "leaf group{type string;}"
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid value \"systeme\" of \"ordered-by\".", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid value \"systeme\" of \"ordered-by\".", NULL, 5);
 
     schema = MODULE_CREATE_YANG("TERROR0", "list \"\" {"
             "key uid;"
@@ -294,8 +294,8 @@
             "leaf group{type string;}"
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL);
-    CHECK_LOG_CTX("Statement argument is required.", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Statement argument is required.", NULL, 5);
 
     schema = MODULE_CREATE_YANG("T9", "list user {"
             "key uid;"
@@ -389,7 +389,7 @@
             "   <leaf name=\"group\"><type name=\"string\"/></leaf>"
             "</list>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("The list's key \"u<id\" not found.", "Path \"/T00:user\".");
+    CHECK_LOG_CTX("The list's key \"u<id\" not found.", "/T00:user", 0);
 
     schema = MODULE_CREATE_YIN("T1", "<list name=\"user\"> "
             "   <key value=\"uid\"/>"
@@ -498,8 +498,8 @@
             "   <leaf name=\"uid\"> <type name=\"int32\"> </leaf>"
             "</list>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid value \"-1\" of \"value\" attribute in \"max-elements\" element.", "Line number 8.");
+    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid value \"-1\" of \"value\" attribute in \"max-elements\" element.", NULL, 8);
 
     schema = MODULE_CREATE_YIN("TERR_0",
             "<list name=\"user\">"
@@ -511,8 +511,8 @@
             "   <leaf name=\"group\"> <type name=\"string\"/>  </leaf>"
             "</list>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
-    CHECK_LOG_CTX("Value \"4294967298\" of \"value\" attribute in \"max-elements\" element is out of bounds.", "Line number 8.");
+    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Value \"4294967298\" of \"value\" attribute in \"max-elements\" element is out of bounds.", NULL, 8);
 
     schema = MODULE_CREATE_YIN("TERR_0",
             "<list name=\"user\">"
@@ -524,9 +524,9 @@
             "   <leaf name=\"group\"> <type name=\"string\"/> </leaf>"
             "</list>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
+    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL, 0);
     CHECK_LOG_CTX("Invalid combination of min-elements and max-elements: min value 20 is bigger than the max value 10.",
-            "Line number 8.");
+            NULL, 8);
 
     schema = MODULE_CREATE_YIN("TERR_0",
             "<list name=\"user\">"
@@ -538,8 +538,8 @@
             "   <leaf name=\"group\"> <type name=\"string\"/> </leaf>"
             "</list>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
-    CHECK_LOG_CTX("Value \"-1\" of \"value\" attribute in \"min-elements\" element is out of bounds.", "Line number 8.");
+    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Value \"-1\" of \"value\" attribute in \"min-elements\" element is out of bounds.", NULL, 8);
 
     schema = MODULE_CREATE_YIN("TERR_0",
             "<list name=\"user\">"
@@ -550,8 +550,8 @@
             "   <leaf name=\"group\"> <type name=\"string\"/> </leaf>"
             "</list>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
-    CHECK_LOG_CTX("Redefinition of \"key\" sub-element in \"list\" element.", "Line number 8.");
+    CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Redefinition of \"key\" sub-element in \"list\" element.", NULL, 8);
 
     schema = MODULE_CREATE_YIN("T6",
             "<list name=\"user\">"
@@ -621,9 +621,9 @@
             "   <leaf name=\"group\"><type name=\"string\"/> </leaf>"
             "</list>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL);
+    CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL, 0);
     CHECK_LOG_CTX("Invalid value \"systeme\" of \"value\" attribute in \"ordered-by\" element. Valid values are \"system\" and \"user\".",
-            "Line number 8.");
+            NULL, 8);
 
     schema = MODULE_CREATE_YIN("T_DEFS1",
             "<list name=\"user\">"
@@ -852,8 +852,7 @@
     /* check first item */
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
-    CHECK_LOG_CTX("Duplicate instance of \"user\".",
-            "Data location \"/T0:user[uid='0']\".");
+    CHECK_LOG_CTX("Duplicate instance of \"user\".", "/T0:user[uid='0']", 0);
 
     data =
             "<user xmlns=\"urn:tests:T0\">"
@@ -870,7 +869,7 @@
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
     CHECK_LOG_CTX("Unique data leaf(s) \"name group\" not satisfied in \"/T0:user[uid='0']\" and \"/T0:user[uid='1']\".",
-            "Data location \"/T0:user[uid='1']\".");
+            "/T0:user[uid='1']", 0);
 
     /* double key */
     schema = MODULE_CREATE_YANG("T1", "list user {"
@@ -932,8 +931,7 @@
     /* check first item */
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
-    CHECK_LOG_CTX("Duplicate instance of \"user\".",
-            "Data location \"/T1:user[uid='0'][group='User']\".");
+    CHECK_LOG_CTX("Duplicate instance of \"user\".", "/T1:user[uid='0'][group='User']", 0);
 
     /* min elements max elements */
     schema = MODULE_CREATE_YANG("T2",
@@ -1053,8 +1051,7 @@
             "</user>";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
-    CHECK_LOG_CTX("Too few \"user\" instances.",
-            "Schema location \"/T2:user\".");
+    CHECK_LOG_CTX("Too few \"user\" instances.", "/T2:user", 0);
 
     data =
             "<user xmlns=\"urn:tests:T2\">"
@@ -1089,8 +1086,7 @@
             "</user>";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
-    CHECK_LOG_CTX("Too many \"user\" instances.",
-            "Data location \"/T2:user[uid='5']\".");
+    CHECK_LOG_CTX("Too many \"user\" instances.", "/T2:user[uid='5']", 0);
 
     /* empty list */
     schema = MODULE_CREATE_YANG("T_EMPTY_LIST",
@@ -1205,8 +1201,7 @@
             "]}";
     CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
-    CHECK_LOG_CTX("Duplicate instance of \"user\".",
-            "Data location \"/T0:user[uid='0']\".");
+    CHECK_LOG_CTX("Duplicate instance of \"user\".", "/T0:user[uid='0']", 0);
 
     data =
             "{\"T0:user\": ["
@@ -1216,7 +1211,7 @@
     CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
     CHECK_LOG_CTX("Unique data leaf(s) \"name group\" not satisfied in \"/T0:user[uid='0']\" and \"/T0:user[uid='1']\".",
-            "Data location \"/T0:user[uid='1']\".");
+            "/T0:user[uid='1']", 0);
 
     /* double key */
     schema = MODULE_CREATE_YANG("T1", "list user {"
@@ -1265,8 +1260,7 @@
     /* check first item */
     CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
-    CHECK_LOG_CTX("Duplicate instance of \"user\".",
-            "Data location \"/T1:user[uid='0'][group='User']\".");
+    CHECK_LOG_CTX("Duplicate instance of \"user\".", "/T1:user[uid='0'][group='User']", 0);
 
     /* min elements max elements */
     schema = MODULE_CREATE_YANG("T2",
@@ -1353,8 +1347,7 @@
             "]}";
     CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
-    CHECK_LOG_CTX("Too few \"user\" instances.",
-            "Schema location \"/T2:user\".");
+    CHECK_LOG_CTX("Too few \"user\" instances.", "/T2:user", 0);
 
     data =
             "{\"T2:user\": ["
@@ -1367,8 +1360,7 @@
             "]}";
     CHECK_PARSE_LYD_PARAM(data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
     assert_null(tree);
-    CHECK_LOG_CTX("Too many \"user\" instances.",
-            "Data location \"/T2:user[uid='5']\".");
+    CHECK_LOG_CTX("Too many \"user\" instances.", "/T2:user[uid='5']", 0);
 
     schema = MODULE_CREATE_YANG("T_EMPTY_LIST",
             "container user_list {"
diff --git a/tests/utests/restriction/test_pattern.c b/tests/utests/restriction/test_pattern.c
index 94539d6..56c1499 100644
--- a/tests/utests/restriction/test_pattern.c
+++ b/tests/utests/restriction/test_pattern.c
@@ -375,12 +375,9 @@
     TEST_SUCCESS_XML("TPATTERN_0", "AHOJ", STRING, "AHOJ");
     /* test print error */
     TEST_ERROR_XML("TPATTERN_0", "T128");
-    CHECK_LOG_CTX("pattern 0 error message",
-            "Schema location \"/TPATTERN_0:port\", line number 1.");
+    CHECK_LOG_CTX("pattern 0 error message", "/TPATTERN_0:port", 1);
     TEST_ERROR_XML("TPATTERN_0", "ahoj");
-    CHECK_LOG_CTX("pattern 1 error message",
-            "Schema location \"/TPATTERN_0:port\", line number 1.");
-
+    CHECK_LOG_CTX("pattern 1 error message", "/TPATTERN_0:port", 1);
 }
 
 int
diff --git a/tests/utests/restriction/test_range.c b/tests/utests/restriction/test_range.c
index f202b6c..13cccfa 100644
--- a/tests/utests/restriction/test_range.c
+++ b/tests/utests/restriction/test_range.c
@@ -385,14 +385,11 @@
     TEST_SUCCESS_XML("TRANGE_0", "126", INT8, "126", 126);
     /* test print error */
     TEST_ERROR_XML("TRANGE_0", "-1");
-    CHECK_LOG_CTX("error message",
-            "Schema location \"/TRANGE_0:port\", line number 1.");
+    CHECK_LOG_CTX("error message", "/TRANGE_0:port", 1);
     TEST_ERROR_XML("TRANGE_0", "51");
-    CHECK_LOG_CTX("error message",
-            "Schema location \"/TRANGE_0:port\", line number 1.");
+    CHECK_LOG_CTX("error message", "/TRANGE_0:port", 1);
     TEST_ERROR_XML("TRANGE_0", "127");
-    CHECK_LOG_CTX("error message",
-            "Schema location \"/TRANGE_0:port\", line number 1.");
+    CHECK_LOG_CTX("error message", "/TRANGE_0:port", 1);
 
     /* xml test */
     schema = MODULE_CREATE_YANG("TRANGE_1", "leaf port {type uint8 {"
@@ -406,15 +403,11 @@
     TEST_SUCCESS_XML("TRANGE_1", "126", UINT8, "126", 126);
     /* test print error */
     TEST_ERROR_XML("TRANGE_1", "0");
-    CHECK_LOG_CTX("error message",
-            "Schema location \"/TRANGE_1:port\", line number 1.");
+    CHECK_LOG_CTX("error message", "/TRANGE_1:port", 1);
     TEST_ERROR_XML("TRANGE_1", "51");
-    CHECK_LOG_CTX("error message",
-            "Schema location \"/TRANGE_1:port\", line number 1.");
+    CHECK_LOG_CTX("error message", "/TRANGE_1:port", 1);
     TEST_ERROR_XML("TRANGE_1", "127");
-    CHECK_LOG_CTX("error message",
-            "Schema location \"/TRANGE_1:port\", line number 1.");
-
+    CHECK_LOG_CTX("error message", "/TRANGE_1:port", 1);
 }
 
 int
diff --git a/tests/utests/schema/test_schema.c b/tests/utests/schema/test_schema.c
index 17c4e4f..e59fa65 100644
--- a/tests/utests/schema/test_schema.c
+++ b/tests/utests/schema/test_schema.c
@@ -83,29 +83,29 @@
     const char *test_str__; \
     TEST_SCHEMA_STR(RFC7950, YIN, MOD_NAME, CONTENT, test_str__) \
     assert_int_not_equal(lys_parse_mem(UTEST_LYCTX, test_str__, YIN ? LYS_IN_YIN : LYS_IN_YANG, NULL), LY_SUCCESS); \
-    CHECK_LOG_CTX(ERRMSG, ERRPATH); \
+    CHECK_LOG_CTX(ERRMSG, ERRPATH, 0); \
     }
 
-#define TEST_SCHEMA_PARSE_ERR(RFC7950, YIN, MOD_NAME, CONTENT, ERRMSG, ERRPATH) \
+#define TEST_SCHEMA_PARSE_ERR(RFC7950, YIN, MOD_NAME, CONTENT, ERRMSG, ERRPATH, ERRLINE) \
     { \
     const char *test_str__; \
     TEST_SCHEMA_STR(RFC7950, YIN, MOD_NAME, CONTENT, test_str__) \
     assert_int_not_equal(lys_parse_mem(UTEST_LYCTX, test_str__, YIN ? LYS_IN_YIN : LYS_IN_YANG, NULL), LY_SUCCESS); \
-    CHECK_LOG_CTX("Parsing module \""MOD_NAME"\" failed.", NULL); \
-    CHECK_LOG_CTX(ERRMSG, ERRPATH); \
+    CHECK_LOG_CTX("Parsing module \""MOD_NAME"\" failed.", NULL, 0); \
+    CHECK_LOG_CTX(ERRMSG, ERRPATH, ERRLINE); \
     }
 
 #define TEST_STMT_DUP(RFC7950, YIN, STMT, MEMBER, VALUE1, VALUE2, LINE) \
     if (YIN) { \
-        TEST_SCHEMA_PARSE_ERR(RFC7950, YIN, "dup", "", "Duplicate keyword \""MEMBER"\".", "Line number "LINE"."); \
+        TEST_SCHEMA_PARSE_ERR(RFC7950, YIN, "dup", "", "Duplicate keyword \""MEMBER"\".", NULL, LINE); \
     } else { \
         TEST_SCHEMA_PARSE_ERR(RFC7950, YIN, "dup", STMT"{"MEMBER" "VALUE1";"MEMBER" "VALUE2";}", \
-                        "Duplicate keyword \""MEMBER"\".", "Line number "LINE"."); \
+                        "Duplicate keyword \""MEMBER"\".", NULL, LINE); \
     }
 
 #define TEST_STMT_SUBSTM_ERR(RFC7950, STMT, SUBSTMT, VALUE) ;\
         TEST_SCHEMA_PARSE_ERR(RFC7950, 0, "inv", STMT" test {"SUBSTMT" "VALUE";}", \
-                        "Invalid keyword \""SUBSTMT"\" as a child of \""STMT"\".", "Line number 1.");
+                        "Invalid keyword \""SUBSTMT"\" as a child of \""STMT"\".", NULL, 1);
 
 struct module_clb_list {
     const char *name;
@@ -242,26 +242,26 @@
 }
 
 static void
-test_date(void **state)
+test_date(void **UNUSED(state))
 {
     assert_int_equal(LY_EINVAL, lysp_check_date(NULL, NULL, 0, "date"));
-    CHECK_LOG("Invalid argument date (lysp_check_date()).", NULL);
+    CHECK_LOG_LASTMSG("Invalid argument date (lysp_check_date()).");
     assert_int_equal(LY_EINVAL, lysp_check_date(NULL, "x", 1, "date"));
-    CHECK_LOG("Invalid length 1 of a date.", NULL);
+    CHECK_LOG_LASTMSG("Invalid length 1 of a date.");
     assert_int_equal(LY_EINVAL, lysp_check_date(NULL, "nonsencexx", 10, "date"));
-    CHECK_LOG("Invalid value \"nonsencexx\" of \"date\".", NULL);
+    CHECK_LOG_LASTMSG("Invalid value \"nonsencexx\" of \"date\".");
     assert_int_equal(LY_EINVAL, lysp_check_date(NULL, "123x-11-11", 10, "date"));
-    CHECK_LOG("Invalid value \"123x-11-11\" of \"date\".", NULL);
+    CHECK_LOG_LASTMSG("Invalid value \"123x-11-11\" of \"date\".");
     assert_int_equal(LY_EINVAL, lysp_check_date(NULL, "2018-13-11", 10, "date"));
-    CHECK_LOG("Invalid value \"2018-13-11\" of \"date\".", NULL);
+    CHECK_LOG_LASTMSG("Invalid value \"2018-13-11\" of \"date\".");
     assert_int_equal(LY_EINVAL, lysp_check_date(NULL, "2018-11-41", 10, "date"));
-    CHECK_LOG("Invalid value \"2018-11-41\" of \"date\".", NULL);
+    CHECK_LOG_LASTMSG("Invalid value \"2018-11-41\" of \"date\".");
     assert_int_equal(LY_EINVAL, lysp_check_date(NULL, "2018-02-29", 10, "date"));
-    CHECK_LOG("Invalid value \"2018-02-29\" of \"date\".", NULL);
+    CHECK_LOG_LASTMSG("Invalid value \"2018-02-29\" of \"date\".");
     assert_int_equal(LY_EINVAL, lysp_check_date(NULL, "2018.02-28", 10, "date"));
-    CHECK_LOG("Invalid value \"2018.02-28\" of \"date\".", NULL);
+    CHECK_LOG_LASTMSG("Invalid value \"2018.02-28\" of \"date\".");
     assert_int_equal(LY_EINVAL, lysp_check_date(NULL, "2018-02.28", 10, "date"));
-    CHECK_LOG("Invalid value \"2018-02.28\" of \"date\".", NULL);
+    CHECK_LOG_LASTMSG("Invalid value \"2018-02.28\" of \"date\".");
 
     assert_int_equal(LY_SUCCESS, lysp_check_date(NULL, "2018-11-11", 10, "date"));
     assert_int_equal(LY_SUCCESS, lysp_check_date(NULL, "2018-02-28", 10, "date"));
@@ -269,14 +269,10 @@
 }
 
 static void
-test_revisions(void **state)
+test_revisions(void **UNUSED(state))
 {
     struct lysp_revision *revs = NULL, *rev;
 
-    /* no error, it just does nothing */
-    lysp_sort_revisions(NULL);
-    CHECK_LOG(NULL, NULL);
-
     /* revisions are stored in wrong order - the newest is the last */
     LY_ARRAY_NEW_RET(NULL, revs, rev, );
     strcpy(rev->date, "2018-01-01");
@@ -307,80 +303,80 @@
     /* collision with a built-in type */
     str = "module a {namespace urn:a; prefix a; typedef binary {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"binary\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"binary\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef bits {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"bits\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"bits\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef boolean {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"boolean\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"boolean\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef decimal64 {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"decimal64\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"decimal64\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef empty {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"empty\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"empty\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef enumeration {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"enumeration\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"enumeration\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef int8 {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"int8\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"int8\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef int16 {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"int16\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"int16\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef int32 {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"int32\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"int32\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef int64 {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"int64\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"int64\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef instance-identifier {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"instance-identifier\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"instance-identifier\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef identityref {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"identityref\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"identityref\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef leafref {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"leafref\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"leafref\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef string {type int8;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"string\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"string\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef union {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"union\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"union\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef uint8 {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"uint8\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"uint8\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef uint16 {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"uint16\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"uint16\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef uint32 {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"uint32\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"uint32\" of typedef statement - name collision with a built-in type.", NULL, 0);
     str = "module a {namespace urn:a; prefix a; typedef uint64 {type string;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"uint64\" of typedef statement - name collision with a built-in type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"uint64\" of typedef statement - name collision with a built-in type.", NULL, 0);
 
     str = "module mytypes {namespace urn:types; prefix t; typedef binary_ {type string;} typedef bits_ {type string;} typedef boolean_ {type string;} "
             "typedef decimal64_ {type string;} typedef empty_ {type string;} typedef enumeration_ {type string;} typedef int8_ {type string;} typedef int16_ {type string;}"
@@ -392,34 +388,34 @@
     /* collision in node's scope */
     str = "module a {namespace urn:a; prefix a; container c {typedef y {type int8;} typedef y {type string;}}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"y\" of typedef statement - name collision with sibling type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"y\" of typedef statement - name collision with sibling type.", NULL, 0);
 
     /* collision with parent node */
     str = "module a {namespace urn:a; prefix a; container c {container d {typedef y {type int8;}} typedef y {type string;}}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"y\" of typedef statement - name collision with another scoped type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"y\" of typedef statement - name collision with another scoped type.", NULL, 0);
 
     /* collision with module's top-level */
     str = "module a {namespace urn:a; prefix a; typedef x {type string;} container c {typedef x {type int8;}}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL, 0);
 
     /* collision of submodule's node with module's top-level */
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} container c {typedef x {type string;}}}");
     str = "module a {namespace urn:a; prefix a; include b; typedef x {type int8;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL, 0);
 
     /* collision of module's node with submodule's top-level */
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} typedef x {type int8;}}");
     str = "module a {namespace urn:a; prefix a; include b; container c {typedef x {type string;}}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL, 0);
 
     /* collision of submodule's node with another submodule's top-level */
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -427,29 +423,29 @@
     list[1].data = "submodule bsub {belongs-to a {prefix a;} container c {typedef g {type int;}}}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of typedef statement - scoped type collide with a top-level type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of typedef statement - scoped type collide with a top-level type.", NULL, 0);
 
     /* collision of module's top-levels */
     str = "module a {namespace urn:a; prefix a; typedef test {type string;} typedef test {type int8;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"test\" of typedef statement - name collision with another top-level type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"test\" of typedef statement - name collision with another top-level type.", NULL, 0);
 
     /* collision of submodule's top-levels */
     submod = "submodule asub {belongs-to a {prefix a;} typedef g {type int;} typedef g {type int;}}";
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub;}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of typedef statement - name collision with another top-level type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of typedef statement - name collision with another top-level type.", NULL, 0);
 
     /* collision of module's top-level with submodule's top-levels */
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} typedef x {type string;}}");
     str = "module a {namespace urn:a; prefix a; include b; typedef x {type int8;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - name collision with another top-level type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - name collision with another top-level type.", NULL, 0);
 
     /* collision of submodule's top-level with another submodule's top-levels */
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -457,14 +453,14 @@
     list[1].data = "submodule bsub {belongs-to a {prefix a;} typedef g {type int;}}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of typedef statement - name collision with another top-level type.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of typedef statement - name collision with another top-level type.", NULL, 0);
 
     /* error in type-stmt */
     str = "module a {namespace urn:a; prefix a; container c {typedef x {type t{}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Unexpected end-of-input.", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Unexpected end-of-input.", NULL, 1);
 
     /* no collision if the same names are in different scope */
     str = "module a {yang-version 1.1; namespace urn:a; prefix a;"
@@ -485,34 +481,34 @@
     /* collision in node's scope */
     str = "module a {namespace urn:a; prefix a; container c {grouping y; grouping y;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"y\" of grouping statement - name collision with sibling grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"y\" of grouping statement - name collision with sibling grouping.", NULL, 0);
 
     /* collision with parent node */
     str = "module a {namespace urn:a; prefix a; container c {container d {grouping y;} grouping y;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"y\" of grouping statement - name collision with another scoped grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"y\" of grouping statement - name collision with another scoped grouping.", NULL, 0);
 
     /* collision with module's top-level */
     str = "module a {namespace urn:a; prefix a; grouping x; container c {grouping x;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL, 0);
 
     /* collision of submodule's node with module's top-level */
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} container c {grouping x;}}");
     str = "module a {namespace urn:a; prefix a; include b; grouping x;}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL, 0);
 
     /* collision of module's node with submodule's top-level */
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} grouping x;}");
     str = "module a {namespace urn:a; prefix a; include b; container c {grouping x;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL, 0);
 
     /* collision of submodule's node with another submodule's top-level */
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -520,29 +516,29 @@
     list[1].data = "submodule bsub {belongs-to a {prefix a;} container c {grouping g;}}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL, 0);
 
     /* collision of module's top-levels */
     str = "module a {namespace urn:a; prefix a; grouping test; grouping test;}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"test\" of grouping statement - name collision with another top-level grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"test\" of grouping statement - name collision with another top-level grouping.", NULL, 0);
 
     /* collision of submodule's top-levels */
     submod = "submodule asub {belongs-to a {prefix a;} grouping g; grouping g;}";
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub;}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - name collision with another top-level grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - name collision with another top-level grouping.", NULL, 0);
 
     /* collision of module's top-level with submodule's top-levels */
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} grouping x;}");
     str = "module a {namespace urn:a; prefix a; include b; grouping x;}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - name collision with another top-level grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - name collision with another top-level grouping.", NULL, 0);
 
     /* collision of submodule's top-level with another submodule's top-levels */
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -550,27 +546,27 @@
     list[1].data = "submodule bsub {belongs-to a {prefix a;} grouping g;}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - name collision with another top-level grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - name collision with another top-level grouping.", NULL, 0);
 
     /* collision in nested groupings, top-level */
     str = "module a {namespace urn:a; prefix a; grouping g {grouping g;}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL, 0);
 
     /* collision in nested groupings, in node */
     str = "module a {namespace urn:a; prefix a; container c {grouping g {grouping g;}}}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - name collision with another scoped grouping.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - name collision with another scoped grouping.", NULL, 0);
 
     /* no collision if the same names are in different scope */
     str = "module a {yang-version 1.1; namespace urn:a; prefix a;"
             "container c {grouping g;} container d {grouping g;}}";
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Locally scoped grouping \"g\" not used.", NULL);
-    CHECK_LOG_CTX("Locally scoped grouping \"g\" not used.", NULL);
+    CHECK_LOG_CTX("Locally scoped grouping \"g\" not used.", NULL, 0);
+    CHECK_LOG_CTX("Locally scoped grouping \"g\" not used.", NULL, 0);
 }
 
 static void
@@ -586,24 +582,24 @@
     /* collision of module's top-levels */
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; identity g; identity g;}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL, 0);
 
     /* collision of submodule's top-levels */
     submod = "submodule asub {belongs-to a {prefix a;} identity g; identity g;}";
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub;}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL, 0);
 
     /* collision of module's top-level with submodule's top-levels */
     submod = "submodule asub {belongs-to a {prefix a;} identity g;}";
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; identity g;}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL, 0);
 
     /* collision of submodule's top-level with another submodule's top-levels */
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -611,8 +607,8 @@
     list[1].data = "submodule bsub {belongs-to a {prefix a;} identity g;}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL, 0);
 }
 
 static void
@@ -628,24 +624,24 @@
     /* collision of module's top-levels */
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; feature g; feature g;}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL, 0);
 
     /* collision of submodule's top-levels */
     submod = "submodule asub {belongs-to a {prefix a;} feature g; feature g;}";
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub;}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL, 0);
 
     /* collision of module's top-level with submodule's top-levels */
     submod = "submodule asub {belongs-to a {prefix a;} feature g;}";
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; feature g;}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL, 0);
 
     /* collision of submodule's top-level with another submodule's top-levels */
     str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -653,8 +649,8 @@
     list[1].data = "submodule bsub {belongs-to a {prefix a;} feature g;}";
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
+    CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL, 0);
 }
 
 static void
@@ -681,7 +677,7 @@
             "    }\n"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_SUCCESS);
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
 
     /* config -> state leafref */
     str = "module b {\n"
@@ -703,7 +699,7 @@
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
     CHECK_LOG_CTX("Invalid leafref path \"/cont/l\" - target is supposed to represent configuration data"
-            " (as the leafref does), but it does not.", "Schema location \"/b:cont2/l2\".");
+            " (as the leafref does), but it does not.", "/b:cont2/l2", 0);
 
     /* config -> state must */
     str = "module b {\n"
@@ -724,7 +720,7 @@
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_SUCCESS);
     CHECK_LOG_CTX("Schema node \"cont\" for parent \"<config-root>\" not found; in expr \"../../cont\" "
-            "with context node \"/b:cont2/l2\".", NULL);
+            "with context node \"/b:cont2/l2\".", NULL, 0);
 
     /* state -> config */
     str = "module c {\n"
@@ -746,7 +742,7 @@
             "    }\n"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_SUCCESS);
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
 
     /* notif -> state */
     str = "module d {\n"
@@ -768,7 +764,7 @@
             "    }\n"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_SUCCESS);
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
 
     /* notif -> notif */
     str = "module e {\n"
@@ -787,7 +783,7 @@
             "    }\n"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_SUCCESS);
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
 
     /* rpc input -> state */
     str = "module f {\n"
@@ -811,7 +807,7 @@
             "    }\n"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_SUCCESS);
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
 
     /* rpc input -> rpc input */
     str = "module g {\n"
@@ -832,7 +828,7 @@
             "    }\n"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_SUCCESS);
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
 
     /* rpc input -> rpc output leafref */
     str = "module h {\n"
@@ -854,7 +850,7 @@
             "    }\n"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Not found node \"l\" in path.", "Schema location \"/h:rp/input/l2\".");
+    CHECK_LOG_CTX("Not found node \"l\" in path.", "/h:rp/input/l2", 0);
 
     /* rpc input -> rpc output must */
     str = "module h {\n"
@@ -875,7 +871,8 @@
             "    }\n"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_SUCCESS);
-    CHECK_LOG_CTX("Schema node \"l\" for parent \"/h:rp\" not found; in expr \"../l\" with context node \"/h:rp/input/l2\".", NULL);
+    CHECK_LOG_CTX("Schema node \"l\" for parent \"/h:rp\" not found; in expr \"../l\" with context node \"/h:rp/input/l2\".",
+            NULL, 0);
 
     /* rpc input -> notif leafref */
     str = "module i {\n"
@@ -897,7 +894,7 @@
             "    }\n"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Not found node \"notif\" in path.", "Schema location \"/i:rp/input/l2\".");
+    CHECK_LOG_CTX("Not found node \"notif\" in path.", "/i:rp/input/l2", 0);
 
     /* rpc input -> notif must */
     str = "module i {\n"
@@ -919,7 +916,7 @@
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_SUCCESS);
     CHECK_LOG_CTX("Schema node \"notif\" for parent \"<root>\" not found; in expr \"/notif\" "
-            "with context node \"/i:rp/input/l2\".", NULL);
+            "with context node \"/i:rp/input/l2\".", NULL, 0);
 
     /* action output -> state */
     str = "module j {\n"
@@ -950,7 +947,7 @@
             "    }\n"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_SUCCESS);
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
 
     /* action output -> action input leafref */
     str = "module k {\n"
@@ -981,7 +978,7 @@
             "    }\n"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Not found node \"l\" in path.", "Schema location \"/k:cont/ll/act/output/l2\".");
+    CHECK_LOG_CTX("Not found node \"l\" in path.", "/k:cont/ll/act/output/l2", 0);
 
     /* action output -> action input must */
     str = "module k {\n"
@@ -1012,7 +1009,7 @@
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_SUCCESS);
     CHECK_LOG_CTX("Schema node \"l\" for parent \"/k:cont/ll/act\" not found; in expr \"/cont/ll/act/l\" "
-            "with context node \"/k:cont/ll/act/output/l2\".", NULL);
+            "with context node \"/k:cont/ll/act/output/l2\".", NULL, 0);
 }
 
 static void
@@ -1048,15 +1045,16 @@
         ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
         mod = ly_ctx_load_module(UTEST_LYCTX, "main_b", NULL, NULL);
         assert_null(mod);
-        CHECK_LOG_CTX("Loading \"main_b\" module failed.", NULL);
-        CHECK_LOG_CTX("Data model \"main_b\" not found in local searchdirs.", NULL);
-        CHECK_LOG_CTX("Parsing module \"main_b\" failed.", NULL);
-        CHECK_LOG_CTX("Including \"sub_b_one\" submodule into \"main_b\" failed.", NULL);
-        CHECK_LOG_CTX("Data model \"sub_b_one\" not found in local searchdirs.", NULL);
-        CHECK_LOG_CTX("Parsing submodule \"sub_b_one\" failed.", NULL);
+        CHECK_LOG_CTX("Loading \"main_b\" module failed.", NULL, 0);
+        CHECK_LOG_CTX("Data model \"main_b\" not found in local searchdirs.", NULL, 0);
+        CHECK_LOG_CTX("Parsing module \"main_b\" failed.", NULL, 0);
+        CHECK_LOG_CTX("Including \"sub_b_one\" submodule into \"main_b\" failed.", NULL, 0);
+        CHECK_LOG_CTX("Data model \"sub_b_one\" not found in local searchdirs.", NULL, 0);
+        CHECK_LOG_CTX("Parsing submodule \"sub_b_one\" failed.", NULL, 0);
         CHECK_LOG_CTX("YANG 1.1 requires all submodules to be included from main module. But submodule \"sub_b_one\" includes "
-                "submodule \"sub_b_two\" which is not included by main module \"main_b\".", NULL);
-        CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (sub_b_one) are not necessary.", NULL);
+                "submodule \"sub_b_two\" which is not included by main module \"main_b\".", NULL, 0);
+        CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (sub_b_one) are not necessary.",
+                NULL, 0);
     }
 
     {
@@ -1074,8 +1072,10 @@
         assert_int_equal(2, LY_ARRAY_COUNT(mod->parsed->includes));
         assert_false(mod->parsed->includes[1].injected);
         /* result is ok, but log includes the warning */
-        CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (sub_c_two) are not necessary.", NULL);
-        CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (sub_c_one) are not necessary.", NULL);
+        CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (sub_c_two) are not necessary.",
+                NULL, 0);
+        CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (sub_c_one) are not necessary.",
+                NULL, 0);
     }
 }
 
@@ -1163,7 +1163,7 @@
             "}}"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Node \"l\" without any (or all disabled) valid values.", "Schema location \"/a:l\".");
+    CHECK_LOG_CTX("Node \"l\" without any (or all disabled) valid values.", "/a:l", 0);
 
     /* disabled default value */
     str = "module a {"
@@ -1180,8 +1180,7 @@
             "}"
             "}";
     assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid default - value does not fit the type (Invalid enumeration value \"e1\".).",
-            "Schema location \"/a:l\".");
+    CHECK_LOG_CTX("Invalid default - value does not fit the type (Invalid enumeration value \"e1\".).", "/a:l", 0);
 }
 
 static void
@@ -1192,9 +1191,9 @@
     /*
      * parsing YANG
      */
-    TEST_STMT_DUP(1, 0, "identity id", "description", "a", "b", "1");
-    TEST_STMT_DUP(1, 0, "identity id", "reference", "a", "b", "1");
-    TEST_STMT_DUP(1, 0, "identity id", "status", "current", "obsolete", "1");
+    TEST_STMT_DUP(1, 0, "identity id", "description", "a", "b", 1);
+    TEST_STMT_DUP(1, 0, "identity id", "reference", "a", "b", 1);
+    TEST_STMT_DUP(1, 0, "identity id", "status", "current", "obsolete", 1);
 
     /* full content */
     TEST_SCHEMA_OK(1, 0, "identityone",
@@ -1239,7 +1238,7 @@
     /* invalid substatement */
     TEST_SCHEMA_PARSE_ERR(0, 1, "inv", "<identity name=\"ident-name\"><if-feature name=\"iff\"/></identity>",
             "Invalid sub-elemnt \"if-feature\" of \"identity\" element - "
-            "this sub-element is allowed only in modules with version 1.1 or newer.", "Line number 1.");
+            "this sub-element is allowed only in modules with version 1.1 or newer.", NULL, 1);
 
     /*
      * compiling
@@ -1270,10 +1269,10 @@
     assert_ptr_equal(mod->identities[1].derived[0], &mod->identities[0]);
 
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule inv_sub {belongs-to inv {prefix inv;} identity i1;}");
-    TEST_SCHEMA_ERR(0, 0, "inv", "identity i1 {base i2;}", "Unable to find base (i2) of identity \"i1\".", "Path \"/inv:{identity='i1'}\".");
-    TEST_SCHEMA_ERR(0, 0, "inv", "identity i1 {base i1;}", "Identity \"i1\" is derived from itself.", "Path \"/inv:{identity='i1'}\".");
+    TEST_SCHEMA_ERR(0, 0, "inv", "identity i1 {base i2;}", "Unable to find base (i2) of identity \"i1\".", "/inv:{identity='i1'}");
+    TEST_SCHEMA_ERR(0, 0, "inv", "identity i1 {base i1;}", "Identity \"i1\" is derived from itself.", "/inv:{identity='i1'}");
     TEST_SCHEMA_ERR(0, 0, "inv", "identity i1 {base i2;}identity i2 {base i3;}identity i3 {base i1;}",
-            "Identity \"i1\" is indirectly derived from itself.", "Path \"/inv:{identity='i3'}\".");
+            "Identity \"i1\" is indirectly derived from itself.", "/inv:{identity='i3'}");
 
     /* base in non-implemented module */
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb,
@@ -1283,12 +1282,12 @@
     /* default value from non-implemented module */
     TEST_SCHEMA_ERR(0, 0, "ident2", "import base {prefix b;} leaf l {type identityref {base b:i1;} default b:i2;}",
             "Invalid default - value does not fit the type (Invalid identityref \"b:i2\" value"
-            " - identity found in non-implemented module \"base\".).", "Schema location \"/ident2:l\".");
+            " - identity found in non-implemented module \"base\".).", "/ident2:l");
 
     /* default value in typedef from non-implemented module */
     TEST_SCHEMA_ERR(0, 0, "ident2", "import base {prefix b;} typedef t1 {type identityref {base b:i1;} default b:i2;}"
             "leaf l {type t1;}", "Invalid default - value does not fit the type (Invalid"
-            " identityref \"b:i2\" value - identity found in non-implemented module \"base\".).", "Schema location \"/ident2:l\".");
+            " identityref \"b:i2\" value - identity found in non-implemented module \"base\".).", "/ident2:l");
 
     /*
      * printing
@@ -1309,9 +1308,9 @@
      * parsing YANG
      */
 
-    TEST_STMT_DUP(1, 0, "feature f", "description", "a", "b", "1");
-    TEST_STMT_DUP(1, 0, "feature f", "reference", "a", "b", "1");
-    TEST_STMT_DUP(1, 0, "feature f", "status", "current", "obsolete", "1");
+    TEST_STMT_DUP(1, 0, "feature f", "description", "a", "b", 1);
+    TEST_STMT_DUP(1, 0, "feature f", "reference", "a", "b", 1);
+    TEST_STMT_DUP(1, 0, "feature f", "status", "current", "obsolete", 1);
 
     /* full content */
     TEST_SCHEMA_OK(1, 0, "featureone",
@@ -1351,7 +1350,7 @@
 
     /* invalid substatement */
     TEST_SCHEMA_PARSE_ERR(0, 1, "inv", "<feature name=\"feature-name\"><organization><text>org</text></organization></feature>",
-            "Unexpected sub-element \"organization\" of \"feature\" element.", "Line number 1.");
+            "Unexpected sub-element \"organization\" of \"feature\" element.", NULL, 1);
 
     /*
      * compiling
@@ -1374,37 +1373,37 @@
 
     /* some invalid expressions */
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f{if-feature f1;}",
-            "Invalid value \"f1\" of if-feature - unable to find feature \"f1\".", NULL);
+            "Invalid value \"f1\" of if-feature - unable to find feature \"f1\".", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f1; feature f2{if-feature 'f and';}",
-            "Invalid value \"f and\" of if-feature - unexpected end of expression.", NULL);
+            "Invalid value \"f and\" of if-feature - unexpected end of expression.", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f{if-feature 'or';}",
-            "Invalid value \"or\" of if-feature - unexpected end of expression.", NULL);
+            "Invalid value \"or\" of if-feature - unexpected end of expression.", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f1; feature f2{if-feature '(f1';}",
-            "Invalid value \"(f1\" of if-feature - non-matching opening and closing parentheses.", NULL);
+            "Invalid value \"(f1\" of if-feature - non-matching opening and closing parentheses.", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f1; feature f2{if-feature 'f1)';}",
-            "Invalid value \"f1)\" of if-feature - non-matching opening and closing parentheses.", NULL);
+            "Invalid value \"f1)\" of if-feature - non-matching opening and closing parentheses.", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f1; feature f2{if-feature ---;}",
-            "Invalid value \"---\" of if-feature - unable to find feature \"---\".", NULL);
+            "Invalid value \"---\" of if-feature - unable to find feature \"---\".", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(0, 0, "inv", "feature f1; feature f2{if-feature 'not f1';}",
-            "Invalid value \"not f1\" of if-feature - YANG 1.1 expression in YANG 1.0 module.", NULL);
+            "Invalid value \"not f1\" of if-feature - YANG 1.1 expression in YANG 1.0 module.", NULL, 0);
 
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule inv_sub {belongs-to inv {prefix inv;} feature f1;}");
     TEST_SCHEMA_PARSE_ERR(0, 0, "inv", "feature f1 {if-feature f2;} feature f2 {if-feature f1;}",
-            "Feature \"f1\" is indirectly referenced from itself.", NULL);
+            "Feature \"f1\" is indirectly referenced from itself.", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(0, 0, "inv", "feature f1 {if-feature f1;}",
-            "Feature \"f1\" is referenced from itself.", NULL);
+            "Feature \"f1\" is referenced from itself.", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f {if-feature ();}",
-            "Invalid value \"()\" of if-feature - number of features in expression does not match the required number of operands for the operations.", NULL);
+            "Invalid value \"()\" of if-feature - number of features in expression does not match the required number of operands for the operations.", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f1; feature f {if-feature 'f1(';}",
-            "Invalid value \"f1(\" of if-feature - non-matching opening and closing parentheses.", NULL);
+            "Invalid value \"f1(\" of if-feature - non-matching opening and closing parentheses.", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f1; feature f {if-feature 'and f1';}",
-            "Invalid value \"and f1\" of if-feature - missing feature/expression before \"and\" operation.", NULL);
+            "Invalid value \"and f1\" of if-feature - missing feature/expression before \"and\" operation.", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f1; feature f {if-feature 'f1 not ';}",
-            "Invalid value \"f1 not \" of if-feature - unexpected end of expression.", NULL);
+            "Invalid value \"f1 not \" of if-feature - unexpected end of expression.", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f1; feature f {if-feature 'f1 not not ';}",
-            "Invalid value \"f1 not not \" of if-feature - unexpected end of expression.", NULL);
+            "Invalid value \"f1 not not \" of if-feature - unexpected end of expression.", NULL, 0);
     TEST_SCHEMA_PARSE_ERR(1, 0, "inv", "feature f1; feature f2; feature f {if-feature 'or f1 f2';}",
-            "Invalid value \"or f1 f2\" of if-feature - missing feature/expression before \"or\" operation.", NULL);
+            "Invalid value \"or f1 f2\" of if-feature - missing feature/expression before \"or\" operation.", NULL, 0);
 
     /*
      * printing
@@ -1613,8 +1612,8 @@
     /* invalid */
     mod_test_yang = "module x { namespace \"urn:x\"; prefix x; import a { prefix a; } a:e; }";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, mod_test_yang, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL);
-    CHECK_LOG_CTX("Extension instance \"a:e\" missing argument element \"name\".", NULL);
+    CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Extension instance \"a:e\" missing argument element \"name\".", NULL, 0);
 
     mod_test_yin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
             "<module name=\"x\"\n"
@@ -1629,8 +1628,8 @@
             "  <a:e/>\n"
             "</module>\n";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, mod_test_yin, LYS_IN_YIN, NULL));
-    CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL);
-    CHECK_LOG_CTX("Extension instance \"a:e\" missing argument element \"name\".", NULL);
+    CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Extension instance \"a:e\" missing argument element \"name\".", NULL, 0);
 
     mod_test_yin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
             "<module name=\"x\"\n"
@@ -1645,8 +1644,8 @@
             "  <a:e name=\"xxx\"/>\n"
             "</module>\n";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, mod_test_yin, LYS_IN_YIN, NULL));
-    CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL);
-    CHECK_LOG_CTX("Extension instance \"a:e\" missing argument element \"name\".", NULL);
+    CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Extension instance \"a:e\" missing argument element \"name\".", NULL, 0);
 
     mod_test_yin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
             "<module name=\"x\"\n"
@@ -1663,9 +1662,9 @@
             "  </a:e>\n"
             "</module>\n";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, mod_test_yin, LYS_IN_YIN, NULL));
-    CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL);
+    CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL, 0);
     CHECK_LOG_CTX("Extension instance \"a:e\" element and its argument element \"name\" are expected in the same namespace, but they differ.",
-            NULL);
+            NULL, 0);
 
     mod_test_yin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
             "<module name=\"x\"\n"
@@ -1682,9 +1681,9 @@
             "  </a:e>\n"
             "</module>\n";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, mod_test_yin, LYS_IN_YIN, NULL));
-    CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL);
+    CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL, 0);
     CHECK_LOG_CTX("Extension instance \"a:e\" expects argument element \"name\" as its first XML child, but \"value\" element found.",
-            NULL);
+            NULL, 0);
 
 }
 
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index 4507411..c2a13cd 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -83,7 +83,7 @@
     ly_in_free(in, 0);
     assert_int_equal(0, mod->implemented);
     assert_int_equal(LY_EINVAL, lys_set_implemented(mod, feats));
-    CHECK_LOG_CTX("Feature \"invalid\" not found in module \"test\".", NULL);
+    CHECK_LOG_CTX("Feature \"invalid\" not found in module \"test\".", NULL, 0);
     assert_int_equal(LY_SUCCESS, lys_set_implemented(mod, NULL));
     assert_non_null(mod->compiled);
     assert_string_equal("test", mod->name);
@@ -107,14 +107,14 @@
     assert_int_equal(LY_EINVAL, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres.creating, NULL));
     lys_unres_glob_erase(&unres);
     ly_in_free(in, 0);
-    CHECK_LOG_CTX("Input data contains submodule which cannot be parsed directly without its main module.", NULL);
+    CHECK_LOG_CTX("Input data contains submodule which cannot be parsed directly without its main module.", NULL, 0);
 
     /* data definition name collision in top level */
     str = "module aa {namespace urn:aa;prefix aa; leaf a {type string;} container a{presence x;}}";
     assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
     assert_int_equal(LY_EEXIST, lys_parse(UTEST_LYCTX, in, LYS_IN_YANG, NULL, &mod));
     ly_in_free(in, 0);
-    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "Path \"/aa:a\".");
+    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "/aa:a", 0);
 }
 
 static void
@@ -146,8 +146,7 @@
             "  leaf c {type empty;}"
             "}";
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, yang_data, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"c\" of data definition/RPC/action/notification statement.", "Path \"/a:c\".");
-    UTEST_LOG_CLEAN;
+    CHECK_LOG_CTX("Duplicate identifier \"c\" of data definition/RPC/action/notification statement.", "/a:c", 0);
 
     yang_data = "module a {namespace urn:a;prefix a;"
             "  container c;"
@@ -155,8 +154,7 @@
             "  notification c;"
             "}";
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, yang_data, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"c\" of data definition/RPC/action/notification statement.", "Path \"/a:c\".");
-    UTEST_LOG_CLEAN;
+    CHECK_LOG_CTX("Duplicate identifier \"c\" of data definition/RPC/action/notification statement.", "/a:c", 0);
 
     yang_data = "module a {namespace urn:a;prefix a;"
             "  container c;"
@@ -164,8 +162,7 @@
             "  rpc c;"
             "}";
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, yang_data, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"c\" of data definition/RPC/action/notification statement.", "Path \"/a:c\".");
-    UTEST_LOG_CLEAN;
+    CHECK_LOG_CTX("Duplicate identifier \"c\" of data definition/RPC/action/notification statement.", "/a:c", 0);
 
     yang_data = "module a {namespace urn:a;prefix a;"
             "  container c;"
@@ -178,8 +175,7 @@
             "  }"
             "}";
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, yang_data, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"c\" of data definition/RPC/action/notification statement.", "Path \"/a:ch/c/c\".");
-    UTEST_LOG_CLEAN;
+    CHECK_LOG_CTX("Duplicate identifier \"c\" of data definition/RPC/action/notification statement.", "/a:ch/c/c", 0);
 
     /* nested */
     yang_data = "module a {namespace urn:a;prefix a;container c { list l {key \"k\"; leaf k {type string;}"
@@ -187,24 +183,21 @@
             "container a;"
             "}}}";
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, yang_data, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "Path \"/a:c/l/a\".");
-    UTEST_LOG_CLEAN;
+    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "/a:c/l/a", 0);
 
     yang_data = "module a {yang-version 1.1;namespace urn:a;prefix a;container c { list l {key \"k\"; leaf k {type string;}"
             "leaf-list a {type string;}"
             "notification a;"
             "}}}";
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, yang_data, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "Path \"/a:c/l/a\".");
-    UTEST_LOG_CLEAN;
+    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "/a:c/l/a", 0);
 
     yang_data = "module a {yang-version 1.1;namespace urn:a;prefix a;container c { list l {key \"k\"; leaf k {type string;}"
             "leaf-list a {type string;}"
             "action a;"
             "}}}";
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, yang_data, LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "Path \"/a:c/l/a\".");
-    UTEST_LOG_CLEAN;
+    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "/a:c/l/a", 0);
 
     /* grouping */
 }
@@ -314,10 +307,10 @@
     /* invalid */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;leaf-list ll {type empty;}}",
             LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Leaf-list of type \"empty\" is allowed only in YANG 1.1 modules.", "Path \"/aa:ll\".");
+    CHECK_LOG_CTX("Leaf-list of type \"empty\" is allowed only in YANG 1.1 modules.", "/aa:ll", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {yang-version 1.1;namespace urn:bb;prefix bb;leaf-list ll {type empty; default x;}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid default - value does not fit the type (Invalid empty value length 1.).", "Schema location \"/bb:ll\".");
+    CHECK_LOG_CTX("Invalid default - value does not fit the type (Invalid empty value length 1.).", "/bb:ll", 0);
 
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module cc {yang-version 1.1;namespace urn:cc;prefix cc;"
             "leaf-list ll {config false;type string; default one;default two;default one;}}", LYS_IN_YANG, &mod));
@@ -327,12 +320,12 @@
     assert_int_equal(3, LY_ARRAY_COUNT(ll->dflts));
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd {yang-version 1.1;namespace urn:dd;prefix dd;"
             "leaf-list ll {type string; default one;default two;default one;}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Configuration leaf-list has multiple defaults of the same value \"one\".", "Path \"/dd:ll\".");
+    CHECK_LOG_CTX("Configuration leaf-list has multiple defaults of the same value \"one\".", "/dd:ll", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {yang-version 1.1; namespace urn:ee;prefix ee;"
             "leaf ref {type instance-identifier {require-instance true;} default \"/ee:g\";}}", LYS_IN_YANG, NULL));
     CHECK_LOG_CTX("Invalid default - value does not fit the type "
-            "(Invalid instance-identifier \"/ee:g\" value - semantic error: Not found node \"g\" in path.).", "Schema location \"/ee:ref\".");
+            "(Invalid instance-identifier \"/ee:g\" value - semantic error: Not found node \"g\" in path.).", "/ee:ref", 0);
 }
 
 static void
@@ -422,55 +415,55 @@
 
     /* invalid */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;list l;}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Missing key in list representing configuration data.", "Path \"/aa:l\".");
+    CHECK_LOG_CTX("Missing key in list representing configuration data.", "/aa:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {yang-version 1.1; namespace urn:bb;prefix bb;"
             "list l {key x; leaf x {type string; when 1;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("List's key must not have any \"when\" statement.", "Path \"/bb:l/x\".");
+    CHECK_LOG_CTX("List's key must not have any \"when\" statement.", "/bb:l/x", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cc {yang-version 1.1;namespace urn:cc;prefix cc;feature f;"
             "list l {key x; leaf x {type string; if-feature f;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Key \"x\" is disabled.", "Schema location \"/cc:l/x\".");
+    CHECK_LOG_CTX("Key \"x\" is disabled.", "/cc:l/x", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd {namespace urn:dd;prefix dd;"
             "list l {key x; leaf x {type string; config false;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Key of a configuration list must not be a state leaf.", "Path \"/dd:l/x\".");
+    CHECK_LOG_CTX("Key of a configuration list must not be a state leaf.", "/dd:l/x", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee;"
             "list l {config false;key x; leaf x {type string; config true;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "Path \"/ee:l/x\".");
+    CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "/ee:l/x", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff {namespace urn:ff;prefix ff;"
             "list l {key x; leaf-list x {type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("The list's key \"x\" not found.", "Path \"/ff:l\".");
+    CHECK_LOG_CTX("The list's key \"x\" not found.", "/ff:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg {namespace urn:gg;prefix gg;"
             "list l {key x; unique y;leaf x {type string;} leaf-list y {type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Unique's descendant-schema-nodeid \"y\" refers to leaf-list node instead of a leaf.", "Path \"/gg:l\".");
+    CHECK_LOG_CTX("Unique's descendant-schema-nodeid \"y\" refers to leaf-list node instead of a leaf.", "/gg:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module hh {namespace urn:hh;prefix hh;"
             "list l {key x; unique \"x y\";leaf x {type string;} leaf y {config false; type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Unique statement \"x y\" refers to leaves with different config type.", "Path \"/hh:l\".");
+    CHECK_LOG_CTX("Unique statement \"x y\" refers to leaves with different config type.", "/hh:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ii {namespace urn:ii;prefix ii;"
             "list l {key x; unique a:x;leaf x {type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid descendant-schema-nodeid value \"a:x\" - prefix \"a\" not defined in module \"ii\".", "Path \"/ii:l\".");
+    CHECK_LOG_CTX("Invalid descendant-schema-nodeid value \"a:x\" - prefix \"a\" not defined in module \"ii\".", "/ii:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj {namespace urn:jj;prefix jj;"
             "list l {key x; unique c/x;leaf x {type string;}container c {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid descendant-schema-nodeid value \"c/x\" - target node not found.", "Path \"/jj:l\".");
+    CHECK_LOG_CTX("Invalid descendant-schema-nodeid value \"c/x\" - target node not found.", "/jj:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk {namespace urn:kk;prefix kk;"
             "list l {key x; unique c^y;leaf x {type string;}container c {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid descendant-schema-nodeid value \"c^\" - missing \"/\" as node-identifier separator.", "Path \"/kk:l\".");
+    CHECK_LOG_CTX("Invalid descendant-schema-nodeid value \"c^\" - missing \"/\" as node-identifier separator.", "/kk:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ll {namespace urn:ll;prefix ll;"
             "list l {key \"x y x\";leaf x {type string;}leaf y {type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicated key identifier \"x\".", "Path \"/ll:l\".");
+    CHECK_LOG_CTX("Duplicated key identifier \"x\".", "/ll:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm {namespace urn:mm;prefix mm;"
             "list l {key x;leaf x {type empty;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("List key of the \"empty\" type is allowed only in YANG 1.1 modules.", "Path \"/mm:l/x\".");
+    CHECK_LOG_CTX("List key of the \"empty\" type is allowed only in YANG 1.1 modules.", "/mm:l/x", 0);
 }
 
 static void
@@ -509,26 +502,26 @@
 
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;"
             "choice ch {case a {leaf x {type string;}}leaf x {type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"x\" of data definition/RPC/action/notification statement.", "Path \"/aa:ch/x/x\".");
+    CHECK_LOG_CTX("Duplicate identifier \"x\" of data definition/RPC/action/notification statement.", "/aa:ch/x/x", 0);
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module aa2 {namespace urn:aa2;prefix aa;"
             "choice ch {case a {leaf y {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"y\" of data definition/RPC/action/notification statement.", "Path \"/aa2:ch/b/y\".");
+    CHECK_LOG_CTX("Duplicate identifier \"y\" of data definition/RPC/action/notification statement.", "/aa2:ch/b/y", 0);
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;"
             "choice ch {case a {leaf x {type string;}}leaf a {type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"a\" of case statement.", "Path \"/bb:ch/a\".");
+    CHECK_LOG_CTX("Duplicate identifier \"a\" of case statement.", "/bb:ch/a", 0);
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module bb2 {namespace urn:bb2;prefix bb;"
             "choice ch {case b {leaf x {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"b\" of case statement.", "Path \"/bb2:ch/b\".");
+    CHECK_LOG_CTX("Duplicate identifier \"b\" of case statement.", "/bb2:ch/b", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ca {namespace urn:ca;prefix ca;"
             "choice ch {default c;case a {leaf x {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Default case \"c\" not found.", "Path \"/ca:ch\".");
+    CHECK_LOG_CTX("Default case \"c\" not found.", "/ca:ch", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cb {namespace urn:cb;prefix cb; import a {prefix a;}"
             "choice ch {default a:a;case a {leaf x {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Default case \"a:a\" not found.", "Path \"/cb:ch\".");
+    CHECK_LOG_CTX("Default case \"a:a\" not found.", "/cb:ch", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:cc;prefix cc;"
             "choice ch {default a;case a {leaf x {mandatory true;type string;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Mandatory node \"x\" under the default case \"a\".", "Path \"/cc:ch\".");
+    CHECK_LOG_CTX("Mandatory node \"x\" under the default case \"a\".", "/cc:ch", 0);
     /* TODO check with mandatory nodes from augment placed into the case */
 }
 
@@ -554,9 +547,9 @@
 
     /* invalid */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;anydata any;}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
     CHECK_LOG_CTX("Invalid keyword \"anydata\" as a child of \"module\" - the statement is allowed only in YANG 1.1 modules.",
-            "Line number 1.");
+            NULL, 1);
 }
 
 static void
@@ -590,32 +583,32 @@
     /* invalid */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;container top {action x;}}",
             LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
     CHECK_LOG_CTX("Invalid keyword \"action\" as a child of \"container\" - the statement is allowed only in YANG 1.1 modules.",
-            "Line number 1.");
+            NULL, 1);
 
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;leaf x{type string;} rpc x;}",
             LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"x\" of data definition/RPC/action/notification statement.", "Path \"/bb:x\".");
+    CHECK_LOG_CTX("Duplicate identifier \"x\" of data definition/RPC/action/notification statement.", "/bb:x", 0);
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module cc {yang-version 1.1; namespace urn:cc;prefix cc;container c {leaf y {type string;} action y;}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"y\" of data definition/RPC/action/notification statement.", "Path \"/cc:c/y\".");
+    CHECK_LOG_CTX("Duplicate identifier \"y\" of data definition/RPC/action/notification statement.", "/cc:c/y", 0);
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module dd {yang-version 1.1; namespace urn:dd;prefix dd;container c {action z; action z;}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"z\" of data definition/RPC/action/notification statement.", "Path \"/dd:c/z\".");
+    CHECK_LOG_CTX("Duplicate identifier \"z\" of data definition/RPC/action/notification statement.", "/dd:c/z", 0);
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule eesub {belongs-to ee {prefix ee;} notification w;}");
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module ee {yang-version 1.1; namespace urn:ee;prefix ee;include eesub; rpc w;}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"w\" of data definition/RPC/action/notification statement.", "Path \"/ee:w\".");
+    CHECK_LOG_CTX("Duplicate identifier \"w\" of data definition/RPC/action/notification statement.", "/ee:w", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff {yang-version 1.1; namespace urn:ff;prefix ff; rpc test {input {container a {leaf b {type string;}}}}"
             "augment /test/input/a {action invalid {input {leaf x {type string;}}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Action \"invalid\" is placed inside another RPC/action.", "Path \"/ff:{augment='/test/input/a'}/invalid\".");
+    CHECK_LOG_CTX("Action \"invalid\" is placed inside another RPC/action.", "/ff:{augment='/test/input/a'}/invalid", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg {yang-version 1.1; namespace urn:gg;prefix gg; notification test {container a {leaf b {type string;}}}"
             "augment /test/a {action invalid {input {leaf x {type string;}}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Action \"invalid\" is placed inside notification.", "Path \"/gg:{augment='/test/a'}/invalid\".");
+    CHECK_LOG_CTX("Action \"invalid\" is placed inside notification.", "/gg:{augment='/test/a'}/invalid", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module hh {yang-version 1.1; namespace urn:hh;prefix hh; notification test {container a {uses grp;}}"
             "grouping grp {action invalid {input {leaf x {type string;}}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Action \"invalid\" is placed inside notification.", "Path \"/hh:test/a/{uses='grp'}/invalid\".");
+    CHECK_LOG_CTX("Action \"invalid\" is placed inside notification.", "/hh:test/a/{uses='grp'}/invalid", 0);
 }
 
 static void
@@ -662,31 +655,31 @@
     /* invalid */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;container top {notification x;}}",
             LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
     CHECK_LOG_CTX("Invalid keyword \"notification\" as a child of \"container\" - the statement is allowed only in YANG 1.1 modules.",
-            "Line number 1.");
+            NULL, 1);
 
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;leaf x{type string;} notification x;}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"x\" of data definition/RPC/action/notification statement.", "Path \"/bb:x\".");
+    CHECK_LOG_CTX("Duplicate identifier \"x\" of data definition/RPC/action/notification statement.", "/bb:x", 0);
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module cc {yang-version 1.1; namespace urn:cc;prefix cc;container c {leaf y {type string;} notification y;}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"y\" of data definition/RPC/action/notification statement.", "Path \"/cc:c/y\".");
+    CHECK_LOG_CTX("Duplicate identifier \"y\" of data definition/RPC/action/notification statement.", "/cc:c/y", 0);
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module dd {yang-version 1.1; namespace urn:dd;prefix dd;container c {notification z; notification z;}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"z\" of data definition/RPC/action/notification statement.", "Path \"/dd:c/z\".");
+    CHECK_LOG_CTX("Duplicate identifier \"z\" of data definition/RPC/action/notification statement.", "/dd:c/z", 0);
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule eesub {belongs-to ee {prefix ee;} rpc w;}");
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module ee {yang-version 1.1; namespace urn:ee;prefix ee;include eesub; notification w;}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Duplicate identifier \"w\" of data definition/RPC/action/notification statement.", "Path \"/ee:w\".");
+    CHECK_LOG_CTX("Duplicate identifier \"w\" of data definition/RPC/action/notification statement.", "/ee:w", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff {yang-version 1.1; namespace urn:ff;prefix ff; rpc test {input {container a {leaf b {type string;}}}}"
             "augment /test/input/a {notification invalid {leaf x {type string;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Notification \"invalid\" is placed inside RPC/action.", "Path \"/ff:{augment='/test/input/a'}/invalid\".");
+    CHECK_LOG_CTX("Notification \"invalid\" is placed inside RPC/action.", "/ff:{augment='/test/input/a'}/invalid", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg {yang-version 1.1; namespace urn:gg;prefix gg; notification test {container a {leaf b {type string;}}}"
             "augment /test/a {notification invalid {leaf x {type string;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Notification \"invalid\" is placed inside another notification.", "Path \"/gg:{augment='/test/a'}/invalid\".");
+    CHECK_LOG_CTX("Notification \"invalid\" is placed inside another notification.", "/gg:{augment='/test/a'}/invalid", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module hh {yang-version 1.1; namespace urn:hh;prefix hh; rpc test {input {container a {uses grp;}}}"
             "grouping grp {notification invalid {leaf x {type string;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Notification \"invalid\" is placed inside RPC/action.", "Path \"/hh:test/input/a/{uses='grp'}/invalid\".");
+    CHECK_LOG_CTX("Notification \"invalid\" is placed inside RPC/action.", "/hh:test/input/a/{uses='grp'}/invalid", 0);
 }
 
 /**
@@ -937,54 +930,56 @@
 
     /* invalid values */
     assert_int_equal(LY_EDENIED, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;leaf l {type binary {length -10;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - value \"-10\" does not fit the type limitations.", "Path \"/aa:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - value \"-10\" does not fit the type limitations.", "/aa:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;leaf l {type binary {length 18446744073709551616;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - invalid value \"18446744073709551616\".", "Path \"/bb:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - invalid value \"18446744073709551616\".", "/bb:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:cc;prefix cc;leaf l {type binary {length \"max .. 10\";}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - unexpected data after max keyword (.. 10).", "Path \"/cc:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - unexpected data after max keyword (.. 10).", "/cc:l", 0);
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module dd {namespace urn:dd;prefix dd;leaf l {type binary {length 50..10;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - values are not in ascending order (10).", "Path \"/dd:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - values are not in ascending order (10).", "/dd:l", 0);
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee;leaf l {type binary {length \"50 | 10\";}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - values are not in ascending order (10).", "Path \"/ee:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - values are not in ascending order (10).", "/ee:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff {namespace urn:ff;prefix ff;leaf l {type binary {length \"x\";}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - unexpected data (x).", "Path \"/ff:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - unexpected data (x).", "/ff:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg {namespace urn:gg;prefix gg;leaf l {type binary {length \"50 | min\";}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - unexpected data before min keyword (50 | ).", "Path \"/gg:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - unexpected data before min keyword (50 | ).", "/gg:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module hh {namespace urn:hh;prefix hh;leaf l {type binary {length \"| 50\";}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - unexpected beginning of the expression (| 50).", "Path \"/hh:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - unexpected beginning of the expression (| 50).", "/hh:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ii {namespace urn:ii;prefix ii;leaf l {type binary {length \"10 ..\";}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - unexpected end of the expression after \"..\" (10 ..).", "Path \"/ii:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - unexpected end of the expression after \"..\" (10 ..).", "/ii:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj {namespace urn:jj;prefix jj;leaf l {type binary {length \".. 10\";}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - unexpected \"..\" without a lower bound.", "Path \"/jj:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - unexpected \"..\" without a lower bound.", "/jj:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk {namespace urn:kk;prefix kk;leaf l {type binary {length \"10 |\";}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - unexpected end of the expression (10 |).", "Path \"/kk:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - unexpected end of the expression (10 |).", "/kk:l", 0);
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module kl {namespace urn:kl;prefix kl;leaf l {type binary {length \"10..20 | 15..30\";}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - values are not in ascending order (15).", "Path \"/kl:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - values are not in ascending order (15).", "/kl:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ll {namespace urn:ll;prefix ll;typedef mytype {type binary {length 10;}}"
             "leaf l {type mytype {length 11;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (11) is not equally or more limiting.", "Path \"/ll:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (11) is not equally or more limiting.", "/ll:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm {namespace urn:mm;prefix mm;typedef mytype {type binary {length 10..100;}}"
             "leaf l {type mytype {length 1..11;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (1..11) is not equally or more limiting.", "Path \"/mm:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (1..11) is not equally or more limiting.", "/mm:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module nn {namespace urn:nn;prefix nn;typedef mytype {type binary {length 10..100;}}"
             "leaf l {type mytype {length 20..110;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (20..110) is not equally or more limiting.", "Path \"/nn:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (20..110) is not equally or more limiting.",
+            "/nn:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module oo {namespace urn:oo;prefix oo;typedef mytype {type binary {length 10..100;}}"
             "leaf l {type mytype {length 20..30|110..120;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (20..30|110..120) is not equally or more limiting.", "Path \"/oo:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (20..30|110..120) is not equally or more limiting.",
+            "/oo:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module pp {namespace urn:pp;prefix pp;typedef mytype {type binary {length 10..11;}}"
             "leaf l {type mytype {length 15;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (15) is not equally or more limiting.", "Path \"/pp:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (15) is not equally or more limiting.", "/pp:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module qq {namespace urn:qq;prefix qq;typedef mytype {type binary {length 10..20|30..40;}}"
             "leaf l {type mytype {length 15..35;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (15..35) is not equally or more limiting.", "Path \"/qq:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (15..35) is not equally or more limiting.", "/qq:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module rr {namespace urn:rr;prefix rr;typedef mytype {type binary {length 10;}}"
             "leaf l {type mytype {length 10..35;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (10..35) is not equally or more limiting.", "Path \"/rr:l\".");
+    CHECK_LOG_CTX("Invalid length restriction - the derived restriction (10..35) is not equally or more limiting.", "/rr:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ss {namespace urn:ss;prefix ss;leaf l {type binary {pattern '[0-9]*';}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid type restrictions for binary type.", "Path \"/ss:l\".");
+    CHECK_LOG_CTX("Invalid type restrictions for binary type.", "/ss:l", 0);
 }
 
 static void
@@ -1087,63 +1082,63 @@
     /* invalid cases */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; feature f; leaf l {type enumeration {"
             "enum one {if-feature f;}}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
     CHECK_LOG_CTX("Invalid keyword \"if-feature\" as a child of \"enum\" - the statement is allowed only in YANG 1.1 modules.",
-            "Line number 1.");
+            NULL, 1);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
             "enum one {value -2147483649;}}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid value \"-2147483649\" of \"value\".", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid value \"-2147483649\" of \"value\".", NULL, 1);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
             "enum one {value 2147483648;}}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid value \"2147483648\" of \"value\".", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid value \"2147483648\" of \"value\".", NULL, 1);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
             "enum one; enum one;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"one\" of enum statement.", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"one\" of enum statement.", NULL, 1);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
             "enum '';}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
-    CHECK_LOG_CTX("Enum name must not be zero-length.", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Enum name must not be zero-length.", NULL, 1);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
             "enum ' x';}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
-    CHECK_LOG_CTX("Enum name must not have any leading or trailing whitespaces (\" x\").", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Enum name must not have any leading or trailing whitespaces (\" x\").", NULL, 1);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
             "enum 'x ';}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
-    CHECK_LOG_CTX("Enum name must not have any leading or trailing whitespaces (\"x \").", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Enum name must not have any leading or trailing whitespaces (\"x \").", NULL, 1);
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
             "enum 'inva\nlid';}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Control characters in enum name should be avoided (\"inva\nlid\", character number 5).", NULL);
+    CHECK_LOG_CTX("Control characters in enum name should be avoided (\"inva\nlid\", character number 5).", NULL, 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb; leaf l {type enumeration;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Missing enum substatement for enumeration type.", "Path \"/bb:l\".");
+    CHECK_LOG_CTX("Missing enum substatement for enumeration type.", "/bb:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cc {yang-version 1.1;namespace urn:cc;prefix cc;typedef mytype {type enumeration {enum one;}}"
             "leaf l {type mytype {enum two;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid enumeration - derived type adds new item \"two\".", "Path \"/cc:l\".");
+    CHECK_LOG_CTX("Invalid enumeration - derived type adds new item \"two\".", "/cc:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd {yang-version 1.1;namespace urn:dd;prefix dd;typedef mytype {type enumeration {enum one;}}"
             "leaf l {type mytype {enum one {value 1;}}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid enumeration - value of the item \"one\" has changed from 0 to 1 in the derived type.", "Path \"/dd:l\".");
+    CHECK_LOG_CTX("Invalid enumeration - value of the item \"one\" has changed from 0 to 1 in the derived type.", "/dd:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee;leaf l {type enumeration {enum x {value 2147483647;}enum y;}}}",
             LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid enumeration - it is not possible to auto-assign enum value for \"y\" since the highest value is already 2147483647.",
-            "Path \"/ee:l\".");
+            "/ee:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff {namespace urn:ff;prefix ff;leaf l {type enumeration {enum x {value 1;}enum y {value 1;}}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid enumeration - value 1 collide in items \"y\" and \"x\".", "Path \"/ff:l\".");
+    CHECK_LOG_CTX("Invalid enumeration - value 1 collide in items \"y\" and \"x\".", "/ff:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg {namespace urn:gg;prefix gg;typedef mytype {type enumeration;}"
             "leaf l {type mytype {enum one;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Missing enum substatement for enumeration type mytype.", "Path \"/gg:l\".");
+    CHECK_LOG_CTX("Missing enum substatement for enumeration type mytype.", "/gg:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module hh {namespace urn:hh;prefix hh; typedef mytype {type enumeration {enum one;}}"
             "leaf l {type mytype {enum one;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Enumeration type can be subtyped only in YANG 1.1 modules.", "Path \"/hh:l\".");
+    CHECK_LOG_CTX("Enumeration type can be subtyped only in YANG 1.1 modules.", "/hh:l", 0);
 }
 
 static void
@@ -1193,43 +1188,44 @@
 
     /* invalid cases */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type decimal64 {fraction-digits 0;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid value \"0\" of \"fraction-digits\".", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid value \"0\" of \"fraction-digits\".", NULL, 1);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type decimal64 {fraction-digits -1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid value \"-1\" of \"fraction-digits\".", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid value \"-1\" of \"fraction-digits\".", NULL, 1);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type decimal64 {fraction-digits 19;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
-    CHECK_LOG_CTX("Value \"19\" is out of \"fraction-digits\" bounds.", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Value \"19\" is out of \"fraction-digits\" bounds.", NULL, 1);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type decimal64;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Missing fraction-digits substatement for decimal64 type.", "Path \"/aa:l\".");
+    CHECK_LOG_CTX("Missing fraction-digits substatement for decimal64 type.", "/aa:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ab {namespace urn:ab;prefix ab; typedef mytype {type decimal64;}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Missing fraction-digits substatement for decimal64 type mytype.", "Path \"/ab:l\".");
+    CHECK_LOG_CTX("Missing fraction-digits substatement for decimal64 type mytype.", "/ab:l", 0);
 
     assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb; leaf l {type decimal64 {fraction-digits 2;"
             "range '3.142';}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Range boundary \"3.142\" of decimal64 type exceeds defined number (2) of fraction digits.", "Path \"/bb:l\".");
+    CHECK_LOG_CTX("Range boundary \"3.142\" of decimal64 type exceeds defined number (2) of fraction digits.", "/bb:l", 0);
 
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:cc;prefix cc; leaf l {type decimal64 {fraction-digits 2;"
             "range '4 | 3.14';}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid range restriction - values are not in ascending order (3.14).", "Path \"/cc:l\".");
+    CHECK_LOG_CTX("Invalid range restriction - values are not in ascending order (3.14).", "/cc:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd {namespace urn:dd;prefix dd; typedef mytype {type decimal64 {fraction-digits 2;}}"
             "leaf l {type mytype {fraction-digits 3;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid fraction-digits substatement for type not directly derived from decimal64 built-in type.", "Path \"/dd:l\".");
+    CHECK_LOG_CTX("Invalid fraction-digits substatement for type not directly derived from decimal64 built-in type.", "/dd:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module de {namespace urn:de;prefix de; typedef mytype {type decimal64 {fraction-digits 2;}}"
             "typedef mytype2 {type mytype {fraction-digits 3;}}leaf l {type mytype2;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid fraction-digits substatement for type \"mytype2\" not directly derived from decimal64 built-in type.", "Path \"/de:l\".");
+    CHECK_LOG_CTX("Invalid fraction-digits substatement for type \"mytype2\" not directly derived from decimal64 built-in type.",
+            "/de:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee;typedef mytype {type decimal64 {"
             "fraction-digits 18;range '-10 .. 0';}}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid range restriction - invalid value \"-10000000000000000000\".", "Path \"/ee:l\".");
+    CHECK_LOG_CTX("Invalid range restriction - invalid value \"-10000000000000000000\".", "/ee:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee;typedef mytype {type decimal64 {"
             "fraction-digits 18;range '0 .. 10';}}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid range restriction - invalid value \"10000000000000000000\".", "Path \"/ee:l\".");
+    CHECK_LOG_CTX("Invalid range restriction - invalid value \"10000000000000000000\".", "/ee:l", 0);
 }
 
 static void
@@ -1258,11 +1254,11 @@
 
     /* invalid cases */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type instance-identifier {require-instance yes;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid value \"yes\" of \"require-instance\".", "Line number 1.");
+    CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid value \"yes\" of \"require-instance\".", NULL, 1);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type instance-identifier {fraction-digits 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid type restrictions for instance-identifier type.", "Path \"/aa:l\".");
+    CHECK_LOG_CTX("Invalid type restrictions for instance-identifier type.", "/aa:l", 0);
 }
 
 static ly_bool
@@ -1340,8 +1336,7 @@
     assert_true(contains_derived_identity(UTEST_LYCTX, "a", NULL, "baseid", "id1"));
     data = "<lf xmlns=\"urn:b\" xmlns:ids=\"urn:a\">ids:id1</lf>";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG("Invalid identityref \"ids:id1\" value - identity found in non-implemented module \"a\".",
-            "Schema location \"/b:lf\", line number 1.");
+    CHECK_LOG_CTX("Invalid identityref \"ids:id1\" value - identity found in non-implemented module \"a\".", "/b:lf", 1);
     assert_non_null(ly_ctx_get_module(UTEST_LYCTX, "a", NULL));
     assert_false(contains_derived_identity(UTEST_LYCTX, "a", NULL, "baseid", "id3"));
     data = "<lf xmlns=\"urn:b\" xmlns:ids=\"urn:a\">ids:id3</lf>";
@@ -1369,13 +1364,11 @@
     assert_true(contains_derived_identity(UTEST_LYCTX, "a", NULL, "baseid", "id1"));
     data = "<lf xmlns=\"urn:b\" xmlns:ids=\"urn:a\">ids:id1</lf>";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG("Invalid identityref \"ids:id1\" value - identity found in non-implemented module \"a\".",
-            "Schema location \"/b:lf\", line number 1.");
+    CHECK_LOG_CTX("Invalid identityref \"ids:id1\" value - identity found in non-implemented module \"a\".", "/b:lf", 1);
     assert_true(contains_derived_identity(UTEST_LYCTX, "a", NULL, "baseid", "id3"));
     data = "<lf xmlns=\"urn:b\" xmlns:ids=\"urn:c\">ids:id3</lf>";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG("Invalid identityref \"ids:id3\" value - identity found in non-implemented module \"c\".",
-            "Schema location \"/b:lf\", line number 1.");
+    CHECK_LOG_CTX("Invalid identityref \"ids:id3\" value - identity found in non-implemented module \"c\".", "/b:lf", 1);
     RESET_CTX(UTEST_LYCTX);
 
     /* Unimplemented module expand base identity located in implemented module. */
@@ -1399,8 +1392,7 @@
     assert_true(contains_derived_identity(UTEST_LYCTX, "b", NULL, "baseid", "id1"));
     data = "<lf xmlns=\"urn:b\" xmlns:ids=\"urn:a\">ids:id1</lf>";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG("Invalid identityref \"ids:id1\" value - identity found in non-implemented module \"a\".",
-            "Schema location \"/b:lf\", line number 1.");
+    CHECK_LOG_CTX("Invalid identityref \"ids:id1\" value - identity found in non-implemented module \"a\".", "/b:lf", 1);
     RESET_CTX(UTEST_LYCTX);
 
     /* Transitivity of derived identity through unimplemented module. */
@@ -1503,9 +1495,9 @@
             "}";
     ly_log_level(LY_LLVRB);
     UTEST_ADD_MODULE(str, LYS_IN_YANG, NULL, NULL);
-    CHECK_LOG("Implemented module \"a@2015-05-08\" was not and will not "
+    CHECK_LOG_LASTMSG("Implemented module \"a@2015-05-08\" was not and will not "
             "be imported if the revision-date is missing in the import "
-            "statement. Instead, the revision \"2014-05-08\" is imported.", NULL);
+            "statement. Instead, the revision \"2014-05-08\" is imported.");
     ly_log_level(LY_LLWRN);
     /* Data is inserted only to implemented revision. */
     data = "<alf xmlns=\"urn:a\" xmlns:ids=\"urn:b\">ids:id1</alf>";
@@ -1582,8 +1574,7 @@
     assert_true(contains_derived_identity(UTEST_LYCTX, "a", NULL, "baseid", "id3"));
     data = "<lf xmlns=\"urn:b\">id3</lf>";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Invalid identityref \"id3\" value - identity is disabled by if-feature.",
-            "Schema location \"/b:lf\", line number 1.");
+    CHECK_LOG_CTX("Invalid identityref \"id3\" value - identity is disabled by if-feature.", "/b:lf", 1);
     RESET_CTX(UTEST_LYCTX);
 
     /* The derived identities are enabled and disabled in submodule. */
@@ -1615,8 +1606,7 @@
     assert_true(contains_derived_identity(UTEST_LYCTX, "a", NULL, "baseid", "id3"));
     data = "<lf xmlns=\"urn:b\" xmlns:ids=\"urn:a\">ids:id3</lf>";
     CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
-    CHECK_LOG_CTX("Invalid identityref \"ids:id3\" value - identity is disabled by if-feature.",
-            "Schema location \"/b:lf\", line number 1.");
+    CHECK_LOG_CTX("Invalid identityref \"ids:id3\" value - identity is disabled by if-feature.", "/b:lf", 1);
     RESET_CTX(UTEST_LYCTX);
 
 #undef RESET_CTX
@@ -1658,29 +1648,31 @@
 
     /* invalid cases */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type identityref;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Missing base substatement for identityref type.", "Path \"/aa:l\".");
+    CHECK_LOG_CTX("Missing base substatement for identityref type.", "/aa:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb; typedef mytype {type identityref;}"
             "leaf l {type mytype;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Missing base substatement for identityref type mytype.", "Path \"/bb:l\".");
+    CHECK_LOG_CTX("Missing base substatement for identityref type mytype.", "/bb:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:cc;prefix cc; identity i; typedef mytype {type identityref {base i;}}"
             "leaf l {type mytype {base i;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid base substatement for the type not directly derived from identityref built-in type.", "Path \"/cc:l\".");
+    CHECK_LOG_CTX("Invalid base substatement for the type not directly derived from identityref built-in type.",
+            "/cc:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd {namespace urn:dd;prefix dd; identity i; typedef mytype {type identityref {base i;}}"
             "typedef mytype2 {type mytype {base i;}}leaf l {type mytype2;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid base substatement for the type \"mytype2\" not directly derived from identityref built-in type.", "Path \"/dd:l\".");
+    CHECK_LOG_CTX("Invalid base substatement for the type \"mytype2\" not directly derived from identityref built-in type.",
+            "/dd:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee; identity i; identity j;"
             "leaf l {type identityref {base i;base j;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Multiple bases in identityref type are allowed only in YANG 1.1 modules.", "Path \"/ee:l\".");
+    CHECK_LOG_CTX("Multiple bases in identityref type are allowed only in YANG 1.1 modules.", "/ee:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff {namespace urn:ff;prefix ff; identity i;leaf l {type identityref {base j;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Unable to find base (j) of identityref.", "Path \"/ff:l\".");
+    CHECK_LOG_CTX("Unable to find base (j) of identityref.", "/ff:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg {namespace urn:gg;prefix gg;leaf l {type identityref {base x:j;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid prefix used for base (x:j) of identityref.", "Path \"/gg:l\".");
+    CHECK_LOG_CTX("Invalid prefix used for base (x:j) of identityref.", "/gg:l", 0);
 }
 
 static void
@@ -1696,32 +1688,32 @@
     path = "invalid_path";
     assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
             LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &expr));
-    CHECK_LOG_CTX("Unexpected XPath token \"NameTest\" (\"invalid_path\"), expected \"..\".", NULL);
+    CHECK_LOG_CTX("Unexpected XPath token \"NameTest\" (\"invalid_path\"), expected \"..\".", NULL, 0);
 
     path = "..";
     assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
             LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &expr));
-    CHECK_LOG_CTX("Unexpected XPath expression end.", NULL);
+    CHECK_LOG_CTX("Unexpected XPath expression end.", NULL, 0);
 
     path = "..[";
     assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
             LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &expr));
-    CHECK_LOG_CTX("Unexpected XPath token \"[\" (\"[\"), expected \"Operator(Path)\".", NULL);
+    CHECK_LOG_CTX("Unexpected XPath token \"[\" (\"[\"), expected \"Operator(Path)\".", NULL, 0);
 
     path = "../";
     assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
             LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &expr));
-    CHECK_LOG_CTX("Unexpected XPath expression end.", NULL);
+    CHECK_LOG_CTX("Unexpected XPath expression end.", NULL, 0);
 
     path = "/";
     assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
             LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &expr));
-    CHECK_LOG_CTX("Unexpected XPath expression end.", NULL);
+    CHECK_LOG_CTX("Unexpected XPath expression end.", NULL, 0);
 
     path = "../../pref:id/xxx[predicate]/invalid!!!";
     assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
             LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &expr));
-    CHECK_LOG_CTX("Invalid character 0x21 ('!'), perhaps \"invalid\" is supposed to be a function call.", NULL);
+    CHECK_LOG_CTX("Invalid character 0x21 ('!'), perhaps \"invalid\" is supposed to be a function call.", NULL, 0);
 
     path = "/absolute/prefix:path";
     assert_int_equal(LY_SUCCESS, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
@@ -1806,8 +1798,8 @@
             "leaf ref1 {type leafref {path /target;}}"
             "leaf target {if-feature 'f1'; type boolean;}}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Target of leafref \"ref1\" cannot be referenced because it is disabled.", "Schema location \"/e:ref1\".");
-    CHECK_LOG_CTX("Not found node \"target\" in path.", "Schema location \"/e:ref1\".");
+    CHECK_LOG_CTX("Target of leafref \"ref1\" cannot be referenced because it is disabled.", "/e:ref1", 0);
+    CHECK_LOG_CTX("Not found node \"target\" in path.", "/e:ref1", 0);
 
     str = "module en {yang-version 1.1;namespace urn:en;prefix en;feature f1;"
             "leaf ref1 {if-feature 'f1'; type leafref {path /target;}}"
@@ -1817,7 +1809,7 @@
     str = "module e {yang-version 1.1;namespace urn:e;prefix e;feature f1;"
             "leaf ref1 {if-feature 'f1'; type leafref {path /target;}}}";
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Not found node \"target\" in path.", "Schema location \"/e:ref1\".");
+    CHECK_LOG_CTX("Not found node \"target\" in path.", "/e:ref1", 0);
 
     ly_ctx_set_options(UTEST_LYCTX, LY_CTX_REF_IMPLEMENTED);
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "module cl {namespace urn:cl;prefix cl;feature f1;"
@@ -1827,8 +1819,8 @@
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module im {namespace urn:im;prefix im;import cl {prefix cl;}"
             "leaf ref {must \"/cl:h > 0\"; type uint16;}}", LYS_IN_YANG, &mod));
     ly_ctx_unset_options(UTEST_LYCTX, LY_CTX_REF_IMPLEMENTED);
-    CHECK_LOG_CTX("Target of leafref \"g\" cannot be referenced because it is disabled.", "Schema location \"/cl:g\".");
-    CHECK_LOG_CTX("Not found node \"f\" in path.", "Schema location \"/cl:g\".");
+    CHECK_LOG_CTX("Target of leafref \"g\" cannot be referenced because it is disabled.", "/cl:g", 0);
+    CHECK_LOG_CTX("Not found node \"f\" in path.", "/cl:g", 0);
 
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module f {namespace urn:f;prefix f;"
             "list interface{key name;leaf name{type string;}list address {key ip;leaf ip {type string;}}}"
@@ -1914,170 +1906,170 @@
     /* invalid paths */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;container a {leaf target2 {type uint8;}}"
             "leaf ref1 {type leafref {path ../a/invalid;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Not found node \"invalid\" in path.", "Schema location \"/aa:ref1\".");
+    CHECK_LOG_CTX("Not found node \"invalid\" in path.", "/aa:ref1", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;container a {leaf target2 {type uint8;}}"
             "leaf ref1 {type leafref {path ../../toohigh;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Too many parent references in path.", "Schema location \"/bb:ref1\".");
+    CHECK_LOG_CTX("Too many parent references in path.", "/bb:ref1", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:cc;prefix cc;container a {leaf target2 {type uint8;}}"
             "leaf ref1 {type leafref {path /a:invalid;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("No module connected with the prefix \"a\" found (prefix format schema stored mapping).", "Schema location \"/cc:ref1\".");
+    CHECK_LOG_CTX("No module connected with the prefix \"a\" found (prefix format schema stored mapping).", "/cc:ref1", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd {namespace urn:dd;prefix dd;leaf target1 {type string;}"
             "container a {leaf target2 {type uint8;}} leaf ref1 {type leafref {"
             "path '/a[target2 = current()/../target1]/target2';}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("List predicate defined for container \"a\" in path.", "Schema location \"/dd:ref1\".");
+    CHECK_LOG_CTX("List predicate defined for container \"a\" in path.", "/dd:ref1", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee;\n  container a {leaf target2 {type uint8;}}\n"
             "leaf ref1 {type leafref {path /a!invalid;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"ee\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid character 0x21 ('!'), perhaps \"a\" is supposed to be a function call.", "Line number 3.");
+    CHECK_LOG_CTX("Parsing module \"ee\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid character 0x21 ('!'), perhaps \"a\" is supposed to be a function call.", NULL, 3);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff {namespace urn:ff;prefix ff;container a {leaf target2 {type uint8;}}"
             "leaf ref1 {type leafref {path /a;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid leafref path \"/a\" - target node is container instead of leaf or leaf-list.", "Schema location \"/ff:ref1\".");
+    CHECK_LOG_CTX("Invalid leafref path \"/a\" - target node is container instead of leaf or leaf-list.", "/ff:ref1", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg {namespace urn:gg;prefix gg;container a {leaf target2 {type uint8;"
             "status deprecated;}} leaf ref1 {type leafref {path /a/target2;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("A current definition \"ref1\" is not allowed to reference deprecated definition \"target2\".",
-            "Schema location \"/gg:ref1\".");
+            "/gg:ref1", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module hh {namespace urn:hh;prefix hh;"
             "leaf ref1 {type leafref;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Missing path substatement for leafref type.", "Path \"/hh:ref1\".");
+    CHECK_LOG_CTX("Missing path substatement for leafref type.", "/hh:ref1", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ii {namespace urn:ii;prefix ii;typedef mytype {type leafref;}"
             "leaf ref1 {type mytype;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Missing path substatement for leafref type mytype.", "Path \"/ii:ref1\".");
+    CHECK_LOG_CTX("Missing path substatement for leafref type mytype.", "/ii:ref1", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk {namespace urn:kk;prefix kk;"
             "leaf ref {type leafref {path /target;}}leaf target {type string;config false;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid leafref path \"/target\" - target is supposed to represent configuration data (as the leafref does), but it does not.", "Schema location \"/kk:ref\".");
+    CHECK_LOG_CTX("Invalid leafref path \"/target\" - target is supposed to represent configuration data (as the leafref does), but it does not.",
+            "/kk:ref", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ll {namespace urn:ll;prefix ll;"
             "leaf ref {type leafref {path /target; require-instance true;}}leaf target {type string;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Leafref type can be restricted by require-instance statement only in YANG 1.1 modules.", "Path \"/ll:ref\".");
+    CHECK_LOG_CTX("Leafref type can be restricted by require-instance statement only in YANG 1.1 modules.",
+            "/ll:ref", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm {namespace urn:mm;prefix mm;typedef mytype {type leafref {path /target;require-instance false;}}"
             "leaf ref {type mytype;}leaf target {type string;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Leafref type \"mytype\" can be restricted by require-instance statement only in YANG 1.1 modules.", "Path \"/mm:ref\".");
+    CHECK_LOG_CTX("Leafref type \"mytype\" can be restricted by require-instance statement only in YANG 1.1 modules.",
+            "/mm:ref", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module nn {namespace urn:nn;prefix nn;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}\n"
             "leaf address {type leafref{\n path \"/interface[name is current()/../ifname]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"nn\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid character 0x69 ('i'), perhaps \"name\" is supposed to be a function call.", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"nn\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid character 0x69 ('i'), perhaps \"name\" is supposed to be a function call.", NULL, 5);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module oo {namespace urn:oo;prefix oo;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}\n"
             "leaf address {type leafref{\n path \"/interface[name=current()/../ifname/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"oo\" failed.", NULL);
-    CHECK_LOG_CTX("Unexpected XPath expression end.", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"oo\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Unexpected XPath expression end.", NULL, 5);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module pp {namespace urn:pp;prefix pp;"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
             "leaf ifname{type leafref{ path \"../interface/name\";}}"
             "leaf address {type leafref{ path \"/interface[x:name=current()/../ifname]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("No module connected with the prefix \"x\" found (prefix format schema stored mapping).",
-            "Schema location \"/pp:address\".");
+    CHECK_LOG_CTX("No module connected with the prefix \"x\" found (prefix format schema stored mapping).", "/pp:address", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module qq {namespace urn:qq;prefix qq;"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
             "leaf ifname{type leafref{ path \"../interface/name\";}}"
             "leaf address {type leafref{ path \"/interface[id=current()/../ifname]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Not found node \"id\" in path.", "Schema location \"/qq:address\".");
+    CHECK_LOG_CTX("Not found node \"id\" in path.", "/qq:address", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module rr {namespace urn:rr;prefix rr;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
             "leaf address {type leafref{ path \"/interface[name=current() /  .. / ifname][name=current()/../test]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"rr\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate predicate key \"name\" in path.", "Line number 4.");
+    CHECK_LOG_CTX("Parsing module \"rr\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate predicate key \"name\" in path.", NULL, 4);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ss {namespace urn:ss;prefix ss;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
             "leaf address {type leafref{ path \"/interface[name = ../ifname]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"ss\" failed.", NULL);
-    CHECK_LOG_CTX("Unexpected XPath token \"..\" (\"../ifname]/ip\"), expected \"FunctionName\".", "Line number 4.");
+    CHECK_LOG_CTX("Parsing module \"ss\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Unexpected XPath token \"..\" (\"../ifname]/ip\"), expected \"FunctionName\".", NULL, 4);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module tt {namespace urn:tt;prefix tt;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
             "leaf address {type leafref{ path \"/interface[name = current()../ifname]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"tt\" failed.", NULL);
-    CHECK_LOG_CTX("Unexpected XPath token \"..\" (\"../ifname]/ip\"), expected \"Operator(Path)\".", "Line number 4.");
+    CHECK_LOG_CTX("Parsing module \"tt\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Unexpected XPath token \"..\" (\"../ifname]/ip\"), expected \"Operator(Path)\".", NULL, 4);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module uu {namespace urn:uu;prefix uu;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
             "leaf address {type leafref{ path \"/interface[name = current()/..ifname]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"uu\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid character 'i'[31] of expression '/interface[name = current()/..ifname]/ip'.", "Line number 4.");
+    CHECK_LOG_CTX("Parsing module \"uu\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid character 'i'[31] of expression '/interface[name = current()/..ifname]/ip'.", NULL, 4);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module vv {namespace urn:vv;prefix vv;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
             "leaf address {type leafref{ path \"/interface[name = current()/ifname]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"vv\" failed.", NULL);
-    CHECK_LOG_CTX("Unexpected XPath token \"NameTest\" (\"ifname]/ip\"), expected \"..\".", "Line number 4.");
+    CHECK_LOG_CTX("Parsing module \"vv\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Unexpected XPath token \"NameTest\" (\"ifname]/ip\"), expected \"..\".", NULL, 4);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ww {namespace urn:ww;prefix ww;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
             "leaf address {type leafref{ path \"/interface[name = current()/../]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"ww\" failed.", NULL);
-    CHECK_LOG_CTX("Unexpected XPath token \"]\" (\"]/ip\"), expected \"NameTest\".", "Line number 4.");
+    CHECK_LOG_CTX("Parsing module \"ww\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Unexpected XPath token \"]\" (\"]/ip\"), expected \"NameTest\".", NULL, 4);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module xx {namespace urn:xx;prefix xx;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
             "leaf address {type leafref{ path \"/interface[name = current()/../#node]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Parsing module \"xx\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid character '#'[32] of expression '/interface[name = current()/../#node]/ip'.", "Line number 4.");
+    CHECK_LOG_CTX("Parsing module \"xx\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid character '#'[32] of expression '/interface[name = current()/../#node]/ip'.", NULL, 4);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module yy {namespace urn:yy;prefix yy;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}\n"
             "leaf address {type leafref{ path \"/interface[name=current()/../x:ifname]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("No module connected with the prefix \"x\" found (prefix format schema stored mapping).",
-            "Schema location \"/yy:address\".");
+    CHECK_LOG_CTX("No module connected with the prefix \"x\" found (prefix format schema stored mapping).", "/yy:address", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module zz {namespace urn:zz;prefix zz;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}\n"
             "leaf address {type leafref{ path \"/interface[name=current()/../xxx]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Not found node \"xxx\" in path.", "Schema location \"/zz:address\".");
+    CHECK_LOG_CTX("Not found node \"xxx\" in path.", "/zz:address", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module zza {namespace urn:zza;prefix zza;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}container c;\n"
             "leaf address {type leafref{ path \"/interface[name=current()/../c]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Leaf expected instead of container \"c\" in leafref predicate in path.", "Schema location \"/zza:address\".");
+    CHECK_LOG_CTX("Leaf expected instead of container \"c\" in leafref predicate in path.", "/zza:address", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module zzb {namespace urn:zzb;prefix zzb;\n"
             "list interface{key name;leaf name{type string;}leaf ip {type string;}container c;}\n"
             "leaf ifname{type leafref{ path \"../interface/name\";}}\n"
             "leaf address {type leafref{ path \"/interface[c=current()/../ifname]/ip\";}}}",
             LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Key expected instead of container \"c\" in path.", "Schema location \"/zzb:address\".");
+    CHECK_LOG_CTX("Key expected instead of container \"c\" in path.", "/zzb:address", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module zzc {namespace urn:zzc;prefix zzc;\n"
             "leaf source {type leafref {path \"../target\";}default true;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Not found node \"target\" in path.", "Schema location \"/zzc:source\".");
+    CHECK_LOG_CTX("Not found node \"target\" in path.", "/zzc:source", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module zzd {namespace urn:zzd;prefix zzd;\n"
             "leaf source {type leafref {path \"../target\";}default true;}\n"
             "leaf target {type uint8;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid default - value does not fit the type (Invalid type uint8 value \"true\".).",
-            "Schema location \"/zzd:source\".");
+    CHECK_LOG_CTX("Invalid default - value does not fit the type (Invalid type uint8 value \"true\".).", "/zzd:source", 0);
 
     /* circular chain */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aaa {namespace urn:aaa;prefix aaa;\n"
@@ -2085,7 +2077,7 @@
             "leaf ref2 {type leafref {path /ref3;}}\n"
             "leaf ref3 {type leafref {path /ref4;}}\n"
             "leaf ref4 {type leafref {path /ref1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid leafref path \"/ref1\" - circular chain of leafrefs detected.", "Schema location \"/aaa:ref4\".");
+    CHECK_LOG_CTX("Invalid leafref path \"/ref1\" - circular chain of leafrefs detected.", "/aaa:ref4", 0);
 }
 
 static void
@@ -2094,11 +2086,11 @@
     /* invalid */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;"
             "leaf l {type empty; default x;}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid default - value does not fit the type (Invalid empty value length 1.).", "Schema location \"/aa:l\".");
+    CHECK_LOG_CTX("Invalid default - value does not fit the type (Invalid empty value length 1.).", "/aa:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;typedef mytype {type empty; default x;}"
             "leaf l {type mytype;}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Invalid type \"mytype\" - \"empty\" type must not have a default value (x).", "Path \"/bb:l\".");
+    CHECK_LOG_CTX("Invalid type \"mytype\" - \"empty\" type must not have a default value (x).", "/bb:l", 0);
 }
 
 static void
@@ -2152,25 +2144,26 @@
     /* invalid unions */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;typedef mytype {type union;}"
             "leaf l {type mytype;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Missing type substatement for union type mytype.", "Path \"/aa:l\".");
+    CHECK_LOG_CTX("Missing type substatement for union type mytype.", "/aa:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;leaf l {type union;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Missing type substatement for union type.", "Path \"/bb:l\".");
+    CHECK_LOG_CTX("Missing type substatement for union type.", "/bb:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:cc;prefix cc;typedef mytype {type union{type int8; type string;}}"
             "leaf l {type mytype {type string;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid type substatement for the type not directly derived from union built-in type.", "Path \"/cc:l\".");
+    CHECK_LOG_CTX("Invalid type substatement for the type not directly derived from union built-in type.", "/cc:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd {namespace urn:dd;prefix dd;typedef mytype {type union{type int8; type string;}}"
             "typedef mytype2 {type mytype {type string;}}leaf l {type mytype2;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid type substatement for the type \"mytype2\" not directly derived from union built-in type.", "Path \"/dd:l\".");
+    CHECK_LOG_CTX("Invalid type substatement for the type \"mytype2\" not directly derived from union built-in type.",
+            "/dd:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee;typedef mytype {type union{type mytype; type string;}}"
             "leaf l {type mytype;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid \"mytype\" type reference - circular chain of types detected.", "Path \"/ee:l\".");
+    CHECK_LOG_CTX("Invalid \"mytype\" type reference - circular chain of types detected.", "/ee:l", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ef {namespace urn:ef;prefix ef;typedef mytype {type mytype2;}"
             "typedef mytype2 {type mytype;} leaf l {type mytype;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid \"mytype\" type reference - circular chain of types detected.", "Path \"/ef:l\".");
+    CHECK_LOG_CTX("Invalid \"mytype\" type reference - circular chain of types detected.", "/ef:l", 0);
 }
 
 static void
@@ -2417,21 +2410,21 @@
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;"
             "container c {status deprecated; leaf l {status current; type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Status \"current\" of \"l\" is in conflict with \"deprecated\" status of parent \"c\".", "Path \"/aa:c/l\".");
+    CHECK_LOG_CTX("Status \"current\" of \"l\" is in conflict with \"deprecated\" status of parent \"c\".", "/aa:c/l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;"
             "container c {status obsolete; leaf l {status current; type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Status \"current\" of \"l\" is in conflict with \"obsolete\" status of parent \"c\".", "Path \"/bb:c/l\".");
+    CHECK_LOG_CTX("Status \"current\" of \"l\" is in conflict with \"obsolete\" status of parent \"c\".", "/bb:c/l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:cc;prefix cc;"
             "container c {status obsolete; leaf l {status deprecated; type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Status \"deprecated\" of \"l\" is in conflict with \"obsolete\" status of parent \"c\".", "Path \"/cc:c/l\".");
+    CHECK_LOG_CTX("Status \"deprecated\" of \"l\" is in conflict with \"obsolete\" status of parent \"c\".", "/cc:c/l", 0);
 
     /* just a warning */
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:dd;prefix d;"
             "container c {leaf l {status obsolete; type string;}}"
             "container d {leaf m {when \"../../c/l\"; type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("When condition \"../../c/l\" may be referencing deprecated node \"l\".", NULL);
+    CHECK_LOG_CTX("When condition \"../../c/l\" may be referencing deprecated node \"l\".", NULL, 0);
 }
 
 static void
@@ -2440,24 +2433,23 @@
     /* result ok, but a warning about not used locally scoped grouping printed */
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module a {namespace urn:a;prefix a; grouping grp1 {leaf a1 {type string;}}"
             "container a {leaf x {type string;} grouping grp2 {leaf a2 {type string;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Locally scoped grouping \"grp2\" not used.", NULL);
-    UTEST_LOG_CLEAN;
+    CHECK_LOG_CTX("Locally scoped grouping \"grp2\" not used.", NULL, 0);
 
     /* result ok - when statement or leafref target must be checked only at the place where the grouping is really instantiated */
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module b {namespace urn:b;prefix b; grouping grp {"
             "leaf ref {type leafref {path \"../name\";}}"
             "leaf cond {type string; when \"../name = 'specialone'\";}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
 
     /* invalid - error in a non-instantiated grouping */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;"
             "grouping grp {leaf x {type leafref;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Missing path substatement for leafref type.", "Path \"/aa:{grouping='grp'}/x\".");
+    CHECK_LOG_CTX("Missing path substatement for leafref type.", "/aa:{grouping='grp'}/x", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;"
             "container a {grouping grp {leaf x {type leafref;}}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Missing path substatement for leafref type.", "Path \"/aa:a/{grouping='grp'}/x\".");
-    CHECK_LOG_CTX("Locally scoped grouping \"grp\" not used.", NULL);
+    CHECK_LOG_CTX("Missing path substatement for leafref type.", "/aa:a/{grouping='grp'}/x", 0);
+    CHECK_LOG_CTX("Locally scoped grouping \"grp\" not used.", NULL, 0);
 
     /* config check */
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "module z1 {namespace urn:z1;prefix z1;"
@@ -2536,7 +2528,6 @@
     assert_int_equal(2, leaf->when[0]->refcount);
     assert_null(leaf->when[0]->context);
 
-    UTEST_LOG_CLEAN;
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module c {namespace urn:c;prefix c;"
             "grouping grp {leaf l {type string;}leaf k {type string; status obsolete;}}"
             "uses grp {status deprecated;}}", LYS_IN_YANG, &mod));
@@ -2546,7 +2537,7 @@
     assert_int_equal(LYS_LEAF, mod->compiled->data->next->nodetype);
     assert_string_equal("k", mod->compiled->data->next->name);
     assert_true(LYS_STATUS_OBSLT & mod->compiled->data->next->flags);
-    CHECK_LOG(NULL, NULL);     /* no warning about inheriting deprecated flag from uses */
+    CHECK_LOG_CTX(NULL, NULL, 0);     /* no warning about inheriting deprecated flag from uses */
 
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module d {namespace urn:d;prefix d; grouping grp {container g;}"
             "container top {uses grp {augment g {leaf x {type int8;}}}}}", LYS_IN_YANG, &mod));
@@ -2628,53 +2619,56 @@
 
     /* invalid */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;uses missinggrp;}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Grouping \"missinggrp\" referenced by a uses statement not found.", "Path \"/aa:{uses='missinggrp'}\".");
+    CHECK_LOG_CTX("Grouping \"missinggrp\" referenced by a uses statement not found.", "/aa:{uses='missinggrp'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;uses grp;"
             "grouping grp {leaf a{type string;}uses grp1;}"
             "grouping grp1 {leaf b {type string;}uses grp2;}"
             "grouping grp2 {leaf c {type string;}uses grp;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Grouping \"grp\" references itself through a uses statement.", "Path \"/bb:{uses='grp'}/{uses='grp1'}/{uses='grp2'}/{uses='grp'}\".");
+    CHECK_LOG_CTX("Grouping \"grp\" references itself through a uses statement.",
+            "/bb:{uses='grp'}/{uses='grp1'}/{uses='grp2'}/{uses='grp'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:cc;prefix cc;uses a:missingprefix;}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid prefix used for grouping \"a:missingprefix\" reference.", "Path \"/cc:{uses='a:missingprefix'}\".");
+    CHECK_LOG_CTX("Invalid prefix used for grouping \"a:missingprefix\" reference.", "/cc:{uses='a:missingprefix'}", 0);
 
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module dd {namespace urn:dd;prefix dd;grouping grp{leaf a{type string;}}"
             "leaf a {type string;}uses grp;}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "Path \"/dd:{uses='grp'}/dd:a\".");
+    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.",
+            "/dd:{uses='grp'}/dd:a", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee;grouping grp {leaf l {type string; status deprecated;}}"
             "uses grp {status obsolete;}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Inherited schema-only status \"obsolete\" is in conflict with \"deprecated\" status of \"l\".",
-            "Path \"/ee:{uses='grp'}/ee:l\".");
+            "/ee:{uses='grp'}/ee:l", 0);
 
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module ff {namespace urn:ff;prefix ff;grouping grp {leaf l {type string;}}"
             "leaf l {type int8;}uses grp;}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Duplicate identifier \"l\" of data definition/RPC/action/notification statement.", "Path \"/ff:{uses='grp'}/ff:l\".");
+    CHECK_LOG_CTX("Duplicate identifier \"l\" of data definition/RPC/action/notification statement.",
+            "/ff:{uses='grp'}/ff:l", 0);
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module fg {namespace urn:fg;prefix fg;grouping grp {leaf m {type string;}}"
             "uses grp;leaf m {type int8;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Duplicate identifier \"m\" of data definition/RPC/action/notification statement.", "Path \"/fg:m\".");
+    CHECK_LOG_CTX("Duplicate identifier \"m\" of data definition/RPC/action/notification statement.", "/fg:m", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg {namespace urn:gg;prefix gg; grouping grp {container g;}"
             "leaf g {type string;}"
             "container top {uses grp {augment /g {leaf x {type int8;}}}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid descendant-schema-nodeid value \"/g\" - name test expected instead of \"/\".",
-            "Path \"/gg:top/{uses='grp'}/{augment='/g'}\".");
+            "/gg:top/{uses='grp'}/{augment='/g'}", 0);
 
     assert_int_equal(LY_ENOTFOUND, lys_parse_mem(UTEST_LYCTX, "module hh {yang-version 1.1;namespace urn:hh;prefix hh;"
             "grouping grp {notification g { description \"super g\";}}"
             "container top {notification h; uses grp {refine h {description \"ultra h\";}}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Refine(s) target node \"h\" in grouping \"grp\" was not found.", "Path \"/hh:top/{uses='grp'}\".");
+    CHECK_LOG_CTX("Refine(s) target node \"h\" in grouping \"grp\" was not found.", "/hh:top/{uses='grp'}", 0);
 
     assert_int_equal(LY_ENOTFOUND, lys_parse_mem(UTEST_LYCTX, "module ii {yang-version 1.1;namespace urn:ii;prefix ii;"
             "grouping grp {action g { description \"super g\";}}"
             "container top {action i; uses grp {refine i {description \"ultra i\";}}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Refine(s) target node \"i\" in grouping \"grp\" was not found.", "Path \"/ii:top/{uses='grp'}\".");
+    CHECK_LOG_CTX("Refine(s) target node \"i\" in grouping \"grp\" was not found.", "/ii:top/{uses='grp'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj {yang-version 1.1;namespace urn:jj;prefix jj;"
             "grouping grp {leaf j { when \"1\"; type invalid;}}"
             "container top {uses grp;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Referenced type \"invalid\" not found.", "Path \"/jj:top/{uses='grp'}/j\".");
+    CHECK_LOG_CTX("Referenced type \"invalid\" not found.", "/jj:top/{uses='grp'}/j", 0);
 }
 
 static void
@@ -2777,70 +2771,70 @@
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;import grp {prefix g;}"
             "uses g:grp {refine c {default hello;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid refine of container node - it is not possible to replace \"default\" property.",
-            "Path \"/aa:{uses='g:grp'}/aa:c/{refine='c'}\".");
+            "/aa:{uses='g:grp'}/aa:c/{refine='c'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;import grp {prefix g;}"
             "uses g:grp {refine c/l {default hello; default world;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid refine of leaf with too many (2) default properties.", "Path \"/bb:{uses='g:grp'}/bb:c/l/{refine='c/l'}\".");
+    CHECK_LOG_CTX("Invalid refine of leaf with too many (2) default properties.", "/bb:{uses='g:grp'}/bb:c/l/{refine='c/l'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:cc;prefix cc;import grp {prefix g;}"
             "uses g:grp {refine c/ll {default hello; default world;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid refine of default in leaf-list - the default statement is allowed only in YANG 1.1 modules.",
-            "Path \"/cc:{uses='g:grp'}/cc:c/ll/{refine='c/ll'}\".");
+            "/cc:{uses='g:grp'}/cc:c/ll/{refine='c/ll'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd {namespace urn:dd;prefix dd;import grp {prefix g;}"
             "uses g:grp {refine c/ll {mandatory true;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid refine of leaf-list node - it is not possible to replace \"mandatory\" property.",
-            "Path \"/dd:{uses='g:grp'}/dd:c/ll/{refine='c/ll'}\".");
+            "/dd:{uses='g:grp'}/dd:c/ll/{refine='c/ll'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee;import grp {prefix g;}"
             "uses g:grp {refine c/l {mandatory true;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/ee:{uses='g:grp'}/ee:c/l\".");
-    CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "Path \"/ee:{uses='g:grp'}/ee:c/l\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ee:{uses='g:grp'}/ee:c/l", 0);
+    CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "/ee:{uses='g:grp'}/ee:c/l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ef {namespace urn:ef;prefix ef;import grp {prefix g;}"
             "uses g:grp {refine c/ch {mandatory true;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/ef:{uses='g:grp'}/ef:c/ch\".");
-    CHECK_LOG_CTX("Invalid mandatory choice with a default case.", "Path \"/ef:{uses='g:grp'}/ef:c/ch\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ef:{uses='g:grp'}/ef:c/ch", 0);
+    CHECK_LOG_CTX("Invalid mandatory choice with a default case.", "/ef:{uses='g:grp'}/ef:c/ch", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff {namespace urn:ff;prefix ff;import grp {prefix g;}"
             "uses g:grp {refine c/ch/ca/ca {mandatory true;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Mandatory node \"ca\" under the default case \"ca\".", "Path \"/ff:{uses='g:grp'}/ff:c/ch\".");
+    CHECK_LOG_CTX("Mandatory node \"ca\" under the default case \"ca\".", "/ff:{uses='g:grp'}/ff:c/ch", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg {namespace urn:gg;prefix gg;import grp {prefix g;}"
             "uses g:grp {refine c/x {default hello;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/gg:{uses='g:grp'}/gg:c/x\".");
-    CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "Path \"/gg:{uses='g:grp'}/gg:c/x\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/gg:{uses='g:grp'}/gg:c/x", 0);
+    CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "/gg:{uses='g:grp'}/gg:c/x", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module hh {namespace urn:hh;prefix hh;import grp {prefix g;}"
             "uses g:grp {refine c/c/l {config true;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/hh:{uses='g:grp'}/hh:c/c/l\".");
-    CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "Path \"/hh:{uses='g:grp'}/hh:c/c/l\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/hh:{uses='g:grp'}/hh:c/c/l", 0);
+    CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "/hh:{uses='g:grp'}/hh:c/c/l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ii {namespace urn:ii;prefix ii;grouping grp {leaf l {type string; status deprecated;}}"
             "uses grp {status obsolete;}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Inherited schema-only status \"obsolete\" is in conflict with \"deprecated\" status of \"l\".",
-            "Path \"/ii:{uses='grp'}/ii:l\".");
+            "/ii:{uses='grp'}/ii:l", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj {namespace urn:jj;prefix jj;import grp {prefix g;}"
             "uses g:grp {refine c/x {presence nonsence;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid refine of leaf node - it is not possible to replace \"presence\" property.",
-            "Path \"/jj:{uses='g:grp'}/jj:c/x/{refine='c/x'}\".");
+            "/jj:{uses='g:grp'}/jj:c/x/{refine='c/x'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk {namespace urn:kk;prefix kk;import grp {prefix g;}"
             "uses g:grp {refine c/ch {must 1;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid refine of choice node - it is not possible to add \"must\" property.",
-            "Path \"/kk:{uses='g:grp'}/kk:c/ch/{refine='c/ch'}\".");
+            "/kk:{uses='g:grp'}/kk:c/ch/{refine='c/ch'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ll {namespace urn:ll;prefix ll;import grp {prefix g;}"
             "uses g:grp {refine c/x {min-elements 1;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid refine of leaf node - it is not possible to replace \"min-elements\" property.",
-            "Path \"/ll:{uses='g:grp'}/ll:c/x/{refine='c/x'}\".");
+            "/ll:{uses='g:grp'}/ll:c/x/{refine='c/x'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm {namespace urn:mm;prefix mm;import grp {prefix g;}"
             "uses g:grp {refine c/ll {min-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/mm:{uses='g:grp'}/mm:c/ll\".");
-    CHECK_LOG_CTX("The default statement is present on leaf-list with a nonzero min-elements.", "Path \"/mm:{uses='g:grp'}/mm:c/ll\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm:{uses='g:grp'}/mm:c/ll", 0);
+    CHECK_LOG_CTX("The default statement is present on leaf-list with a nonzero min-elements.", "/mm:{uses='g:grp'}/mm:c/ll", 0);
 }
 
 static void
@@ -2962,7 +2956,6 @@
     assert_null(cont->notifs->next);
 
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, NULL, NULL);
-    UTEST_LOG_CLEAN;
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module k {namespace urn:k; prefix k;yang-version 1.1;"
             "feature f;"
             "container c {if-feature f; leaf a {type string;}}}", LYS_IN_YANG, &mod));
@@ -2971,7 +2964,7 @@
             "augment /k:c {leaf b {type string;}}"
             "leaf c {when \"/k:c/l:b\"; type string;}}", LYS_IN_YANG, NULL));
     /* no xpath warning expected */
-    CHECK_LOG(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
     assert_null(mod->compiled->data);
 
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module m {namespace urn:m;prefix m;yang-version 1.1;"
@@ -2983,41 +2976,42 @@
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; container c {leaf a {type string;}}"
             "augment /x/ {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid absolute-schema-nodeid value \"/x/\" - unexpected end of expression.", "Path \"/aa:{augment='/x/'}\".");
+    CHECK_LOG_CTX("Invalid absolute-schema-nodeid value \"/x/\" - unexpected end of expression.", "/aa:{augment='/x/'}", 0);
 
     assert_int_equal(LY_ENOTFOUND, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; container c {leaf a {type string;}}"
             "augment /x {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Augment target node \"/x\" from module \"aa\" was not found.", "Path \"/aa:{augment='/x'}\".");
+    CHECK_LOG_CTX("Augment target node \"/x\" from module \"aa\" was not found.", "/aa:{augment='/x'}", 0);
 
     assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb; container c {leaf a {type string;}}"
             "augment /c {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "Path \"/bb:{augment='/c'}/a\".");
+    CHECK_LOG_CTX("Duplicate identifier \"a\" of data definition/RPC/action/notification statement.", "/bb:{augment='/c'}/a", 0);
 
     assert_int_equal(LY_ENOTFOUND, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:cc;prefix cc; container c {leaf a {type string;}}"
             "augment /c/a {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Augment target node \"/c/a\" from module \"cc\" was not found.", "Path \"/cc:{augment='/c/a'}\".");
+    CHECK_LOG_CTX("Augment target node \"/c/a\" from module \"cc\" was not found.", "/cc:{augment='/c/a'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd {namespace urn:dd;prefix dd; container c {leaf a {type string;}}"
             "augment /c {case b {leaf d {type int8;}}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid augment of container node which is not allowed to contain case node \"b\".", "Path \"/dd:{augment='/c'}\".");
+    CHECK_LOG_CTX("Invalid augment of container node which is not allowed to contain case node \"b\".", "/dd:{augment='/c'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee; import himp {prefix hi;}"
             "augment /hi:top {container c {leaf d {mandatory true; type int8;}}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid augment adding mandatory node \"c\" without making it conditional via when statement.", "Path \"/ee:{augment='/hi:top'}\".");
+    CHECK_LOG_CTX("Invalid augment adding mandatory node \"c\" without making it conditional via when statement.",
+            "/ee:{augment='/hi:top'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff {namespace urn:ff;prefix ff; container top;"
             "augment ../top {leaf x {type int8;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid absolute-schema-nodeid value \"../top\" - \"/\" expected instead of \"..\".", "Path \"/ff:{augment='../top'}\".");
+    CHECK_LOG_CTX("Invalid absolute-schema-nodeid value \"../top\" - \"/\" expected instead of \"..\".", "/ff:{augment='../top'}", 0);
 
     assert_int_equal(LY_ENOTFOUND, lys_parse_mem(UTEST_LYCTX, "module gg {namespace urn:gg;prefix gg; rpc func;"
             "augment /func {leaf x {type int8;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Augment target node \"/func\" from module \"gg\" was not found.", "Path \"/gg:{augment='/func'}\".");
+    CHECK_LOG_CTX("Augment target node \"/func\" from module \"gg\" was not found.", "/gg:{augment='/func'}", 0);
 
     assert_int_equal(LY_ENOTFOUND, lys_parse_mem(UTEST_LYCTX, "module hh {namespace urn:hh;prefix hh;import himp {prefix hi;}"
             "augment /hi:func/input {leaf x {type string;}}"
             "augment /hi:func/output {leaf y {type string;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Augment target node \"/hi:func/input\" from module \"hh\" was not found.", "Path \"/hh:{augment='/hi:func/input'}\".");
-    CHECK_LOG_CTX("Augment target node \"/hi:func/output\" from module \"hh\" was not found.", "Path \"/hh:{augment='/hi:func/output'}\".");
+    CHECK_LOG_CTX("Augment target node \"/hi:func/input\" from module \"hh\" was not found.", "/hh:{augment='/hi:func/input'}", 0);
+    CHECK_LOG_CTX("Augment target node \"/hi:func/output\" from module \"hh\" was not found.", "/hh:{augment='/hi:func/output'}", 0);
 }
 
 static void
@@ -3473,219 +3467,240 @@
 
     assert_int_equal(LY_ENOTFOUND, lys_parse_mem(UTEST_LYCTX, "module aa1 {namespace urn:aa1;prefix aa1;import a {prefix a;}"
             "deviation /a:top/a:z {deviate not-supported;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Deviation(s) target node \"/a:top/a:z\" from module \"aa1\" was not found.", "Path \"/a:{deviation='/a:top/a:z'}\".");
+    CHECK_LOG_CTX("Deviation(s) target node \"/a:top/a:z\" from module \"aa1\" was not found.",
+            "/a:{deviation='/a:top/a:z'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa2 {namespace urn:aa2;prefix aa2;import a {prefix a;}"
             "deviation /a:top/a:a {deviate not-supported;}"
             "deviation /a:top/a:a {deviate add {default error;}}}", LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("Multiple deviations of \"/a:top/a:a\" with one of them being \"not-supported\".", "Path \"/aa2:{deviation='/a:top/a:a'}\".");
+    CHECK_LOG_CTX("Multiple deviations of \"/a:top/a:a\" with one of them being \"not-supported\".",
+            "/aa2:{deviation='/a:top/a:a'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;import a {prefix a;}"
             "deviation a:top/a:a {deviate not-supported;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid absolute-schema-nodeid value \"a:top/a:a\" - \"/\" expected instead of \"a:top\".", "Path \"/bb:{deviation='a:top/a:a'}\".");
+    CHECK_LOG_CTX("Invalid absolute-schema-nodeid value \"a:top/a:a\" - \"/\" expected instead of \"a:top\".",
+            "/bb:{deviation='a:top/a:a'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cc {namespace urn:cc;prefix cc; container c;"
             "deviation /c {deviate add {units meters;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to add \"units\" property.", "Path \"/cc:{deviation='/c'}\".");
+    CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to add \"units\" property.",
+            "/cc:{deviation='/c'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module cd {namespace urn:cd;prefix cd; leaf c {type string; units centimeters;}"
             "deviation /c {deviate add {units meters;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation adding \"units\" property which already exists (with value \"centimeters\").", "Path \"/cd:{deviation='/c'}\".");
+    CHECK_LOG_CTX("Invalid deviation adding \"units\" property which already exists (with value \"centimeters\").",
+            "/cd:{deviation='/c'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd1 {namespace urn:dd1;prefix dd1; container c;"
             "deviation /c {deviate delete {units meters;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to delete \"units\" property.", "Path \"/dd1:{deviation='/c'}\".");
+    CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to delete \"units\" property.",
+            "/dd1:{deviation='/c'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd2 {namespace urn:dd2;prefix dd2; leaf c {type string;}"
             "deviation /c {deviate delete {units meters;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation deleting \"units\" property \"meters\" which is not present.", "Path \"/dd2:{deviation='/c'}\".");
+    CHECK_LOG_CTX("Invalid deviation deleting \"units\" property \"meters\" which is not present.",
+            "/dd2:{deviation='/c'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module dd3 {namespace urn:dd3;prefix dd3; leaf c {type string; units centimeters;}"
             "deviation /c {deviate delete {units meters;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation deleting \"units\" property \"meters\" which does not match the target's property value \"centimeters\".",
-            "Path \"/dd3:{deviation='/c'}\".");
+            "/dd3:{deviation='/c'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee1 {namespace urn:ee1;prefix ee1; container c;"
             "deviation /c {deviate replace {units meters;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to replace \"units\" property.", "Path \"/ee1:{deviation='/c'}\".");
+    CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to replace \"units\" property.",
+            "/ee1:{deviation='/c'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee2 {namespace urn:ee2;prefix ee2; leaf c {type string;}"
             "deviation /c {deviate replace {units meters;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation replacing \"units\" property \"meters\" which is not present.", "Path \"/ee2:{deviation='/c'}\".");
+    CHECK_LOG_CTX("Invalid deviation replacing \"units\" property \"meters\" which is not present.",
+            "/ee2:{deviation='/c'}", 0);
 
     /* the default is already deleted in /e:a byt module f */
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff1 {namespace urn:ff1;prefix ff1; import e {prefix e;}"
             "deviation /e:a {deviate delete {default x:aa;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation deleting \"default\" property \"x:aa\" which is not present.", "Path \"/ff1:{deviation='/e:a'}\".");
+    CHECK_LOG_CTX("Invalid deviation deleting \"default\" property \"x:aa\" which is not present.",
+            "/ff1:{deviation='/e:a'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff3 {namespace urn:ff3;prefix ff3; import e {prefix e;}"
             "deviation /e:b {deviate delete {default e:b;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation deleting \"default\" property \"e:b\" which does not match the target's property value \"x:ba\".",
-            "Path \"/ff3:{deviation='/e:b'}\".");
+            "/ff3:{deviation='/e:b'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff5 {namespace urn:ff5;prefix ff5; anyxml a;"
             "deviation /a {deviate delete {default x;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation of anyxml node - it is not possible to delete \"default\" property.", "Path \"/ff5:{deviation='/a'}\".");
+    CHECK_LOG_CTX("Invalid deviation of anyxml node - it is not possible to delete \"default\" property.",
+            "/ff5:{deviation='/a'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff6 {namespace urn:ff6;prefix ff6; import e {prefix e;}"
             "deviation /e:c {deviate delete {default hi;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation deleting \"default\" property \"hi\" which does not match the target's property value \"hello\".",
-            "Path \"/ff6:{deviation='/e:c'}\".");
+            "/ff6:{deviation='/e:c'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff7 {namespace urn:ff7;prefix ff7; import e {prefix e;}"
             "deviation /e:d {deviate delete {default hi;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation deleting \"default\" property \"hi\" which does not match any of the target's property values.",
-            "Path \"/ff7:{deviation='/e:d'}\".");
+            "/ff7:{deviation='/e:d'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg1 {namespace urn:gg1;prefix gg1; import e {prefix e;}"
             "deviation /e:b {deviate add {default e:a;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation adding \"default\" property which already exists (with value \"x:ba\").", "Path \"/gg1:{deviation='/e:b'}\".");
+    CHECK_LOG_CTX("Invalid deviation adding \"default\" property which already exists (with value \"x:ba\").",
+            "/gg1:{deviation='/e:b'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg2 {namespace urn:gg2;prefix gg2; import e {prefix e;}"
             "deviation /e:a {deviate add {default x:a;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/e:a\".");
-    CHECK_LOG_CTX("Default case prefix \"x\" not found in imports of \"gg2\".", "Path \"/e:a\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/e:a", 0);
+    CHECK_LOG_CTX("Default case prefix \"x\" not found in imports of \"gg2\".", "/e:a", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg3 {namespace urn:gg3;prefix gg3; import e {prefix e;}"
             "deviation /e:a {deviate add {default a;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/e:a\".");
-    CHECK_LOG_CTX("Default case \"a\" not found.", "Path \"/e:a\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/e:a", 0);
+    CHECK_LOG_CTX("Default case \"a\" not found.", "/e:a", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg4 {namespace urn:gg4;prefix gg4; import e {prefix e;}"
             "deviation /e:c {deviate add {default hi;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation adding \"default\" property which already exists (with value \"hello\").", "Path \"/gg4:{deviation='/e:c'}\".");
+    CHECK_LOG_CTX("Invalid deviation adding \"default\" property which already exists (with value \"hello\").",
+            "/gg4:{deviation='/e:c'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg4 {namespace urn:gg4;prefix gg4; import e {prefix e;}"
             "deviation /e:a {deviate add {default e:ac;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/e:a\".");
-    CHECK_LOG_CTX("Mandatory node \"ac\" under the default case \"e:ac\".", "Path \"/e:a\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/e:a", 0);
+    CHECK_LOG_CTX("Mandatory node \"ac\" under the default case \"e:ac\".", "/e:a", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg5 {namespace urn:gg5;prefix gg5; leaf x {type string; mandatory true;}"
             "deviation /x {deviate add {default error;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/gg5:{deviation='/x'}\".");
-    CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "Path \"/gg5:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/gg5:{deviation='/x'}", 0);
+    CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "/gg5:{deviation='/x'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module hh1 {yang-version 1.1; namespace urn:hh1;prefix hh1; import e {prefix e;}"
             "deviation /e:d {deviate replace {default hi;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation of leaf-list node - it is not possible to replace \"default\" property.",
-            "Path \"/hh1:{deviation='/e:d'}\".");
+            "/hh1:{deviation='/e:d'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ii1 {namespace urn:ii1;prefix ii1; import i {prefix i;}"
             "deviation /i:l1 {deviate delete {unique x;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation deleting \"unique\" property \"x\" which does not match any of the target's property values.",
-            "Path \"/ii1:{deviation='/i:l1'}\".");
+            "/ii1:{deviation='/i:l1'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ii2 {namespace urn:ii2;prefix ii2; import i {prefix i;} leaf x { type string;}"
             "deviation /i:l2 {deviate delete {unique d;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation deleting \"unique\" property \"d\" which does not match any of the target's property values.",
-            "Path \"/ii2:{deviation='/i:l2'}\".");
+            "/ii2:{deviation='/i:l2'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ii3 {namespace urn:ii3;prefix ii3; leaf x { type string;}"
             "deviation /x {deviate delete {unique d;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation of leaf node - it is not possible to delete \"unique\" property.", "Path \"/ii3:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation of leaf node - it is not possible to delete \"unique\" property.", "/ii3:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ii4 {namespace urn:ii4;prefix ii4; leaf x { type string;}"
             "deviation /x {deviate add {unique d;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation of leaf node - it is not possible to add \"unique\" property.", "Path \"/ii4:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation of leaf node - it is not possible to add \"unique\" property.", "/ii4:{deviation='/x'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj1 {namespace urn:jj1;prefix jj1; choice ch {case a {leaf a{type string;}}}"
             "deviation /ch/a {deviate add {config false;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation of case node - it is not possible to add \"config\" property.", "Path \"/jj1:{deviation='/ch/a'}\".");
+    CHECK_LOG_CTX("Invalid deviation of case node - it is not possible to add \"config\" property.", "/jj1:{deviation='/ch/a'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj2 {namespace urn:jj2;prefix jj2; container top {config false; leaf x {type string;}}"
             "deviation /top/x {deviate add {config true;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/jj2:{deviation='/top/x'}\".");
-    CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "Path \"/jj2:{deviation='/top/x'}\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/jj2:{deviation='/top/x'}", 0);
+    CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "/jj2:{deviation='/top/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj4 {namespace urn:jj4;prefix jj4; choice ch {case a {leaf a{type string;}}}"
             "deviation /ch/a {deviate replace {config false;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation of case node - it is not possible to replace \"config\" property.", "Path \"/jj4:{deviation='/ch/a'}\".");
+    CHECK_LOG_CTX("Invalid deviation of case node - it is not possible to replace \"config\" property.",
+            "/jj4:{deviation='/ch/a'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj5 {namespace urn:jj5;prefix jj5; container top {leaf x {type string; config true;}}"
             "deviation /top {deviate add {config false;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/jj5:top\".");
-    CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "Path \"/jj5:top/x\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/jj5:top", 0);
+    CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "/jj5:top/x", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj6 {namespace urn:jj6;prefix jj6; leaf x {config false; type string;}"
             "deviation /x {deviate add {config true;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation adding \"config\" property which already exists (with value \"config false\").",
-            "Path \"/jj6:{deviation='/x'}\".");
+            "/jj6:{deviation='/x'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk1 {namespace urn:kk1;prefix kk1; container top {leaf a{type string;}}"
             "deviation /top {deviate add {mandatory true;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to add \"mandatory\" property.", "Path \"/kk1:{deviation='/top'}\".");
+    CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to add \"mandatory\" property.",
+            "/kk1:{deviation='/top'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk2 {namespace urn:kk2;prefix kk2; container top {leaf a{type string;}}"
             "deviation /top {deviate replace {mandatory true;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to replace \"mandatory\" property.", "Path \"/kk2:{deviation='/top'}\".");
+    CHECK_LOG_CTX("Invalid deviation of container node - it is not possible to replace \"mandatory\" property.",
+            "/kk2:{deviation='/top'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk3 {namespace urn:kk3;prefix kk3; container top {leaf x {type string;}}"
             "deviation /top/x {deviate replace {mandatory true;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation replacing \"mandatory\" property \"mandatory true\" which is not present.", "Path \"/kk3:{deviation='/top/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation replacing \"mandatory\" property \"mandatory true\" which is not present.",
+            "/kk3:{deviation='/top/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module kk4 {namespace urn:kk4;prefix kk4; leaf x {mandatory true; type string;}"
             "deviation /x {deviate add {mandatory false;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid deviation adding \"mandatory\" property which already exists (with value \"mandatory true\").",
-            "Path \"/kk4:{deviation='/x'}\".");
+            "/kk4:{deviation='/x'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ll1 {namespace urn:ll1;prefix ll1; leaf x {default test; type string;}"
             "deviation /x {deviate add {mandatory true;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/ll1:{deviation='/x'}\".");
-    CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "Path \"/ll1:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ll1:{deviation='/x'}", 0);
+    CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "/ll1:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ll2 {yang-version 1.1; namespace urn:ll2;prefix ll2; leaf-list x {default test; type string;}"
             "deviation /x {deviate add {min-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/ll2:{deviation='/x'}\".");
-    CHECK_LOG_CTX("The default statement is present on leaf-list with a nonzero min-elements.", "Path \"/ll2:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ll2:{deviation='/x'}", 0);
+    CHECK_LOG_CTX("The default statement is present on leaf-list with a nonzero min-elements.", "/ll2:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ll2 {namespace urn:ll2;prefix ll2; choice ch {default a; leaf a {type string;} leaf b {type string;}}"
             "deviation /ch {deviate add {mandatory true;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/ll2:ch\".");
-    CHECK_LOG_CTX("Invalid mandatory choice with a default case.", "Path \"/ll2:ch\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ll2:ch", 0);
+    CHECK_LOG_CTX("Invalid mandatory choice with a default case.", "/ll2:ch", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm1 {namespace urn:mm1;prefix mm1; leaf-list x {min-elements 10; type string;}"
             "deviation /x {deviate add {max-elements 5;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/mm1:{deviation='/x'}\".");
-    CHECK_LOG_CTX("Leaf-list min-elements 10 is bigger than max-elements 5.", "Path \"/mm1:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm1:{deviation='/x'}", 0);
+    CHECK_LOG_CTX("Leaf-list min-elements 10 is bigger than max-elements 5.", "/mm1:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm2 {namespace urn:mm2;prefix mm2; leaf-list x {max-elements 10; type string;}"
             "deviation /x {deviate add {min-elements 20;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/mm2:{deviation='/x'}\".");
-    CHECK_LOG_CTX("Leaf-list min-elements 20 is bigger than max-elements 10.", "Path \"/mm2:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm2:{deviation='/x'}", 0);
+    CHECK_LOG_CTX("Leaf-list min-elements 20 is bigger than max-elements 10.", "/mm2:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm3 {namespace urn:mm3;prefix mm3; list x {min-elements 5; max-elements 10; config false;}"
             "deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/mm3:{deviation='/x'}\".");
-    CHECK_LOG_CTX("List min-elements 5 is bigger than max-elements 1.", "Path \"/mm3:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm3:{deviation='/x'}", 0);
+    CHECK_LOG_CTX("List min-elements 5 is bigger than max-elements 1.", "/mm3:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm4 {namespace urn:mm4;prefix mm4; list x {min-elements 5; max-elements 10; config false;}"
             "deviation /x {deviate replace {min-elements 20;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/mm4:{deviation='/x'}\".");
-    CHECK_LOG_CTX("List min-elements 20 is bigger than max-elements 10.", "Path \"/mm4:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm4:{deviation='/x'}", 0);
+    CHECK_LOG_CTX("List min-elements 20 is bigger than max-elements 10.", "/mm4:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm5 {namespace urn:mm5;prefix mm5; leaf-list x {type string; min-elements 5;}"
             "deviation /x {deviate add {min-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation adding \"min-elements\" property which already exists (with value \"5\").", "Path \"/mm5:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation adding \"min-elements\" property which already exists (with value \"5\").",
+            "/mm5:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm6 {namespace urn:mm6;prefix mm6; list x {config false; min-elements 5;}"
             "deviation /x {deviate add {min-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation adding \"min-elements\" property which already exists (with value \"5\").", "Path \"/mm6:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation adding \"min-elements\" property which already exists (with value \"5\").",
+            "/mm6:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm7 {namespace urn:mm7;prefix mm7; leaf-list x {type string; max-elements 5;}"
             "deviation /x {deviate add {max-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation adding \"max-elements\" property which already exists (with value \"5\").", "Path \"/mm7:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation adding \"max-elements\" property which already exists (with value \"5\").",
+            "/mm7:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm8 {namespace urn:mm8;prefix mm8; list x {config false; max-elements 5;}"
             "deviation /x {deviate add {max-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation adding \"max-elements\" property which already exists (with value \"5\").", "Path \"/mm8:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation adding \"max-elements\" property which already exists (with value \"5\").",
+            "/mm8:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm9 {namespace urn:mm9;prefix mm9; leaf-list x {type string;}"
             "deviation /x {deviate replace {min-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation replacing \"min-elements\" property which is not present.", "Path \"/mm9:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation replacing \"min-elements\" property which is not present.", "/mm9:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm10 {namespace urn:mm10;prefix mm10; list x {config false;}"
             "deviation /x {deviate replace {min-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation replacing \"min-elements\" property which is not present.", "Path \"/mm10:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation replacing \"min-elements\" property which is not present.", "/mm10:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm11 {namespace urn:mm11;prefix mm11; leaf-list x {type string;}"
             "deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation replacing \"max-elements\" property which is not present.", "Path \"/mm11:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation replacing \"max-elements\" property which is not present.", "/mm11:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm12 {namespace urn:mm12;prefix mm12; list x {config false; }"
             "deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation replacing \"max-elements\" property which is not present.", "Path \"/mm12:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation replacing \"max-elements\" property which is not present.", "/mm12:{deviation='/x'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module nn1 {namespace urn:nn1;prefix nn1; anyxml x;"
             "deviation /x {deviate replace {type string;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Invalid deviation of anyxml node - it is not possible to replace \"type\" property.", "Path \"/nn1:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Invalid deviation of anyxml node - it is not possible to replace \"type\" property.", "/nn1:{deviation='/x'}", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module nn2 {namespace urn:nn2;prefix nn2; leaf-list x {type string;}"
             "deviation /x {deviate replace {type empty;}}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "Path \"/nn2:{deviation='/x'}\".");
-    CHECK_LOG_CTX("Leaf-list of type \"empty\" is allowed only in YANG 1.1 modules.", "Path \"/nn2:{deviation='/x'}\".");
+    CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/nn2:{deviation='/x'}", 0);
+    CHECK_LOG_CTX("Leaf-list of type \"empty\" is allowed only in YANG 1.1 modules.", "/nn2:{deviation='/x'}", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module oo1 {namespace urn:oo1;prefix oo1; leaf x {type uint16; default 300;}"
             "deviation /x {deviate replace {type uint8;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid default - value does not fit the type "
-            "(Value \"300\" is out of type uint8 min/max bounds.).", "Schema location \"/oo1:x\".");
+            "(Value \"300\" is out of type uint8 min/max bounds.).", "/oo1:x", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module oo2 {yang-version 1.1;namespace urn:oo2;prefix oo2; leaf-list x {type uint16; default 10; default 300;}"
             "deviation /x {deviate replace {type uint8;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid default - value does not fit the type "
-            "(Value \"300\" is out of type uint8 min/max bounds.).", "Schema location \"/oo2:x\".");
+            "(Value \"300\" is out of type uint8 min/max bounds.).", "/oo2:x", 0);
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module oo3 {namespace urn:oo3;prefix oo3; leaf x {type uint8;}"
             "deviation /x {deviate add {default 300;}}}", LYS_IN_YANG, &mod));
     CHECK_LOG_CTX("Invalid default - value does not fit the type "
-            "(Value \"300\" is out of type uint8 min/max bounds.).", "Schema location \"/oo3:x\".");
+            "(Value \"300\" is out of type uint8 min/max bounds.).", "/oo3:x", 0);
 
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module pp {namespace urn:pp;prefix pp; leaf l { type leafref {path /c/x;}}"
             "container c {leaf x {type string;} leaf y {type string;}}}", LYS_IN_YANG, &mod));
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module pp1 {namespace urn:pp1;prefix pp1; import pp {prefix pp;}"
             "deviation /pp:c/pp:x {deviate not-supported;}}", LYS_IN_YANG, &mod));
-    CHECK_LOG_CTX("Target of leafref \"l\" cannot be referenced because it is disabled.", "Schema location \"/pp:l\".");
-    CHECK_LOG_CTX("Not found node \"x\" in path.", "Schema location \"/pp:l\".");
+    CHECK_LOG_CTX("Target of leafref \"l\" cannot be referenced because it is disabled.", "/pp:l", 0);
+    CHECK_LOG_CTX("Not found node \"x\" in path.", "/pp:l", 0);
 }
 
 static void
@@ -3717,7 +3732,7 @@
             "    }\n"
             "}",
             LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("When condition cyclic dependency on the node \"cont2\".", "Schema location \"/a:cont/lst/val\".");
+    CHECK_LOG_CTX("When condition cyclic dependency on the node \"cont2\".", "/a:cont/lst/val", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX,
             "module a {\n"
@@ -3745,7 +3760,7 @@
             "    }\n"
             "}",
             LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("When condition cyclic dependency on the node \"cont2\".", "Schema location \"/a:cont/lst/val\".");
+    CHECK_LOG_CTX("When condition cyclic dependency on the node \"cont2\".", "/a:cont/lst/val", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX,
             "module a {\n"
@@ -3757,7 +3772,7 @@
             "    }\n"
             "}",
             LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("When condition is accessing its own conditional node value.", "Schema location \"/a:val\".");
+    CHECK_LOG_CTX("When condition is accessing its own conditional node value.", "/a:val", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX,
             "module a {\n"
@@ -3773,7 +3788,7 @@
             "    }\n"
             "}",
             LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("When condition is accessing its own conditional node value.", "Schema location \"/a:val\".");
+    CHECK_LOG_CTX("When condition is accessing its own conditional node value.", "/a:val", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX,
             "module a {\n"
@@ -3788,7 +3803,7 @@
             "    container cont;\n"
             "}",
             LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("When condition is accessing its own conditional node value.", "Schema location \"/a:cont/val\".");
+    CHECK_LOG_CTX("When condition is accessing its own conditional node value.", "/a:cont/val", 0);
 
     assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX,
             "module a {\n"
@@ -3805,7 +3820,7 @@
             "    container cont;\n"
             "}",
             LYS_IN_YANG, NULL));
-    CHECK_LOG_CTX("When condition is accessing its own conditional node children.", "Schema location \"/a:cont/aug-cont\".");
+    CHECK_LOG_CTX("When condition is accessing its own conditional node children.", "/a:cont/aug-cont", 0);
 
     assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX,
             "module b {\n"
@@ -3967,7 +3982,7 @@
             "}",
             LYS_IN_YANG, NULL));
     /* no warnings */
-    CHECK_LOG_CTX(NULL, NULL);
+    CHECK_LOG_CTX(NULL, NULL, 0);
 
     /* must referencing disabled leafref in another module */
     ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb,
@@ -4029,7 +4044,7 @@
     ly_ctx_unset_options(UTEST_LYCTX, LY_CTX_REF_IMPLEMENTED);
 
     CHECK_LOG_CTX("Schema node \"number-of-laa-scarriers\" not found; in expr \"number-of-laa-scarriers\" "
-            "with context node \"/b:laa-config\".", NULL);
+            "with context node \"/b:laa-config\".", NULL, 0);
 }
 
 int
diff --git a/tests/utests/schema/test_yang.c b/tests/utests/schema/test_yang.c
index 01ebbbd..67f9747 100644
--- a/tests/utests/schema/test_yang.c
+++ b/tests/utests/schema/test_yang.c
@@ -91,7 +91,7 @@
     /* initilize and use the global easily available and customizable input handler */
     in.line = 1;
     YCTX->in = &in;
-    LOG_LOCSET(NULL, NULL, NULL, &in);
+    ly_log_location(NULL, NULL, NULL, &in);
 
     fctx.ctx = PARSER_CTX(YCTX);
     fctx.mod = pmod->mod;
@@ -103,7 +103,7 @@
 teardown(void **state)
 {
     lys_module_free(&fctx, PARSER_CUR_PMOD(YCTX)->mod, 0);
-    LOG_LOCBACK(0, 0, 0, 1);
+    ly_log_location_revert(0, 0, 0, 1);
 
     ly_set_free(YCTX->parsed_mods, NULL);
     ly_set_erase(&YCTX->ext_inst, NULL);
@@ -120,7 +120,7 @@
 #define TEST_DUP_GENERIC(PREFIX, MEMBER, VALUE1, VALUE2, FUNC, RESULT, LINE, CLEANUP) \
     in.current = PREFIX MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, FUNC(YCTX, RESULT)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number "LINE".");\
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, LINE);\
     CLEANUP
 static void
 test_helpers(void **state)
@@ -175,22 +175,22 @@
 
     /* checking identifiers */
     assert_int_equal(LY_EVALID, lysp_check_identifierchar((struct lysp_ctx *)YCTX, ':', 0, NULL));
-    CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", NULL, 1);
     assert_int_equal(LY_EVALID, lysp_check_identifierchar((struct lysp_ctx *)YCTX, '#', 1, NULL));
-    CHECK_LOG_CTX("Invalid identifier first character '#' (0x0023).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid identifier first character '#' (0x0023).", NULL, 1);
 
     assert_int_equal(LY_SUCCESS, lysp_check_identifierchar((struct lysp_ctx *)YCTX, 'a', 1, &prefix));
     assert_int_equal(0, prefix);
     assert_int_equal(LY_SUCCESS, lysp_check_identifierchar((struct lysp_ctx *)YCTX, ':', 0, &prefix));
     assert_int_equal(1, prefix);
     assert_int_equal(LY_EVALID, lysp_check_identifierchar((struct lysp_ctx *)YCTX, ':', 0, &prefix));
-    CHECK_LOG_CTX("Invalid identifier first character ':' (0x003a).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid identifier first character ':' (0x003a).", NULL, 1);
     assert_int_equal(1, prefix);
     assert_int_equal(LY_SUCCESS, lysp_check_identifierchar((struct lysp_ctx *)YCTX, 'b', 0, &prefix));
     assert_int_equal(2, prefix);
     /* second colon is invalid */
     assert_int_equal(LY_EVALID, lysp_check_identifierchar((struct lysp_ctx *)YCTX, ':', 0, &prefix));
-    CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", NULL, 1);
 }
 
 #define TEST_GET_ARGUMENT_SUCCESS(INPUT_TEXT, CTX, ARG_TYPE, EXPECT_WORD, EXPECT_LEN, EXPECT_CURRENT, EXPECT_LINE)\
@@ -228,7 +228,7 @@
     in.line = 1;
     in.current = " this is a not terminated comment x";
     assert_int_equal(LY_EVALID, skip_comment(YCTX, 2));
-    CHECK_LOG_CTX("Unexpected end-of-input, non-terminated comment.", "Line number 1.");
+    CHECK_LOG_CTX("Unexpected end-of-input, non-terminated comment.", NULL, 1);
     assert_true(in.current[0] == '\0');
 }
 
@@ -245,35 +245,35 @@
 
     in.current = "{";
     assert_int_equal(LY_EVALID, get_argument(YCTX, Y_STR_ARG, NULL, &word, &buf, &len));
-    CHECK_LOG_CTX("Invalid character sequence \"{\", expected an argument.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"{\", expected an argument.", NULL, 1);
 
     /* invalid escape sequence */
     in.current = "\"\\s\"";
     assert_int_equal(LY_EVALID, get_argument(YCTX, Y_STR_ARG, NULL, &word, &buf, &len));
-    CHECK_LOG_CTX("Double-quoted string unknown special character \'\\s\'.", "Line number 1.");
+    CHECK_LOG_CTX("Double-quoted string unknown special character \'\\s\'.", NULL, 1);
 
     TEST_GET_ARGUMENT_SUCCESS("\'\\s\'", YCTX, Y_STR_ARG, "\\s\'", 2, "", 1);
 
     /* invalid character after the argument */
     in.current = "hello\"";
     assert_int_equal(LY_EVALID, get_argument(YCTX, Y_STR_ARG, NULL, &word, &buf, &len));
-    CHECK_LOG_CTX("Invalid character sequence \"\"\", expected unquoted string character, optsep, semicolon or opening brace.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"\"\", expected unquoted string character, optsep, semicolon or opening brace.", NULL, 1);
 
     in.current = "hello}";
     assert_int_equal(LY_EVALID, get_argument(YCTX, Y_STR_ARG, NULL, &word, &buf, &len));
-    CHECK_LOG_CTX("Invalid character sequence \"}\", expected unquoted string character, optsep, semicolon or opening brace.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"}\", expected unquoted string character, optsep, semicolon or opening brace.", NULL, 1);
     /* invalid identifier-ref-arg-str */
     in.current = "pre:pre:value";
     assert_int_equal(LY_EVALID, get_argument(YCTX, Y_PREF_IDENTIF_ARG, NULL, &word, &buf, &len));
-    CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", NULL, 1);
 
     in.current = "\"\";"; /* empty identifier is not allowed */
     assert_int_equal(LY_EVALID, get_argument(YCTX, Y_IDENTIF_ARG, NULL, &word, &buf, &len));
-    CHECK_LOG_CTX("Statement argument is required.", "Line number 1.");
+    CHECK_LOG_CTX("Statement argument is required.", NULL, 1);
 
     in.current = "\"\";"; /* empty reference identifier is not allowed */
     assert_int_equal(LY_EVALID, get_argument(YCTX, Y_PREF_IDENTIF_ARG, NULL, &word, &buf, &len));
-    CHECK_LOG_CTX("Statement argument is required.", "Line number 1.");
+    CHECK_LOG_CTX("Statement argument is required.", NULL, 1);
 
     /* slash is not an invalid character */
     TEST_GET_ARGUMENT_SUCCESS("hello/x\t", YCTX, Y_STR_ARG, "hello/x\t", 7, "\t", 1);
@@ -322,7 +322,7 @@
     in.line = 1;
     in.current = "\"hel\"  +\t\nlo"; /* unquoted the second part */
     assert_int_equal(LY_EVALID, get_argument(YCTX, Y_STR_ARG, NULL, &word, &buf, &len));
-    CHECK_LOG_CTX("Both string parts divided by '+' must be quoted.", "Line number 2.");
+    CHECK_LOG_CTX("Both string parts divided by '+' must be quoted.", NULL, 2);
 
     TEST_GET_ARGUMENT_SUCCESS("\'he\'\t\n+ \"llo\"", YCTX, Y_STR_ARG, "hello", 5, "", 2);
     free(buf);
@@ -334,7 +334,7 @@
     in.line = 1;
     in.current = ";";
     assert_int_equal(LY_EVALID, get_argument(YCTX, Y_STR_ARG, NULL, &word, &buf, &len));
-    CHECK_LOG_CTX("Invalid character sequence \";\", expected an argument.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \";\", expected an argument.", NULL, 1);
 }
 
 #define TEST_STMS_SUCCESS(INPUT_TEXT, CTX, ACTION, EXPECT_WORD)\
@@ -373,15 +373,15 @@
 
     in.current = "/input { "; /* invalid slash */
     assert_int_equal(LY_EVALID, get_keyword(YCTX, &kw, &word, &len));
-    CHECK_LOG_CTX("Invalid identifier first character '/'.", "Line number 4.");
+    CHECK_LOG_CTX("Invalid identifier first character '/'.", NULL, 4);
 
     in.current = "not-a-statement-nor-extension { "; /* invalid identifier */
     assert_int_equal(LY_EVALID, get_keyword(YCTX, &kw, &word, &len));
-    CHECK_LOG_CTX("Invalid character sequence \"not-a-statement-nor-extension\", expected a keyword.", "Line number 4.");
+    CHECK_LOG_CTX("Invalid character sequence \"not-a-statement-nor-extension\", expected a keyword.", NULL, 4);
 
     in.current = "path;"; /* missing sep after the keyword */
     assert_int_equal(LY_EVALID, get_keyword(YCTX, &kw, &word, &len));
-    CHECK_LOG_CTX("Invalid character sequence \"path;\", expected a keyword followed by a separator.", "Line number 4.");
+    CHECK_LOG_CTX("Invalid character sequence \"path;\", expected a keyword followed by a separator.", NULL, 4);
 
     TEST_STMS_SUCCESS("action ", YCTX, LY_STMT_ACTION, "action");
 
@@ -478,43 +478,43 @@
 
     in.current = " 1invalid; ...";
     assert_int_equal(LY_EVALID, parse_minelements(YCTX, &value, &flags, &ext));
-    CHECK_LOG_CTX("Invalid value \"1invalid\" of \"min-elements\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"1invalid\" of \"min-elements\".", NULL, 1);
 
     flags = value = 0;
     in.current = " -1; ...";
     assert_int_equal(LY_EVALID, parse_minelements(YCTX, &value, &flags, &ext));
-    CHECK_LOG_CTX("Invalid value \"-1\" of \"min-elements\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"-1\" of \"min-elements\".", NULL, 1);
 
     /* implementation limit */
     flags = value = 0;
     in.current = " 4294967296; ...";
     assert_int_equal(LY_EVALID, parse_minelements(YCTX, &value, &flags, &ext));
-    CHECK_LOG_CTX("Value \"4294967296\" is out of \"min-elements\" bounds.", "Line number 1.");
+    CHECK_LOG_CTX("Value \"4294967296\" is out of \"min-elements\" bounds.", NULL, 1);
 
     flags = value = 0;
     in.current = " 1 {config true;} ...";
     assert_int_equal(LY_EVALID, parse_minelements(YCTX, &value, &flags, &ext));
-    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"min-elements\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"min-elements\".", NULL, 1);
 
     in.current = " 1invalid; ...";
     assert_int_equal(LY_EVALID, parse_maxelements(YCTX, &value, &flags, &ext));
-    CHECK_LOG_CTX("Invalid value \"1invalid\" of \"max-elements\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"1invalid\" of \"max-elements\".", NULL, 1);
 
     flags = value = 0;
     in.current = " -1; ...";
     assert_int_equal(LY_EVALID, parse_maxelements(YCTX, &value, &flags, &ext));
-    CHECK_LOG_CTX("Invalid value \"-1\" of \"max-elements\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"-1\" of \"max-elements\".", NULL, 1);
 
     /* implementation limit */
     flags = value = 0;
     in.current = " 4294967296; ...";
     assert_int_equal(LY_EVALID, parse_maxelements(YCTX, &value, &flags, &ext));
-    CHECK_LOG_CTX("Value \"4294967296\" is out of \"max-elements\" bounds.", "Line number 1.");
+    CHECK_LOG_CTX("Value \"4294967296\" is out of \"max-elements\" bounds.", NULL, 1);
 
     flags = value = 0;
     in.current = " 1 {config true;} ...";
     assert_int_equal(LY_EVALID, parse_maxelements(YCTX, &value, &flags, &ext));
-    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"max-elements\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"max-elements\".", NULL, 1);
 }
 
 static void
@@ -784,13 +784,13 @@
     in.current = " name {}";
     assert_int_equal(LY_EVALID, parse_module(YCTX, mod));
     assert_string_equal("name", mod->mod->name);
-    CHECK_LOG_CTX("Missing mandatory keyword \"namespace\" as a child of \"module\".", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory keyword \"namespace\" as a child of \"module\".", NULL, 1);
 
     mod = mod_renew(YCTX);
     in.current = " name {namespace urn:name;}";
     assert_int_equal(LY_EVALID, parse_module(YCTX, mod));
     assert_string_equal("urn:name", mod->mod->ns);
-    CHECK_LOG_CTX("Missing mandatory keyword \"prefix\" as a child of \"module\".", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory keyword \"prefix\" as a child of \"module\".", NULL, 1);
     mod = mod_renew(YCTX);
 
     in.current = " name {namespace urn:name;prefix \"n\";}";
@@ -818,17 +818,17 @@
                          parse_module, mod, LINE, mod = mod_renew(YCTX))
 
     /* duplicated namespace, prefix */
-    TEST_DUP("namespace", "y", "z", "1");
-    TEST_DUP("prefix", "y", "z", "1");
-    TEST_DUP("contact", "a", "b", "1");
-    TEST_DUP("description", "a", "b", "1");
-    TEST_DUP("organization", "a", "b", "1");
-    TEST_DUP("reference", "a", "b", "1");
+    TEST_DUP("namespace", "y", "z", 1);
+    TEST_DUP("prefix", "y", "z", 1);
+    TEST_DUP("contact", "a", "b", 1);
+    TEST_DUP("description", "a", "b", 1);
+    TEST_DUP("organization", "a", "b", 1);
+    TEST_DUP("reference", "a", "b", 1);
 
     /* not allowed in module (submodule-specific) */
     in.current = SCHEMA_BEGINNING "belongs-to master {prefix m;}}";
     assert_int_equal(LY_EVALID, parse_module(YCTX, mod));
-    CHECK_LOG_CTX("Invalid keyword \"belongs-to\" as a child of \"module\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"belongs-to\" as a child of \"module\".", NULL, 1);
     mod = mod_renew(YCTX);
 
     /* anydata */
@@ -871,35 +871,35 @@
     /* import - prefix collision */
     in.current = SCHEMA_BEGINNING "import zzz {prefix x;}}";
     assert_int_equal(LY_EVALID, parse_module(YCTX, mod));
-    CHECK_LOG_CTX("Prefix \"x\" already used as module prefix.", "Line number 1.");
+    CHECK_LOG_CTX("Prefix \"x\" already used as module prefix.", NULL, 1);
     mod = mod_renew(YCTX);
 
     in.current = SCHEMA_BEGINNING "import zzz {prefix y;}import zzz {prefix y;}}";
     assert_int_equal(LY_EVALID, parse_module(YCTX, mod));
-    CHECK_LOG_CTX("Prefix \"y\" already used to import \"zzz\" module.", "Line number 1.");
+    CHECK_LOG_CTX("Prefix \"y\" already used to import \"zzz\" module.", NULL, 1);
 
     mod = mod_renew(YCTX);
-    LOG_LOCBACK(0, 0, 0, 1);
+    ly_log_location_revert(0, 0, 0, 1);
 
     in.current = "module name10 {yang-version 1.1;namespace urn:name10;prefix \"n10\";import zzz {prefix y;}import zzz {prefix z;}}";
     assert_int_equal(lys_parse_mem(PARSER_CUR_PMOD(YCTX)->mod->ctx, in.current, LYS_IN_YANG, NULL), LY_SUCCESS);
-    CHECK_LOG_CTX("Single revision of the module \"zzz\" imported twice.", NULL);
+    CHECK_LOG_CTX("Single revision of the module \"zzz\" imported twice.", NULL, 0);
 
     /* include */
     ly_ctx_set_module_imp_clb(PARSER_CUR_PMOD(YCTX)->mod->ctx, test_imp_clb, "module xxx { namespace urn:xxx; prefix x;}");
     in.current = "module" SCHEMA_BEGINNING "include xxx;}";
     assert_int_equal(lys_parse_mem(PARSER_CUR_PMOD(YCTX)->mod->ctx, in.current, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"name\" failed.", NULL);
-    CHECK_LOG_CTX("Including \"xxx\" submodule into \"name\" failed.", NULL);
-    CHECK_LOG_CTX("Data model \"xxx\" not found in local searchdirs.", NULL);
-    CHECK_LOG_CTX("Parsing submodule failed.", NULL);
-    CHECK_LOG_CTX("Input data contains module in situation when a submodule is expected.", NULL);
+    CHECK_LOG_CTX("Parsing module \"name\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Including \"xxx\" submodule into \"name\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Data model \"xxx\" not found in local searchdirs.", NULL, 0);
+    CHECK_LOG_CTX("Parsing submodule failed.", NULL, 0);
+    CHECK_LOG_CTX("Input data contains module in situation when a submodule is expected.", NULL, 0);
 
     ly_ctx_set_module_imp_clb(PARSER_CUR_PMOD(YCTX)->mod->ctx, test_imp_clb, "submodule xxx {belongs-to wrong-name {prefix w;}}");
     in.current = "module" SCHEMA_BEGINNING "include xxx;}";
     assert_int_equal(lys_parse_mem(PARSER_CUR_PMOD(YCTX)->mod->ctx, in.current, LYS_IN_YANG, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"name\" failed.", NULL);
-    CHECK_LOG_CTX("Including \"xxx\" submodule into \"name\" failed.", NULL);
+    CHECK_LOG_CTX("Parsing module \"name\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Including \"xxx\" submodule into \"name\" failed.", NULL, 0);
     UTEST_LOG_CTX_CLEAN;
 
     ly_ctx_set_module_imp_clb(PARSER_CUR_PMOD(YCTX)->mod->ctx, test_imp_clb, "submodule xxx {belongs-to name {prefix x;}}");
@@ -935,11 +935,11 @@
     /* yang-version */
     in.current = SCHEMA_BEGINNING2 "\n\tyang-version 10;}";
     assert_int_equal(LY_EVALID, parse_module(YCTX, mod));
-    CHECK_LOG_CTX("Invalid value \"10\" of \"yang-version\".", NULL);
+    CHECK_LOG_CTX("Invalid value \"10\" of \"yang-version\".", NULL, 0);
     mod = mod_renew(YCTX);
     in.current = SCHEMA_BEGINNING2 "yang-version 1;yang-version 1.1;}";
     assert_int_equal(LY_EVALID, parse_module(YCTX, mod));
-    CHECK_LOG_CTX("Duplicate keyword \"yang-version\".", NULL);
+    CHECK_LOG_CTX("Duplicate keyword \"yang-version\".", NULL, 0);
     mod = mod_renew(YCTX);
     in.current = SCHEMA_BEGINNING2 "yang-version 1;}";
     assert_int_equal(LY_SUCCESS, parse_module(YCTX, mod));
@@ -954,7 +954,7 @@
     m = calloc(1, sizeof *m);
     m->ctx = PARSER_CUR_PMOD(YCTX)->mod->ctx;
     assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m));
-    CHECK_LOG_CTX("Trailing garbage \"module q {names...\" after module, expected end-of-input.", "Line number 1.");
+    CHECK_LOG_CTX("Trailing garbage \"module q {names...\" after module, expected end-of-input.", NULL, 1);
     lysp_yang_ctx_free(ctx_p);
     lys_module_free(&fctx, m, 0);
 
@@ -962,7 +962,7 @@
     m = calloc(1, sizeof *m);
     m->ctx = PARSER_CUR_PMOD(YCTX)->mod->ctx;
     assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m));
-    CHECK_LOG_CTX("Invalid keyword \"prefix\", expected \"module\" or \"submodule\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"prefix\", expected \"module\" or \"submodule\".", NULL, 1);
     lysp_yang_ctx_free(ctx_p);
     lys_module_free(&fctx, m, 0);
 
@@ -970,7 +970,7 @@
     m = calloc(1, sizeof *m);
     m->ctx = PARSER_CUR_PMOD(YCTX)->mod->ctx;
     assert_int_equal(LY_EVALID, yang_parse_module(&ctx_p, &in, m));
-    CHECK_LOG_CTX("Invalid keyword \"position\" as a child of \"enum\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"position\" as a child of \"enum\".", NULL, 1);
     lysp_yang_ctx_free(ctx_p);
     lys_module_free(&fctx, m, 0);
 
@@ -983,7 +983,7 @@
     /* invalid substatement */
     in.current = SCHEMA_BEGINNING "must false;}";
     assert_int_equal(LY_EVALID, parse_module(YCTX, mod));
-    CHECK_LOG_CTX("Invalid keyword \"must\" as a child of \"module\".", NULL);
+    CHECK_LOG_CTX("Invalid keyword \"must\" as a child of \"module\".", NULL, 0);
 
     /* submodule */
     submod = submod_renew(YCTX);
@@ -991,7 +991,7 @@
     /* missing mandatory substatements */
     in.current = " subname {}";
     assert_int_equal(LY_EVALID, parse_submodule(YCTX, submod));
-    CHECK_LOG_CTX("Missing mandatory keyword \"belongs-to\" as a child of \"submodule\".", NULL);
+    CHECK_LOG_CTX("Missing mandatory keyword \"belongs-to\" as a child of \"submodule\".", NULL, 0);
     assert_string_equal("subname", submod->name);
 
     submod = submod_renew(YCTX);
@@ -1007,27 +1007,27 @@
     /* duplicated namespace, prefix */
     in.current = " subname {belongs-to name {prefix x;}belongs-to module1;belongs-to module2;} ...";
     assert_int_equal(LY_EVALID, parse_submodule(YCTX, submod));
-    CHECK_LOG_CTX("Duplicate keyword \"belongs-to\".", NULL);
+    CHECK_LOG_CTX("Duplicate keyword \"belongs-to\".", NULL, 0);
     submod = submod_renew(YCTX);
 
     /* not allowed in submodule (module-specific) */
     in.current = SCHEMA_BEGINNING "namespace \"urn:z\";}";
     assert_int_equal(LY_EVALID, parse_submodule(YCTX, submod));
-    CHECK_LOG_CTX("Invalid keyword \"namespace\" as a child of \"submodule\".", NULL);
+    CHECK_LOG_CTX("Invalid keyword \"namespace\" as a child of \"submodule\".", NULL, 0);
     submod = submod_renew(YCTX);
     in.current = SCHEMA_BEGINNING "prefix m;}}";
     assert_int_equal(LY_EVALID, parse_submodule(YCTX, submod));
-    CHECK_LOG_CTX("Invalid keyword \"prefix\" as a child of \"submodule\".", NULL);
+    CHECK_LOG_CTX("Invalid keyword \"prefix\" as a child of \"submodule\".", NULL, 0);
     submod = submod_renew(YCTX);
 
     in.current = "submodule " SCHEMA_BEGINNING "} module q {namespace urn:q;prefixq;}";
     assert_int_equal(LY_EVALID, yang_parse_submodule(&ctx_p, PARSER_CUR_PMOD(YCTX)->mod->ctx, (struct lysp_ctx *)YCTX, YCTX->in, &submod));
-    CHECK_LOG_CTX("Trailing garbage \"module q {names...\" after submodule, expected end-of-input.", "Line number 1.");
+    CHECK_LOG_CTX("Trailing garbage \"module q {names...\" after submodule, expected end-of-input.", NULL, 1);
     lysp_yang_ctx_free(ctx_p);
 
     in.current = "prefix " SCHEMA_BEGINNING "}";
     assert_int_equal(LY_EVALID, yang_parse_submodule(&ctx_p, PARSER_CUR_PMOD(YCTX)->mod->ctx, (struct lysp_ctx *)YCTX, YCTX->in, &submod));
-    CHECK_LOG_CTX("Invalid keyword \"prefix\", expected \"module\" or \"submodule\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"prefix\", expected \"module\" or \"submodule\".", NULL, 1);
     lysp_yang_ctx_free(ctx_p);
     submod = submod_renew(YCTX);
 
@@ -1043,18 +1043,18 @@
     struct lysp_deviation *d = NULL;
 
     /* invalid cardinality */
-    TEST_DUP_GENERIC(" test {deviate not-supported;", "description", "a", "b", parse_deviation, &d, "1", );
-    TEST_DUP_GENERIC(" test {deviate not-supported;", "reference", "a", "b", parse_deviation, &d, "1", );
+    TEST_DUP_GENERIC(" test {deviate not-supported;", "description", "a", "b", parse_deviation, &d, 1, );
+    TEST_DUP_GENERIC(" test {deviate not-supported;", "reference", "a", "b", parse_deviation, &d, 1, );
 
     /* missing mandatory substatement */
     in.current = " test {description text;}";
     assert_int_equal(LY_EVALID, parse_deviation(YCTX, &d));
-    CHECK_LOG_CTX("Missing mandatory keyword \"deviate\" as a child of \"deviation\".", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory keyword \"deviate\" as a child of \"deviation\".", NULL, 1);
 
     /* invalid substatement */
     in.current = " test {deviate not-supported; status obsolete;}";
     assert_int_equal(LY_EVALID, parse_deviation(YCTX, &d));
-    CHECK_LOG_CTX("Invalid keyword \"status\" as a child of \"deviation\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"status\" as a child of \"deviation\".", NULL, 1);
 }
 
 static void
@@ -1063,17 +1063,17 @@
     struct lysp_deviate *d = NULL;
 
     /* invalid cardinality */
-    TEST_DUP_GENERIC("add {", "config", "true", "false", parse_deviate, &d, "1", );
-    TEST_DUP_GENERIC("add {", "mandatory", "true", "false", parse_deviate, &d, "1", );
-    TEST_DUP_GENERIC("add {", "max-elements", "1", "2", parse_deviate, &d, "1", );
-    TEST_DUP_GENERIC("add {", "min-elements", "1", "2", parse_deviate, &d, "1", );
-    TEST_DUP_GENERIC("add {", "units", "kilometers", "miles", parse_deviate, &d, "1", );
+    TEST_DUP_GENERIC("add {", "config", "true", "false", parse_deviate, &d, 1, );
+    TEST_DUP_GENERIC("add {", "mandatory", "true", "false", parse_deviate, &d, 1, );
+    TEST_DUP_GENERIC("add {", "max-elements", "1", "2", parse_deviate, &d, 1, );
+    TEST_DUP_GENERIC("add {", "min-elements", "1", "2", parse_deviate, &d, 1, );
+    TEST_DUP_GENERIC("add {", "units", "kilometers", "miles", parse_deviate, &d, 1, );
 
     /* invalid substatements */
 #define TEST_NOT_SUP(DEV, STMT, VALUE) \
     in.current = " "DEV" {"STMT" "VALUE";}..."; \
     assert_int_equal(LY_EVALID, parse_deviate(YCTX, &d)); \
-    CHECK_LOG_CTX("Deviate \""DEV"\" does not support keyword \""STMT"\".", "Line number 1.");
+    CHECK_LOG_CTX("Deviate \""DEV"\" does not support keyword \""STMT"\".", NULL, 1);
 
     TEST_NOT_SUP("not-supported", "units", "meters");
     TEST_NOT_SUP("not-supported", "must", "1");
@@ -1095,7 +1095,7 @@
 
     in.current = " nonsence; ...";
     assert_int_equal(LY_EVALID, parse_deviate(YCTX, &d));
-    CHECK_LOG_CTX("Invalid value \"nonsence\" of \"deviate\".", "Line number 1.");\
+    CHECK_LOG_CTX("Invalid value \"nonsence\" of \"deviate\".", NULL, 1);\
     assert_null(d);
 #undef TEST_NOT_SUP
 }
@@ -1112,7 +1112,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "cont {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_container(YCTX, NULL, (struct lysp_node**)&c)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, (struct lysp_node*)c); c = NULL;
 
     TEST_DUP("config", "true", "false");
@@ -1142,18 +1142,18 @@
     /* invalid */
     in.current = " cont {augment /root;} ...";
     assert_int_equal(LY_EVALID, parse_container(YCTX, NULL, (struct lysp_node **)&c));
-    CHECK_LOG_CTX("Invalid keyword \"augment\" as a child of \"container\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"augment\" as a child of \"container\".", NULL, 1);
     lysp_node_free(&fctx, (struct lysp_node *)c); c = NULL;
     in.current = " cont {nonsence true;} ...";
     assert_int_equal(LY_EVALID, parse_container(YCTX, NULL, (struct lysp_node **)&c));
-    CHECK_LOG_CTX("Invalid character sequence \"nonsence\", expected a keyword.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"nonsence\", expected a keyword.", NULL, 1);
     lysp_node_free(&fctx, (struct lysp_node *)c); c = NULL;
 
     PARSER_CUR_PMOD(YCTX)->version = 1; /* simulate YANG 1.0 */
     in.current = " cont {action x;} ...";
     assert_int_equal(LY_EVALID, parse_container(YCTX, NULL, (struct lysp_node **)&c));
     CHECK_LOG_CTX("Invalid keyword \"action\" as a child of \"container\" - "
-            "the statement is allowed only in YANG 1.1 modules.", "Line number 1.");
+            "the statement is allowed only in YANG 1.1 modules.", NULL, 1);
     lysp_node_free(&fctx, (struct lysp_node *)c); c = NULL;
 }
 
@@ -1166,7 +1166,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "l {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_leaf(YCTX, NULL, (struct lysp_node**)&l)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, (struct lysp_node*)l); l = NULL;
 
     TEST_DUP("config", "true", "false");
@@ -1201,12 +1201,12 @@
     /* invalid */
     in.current = " l {description \"missing type\";} ...";
     assert_int_equal(LY_EVALID, parse_leaf(YCTX, NULL, (struct lysp_node **)&l));
-    CHECK_LOG_CTX("Missing mandatory keyword \"type\" as a child of \"leaf\".", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory keyword \"type\" as a child of \"leaf\".", NULL, 1);
     lysp_node_free(&fctx, (struct lysp_node *)l); l = NULL;
 
     in.current = "l { type iid { path qpud wrong {";
     assert_int_equal(LY_EVALID, parse_leaf(YCTX, NULL, (struct lysp_node **)&l));
-    CHECK_LOG_CTX("Invalid character sequence \"wrong\", expected a keyword.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"wrong\", expected a keyword.", NULL, 1);
     lysp_node_free(&fctx, (struct lysp_node *)l); l = NULL;
 }
 
@@ -1221,7 +1221,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "ll {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_leaflist(YCTX, NULL, (struct lysp_node**)&ll)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, (struct lysp_node*)ll); ll = NULL;
 
     TEST_DUP("config", "true", "false");
@@ -1267,13 +1267,13 @@
     /* invalid */
     in.current = " ll {description \"missing type\";} ...";
     assert_int_equal(LY_EVALID, parse_leaflist(YCTX, NULL, (struct lysp_node **)&ll));
-    CHECK_LOG_CTX("Missing mandatory keyword \"type\" as a child of \"leaf-list\".", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory keyword \"type\" as a child of \"leaf-list\".", NULL, 1);
     lysp_node_free(&fctx, (struct lysp_node *)ll); ll = NULL;
 
     PARSER_CUR_PMOD(YCTX)->version = 1; /* simulate YANG 1.0 - default statement is not allowed */
     in.current = " ll {default xx; type string;} ...";
     assert_int_equal(LY_EVALID, parse_leaflist(YCTX, NULL, (struct lysp_node **)&ll));
-    CHECK_LOG_CTX("Invalid keyword \"default\" as a child of \"leaf-list\" - the statement is allowed only in YANG 1.1 modules.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"default\" as a child of \"leaf-list\" - the statement is allowed only in YANG 1.1 modules.", NULL, 1);
     lysp_node_free(&fctx, (struct lysp_node *)ll); ll = NULL;
 }
 
@@ -1289,7 +1289,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "l {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_list(YCTX, NULL, (struct lysp_node**)&l)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, (struct lysp_node*)l); l = NULL;
 
     TEST_DUP("config", "true", "false");
@@ -1326,7 +1326,7 @@
     PARSER_CUR_PMOD(YCTX)->version = 1; /* simulate YANG 1.0 */
     in.current = "l {action x;} ...";
     assert_int_equal(LY_EVALID, parse_list(YCTX, NULL, (struct lysp_node **)&l));
-    CHECK_LOG_CTX("Invalid keyword \"action\" as a child of \"list\" - the statement is allowed only in YANG 1.1 modules.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"action\" as a child of \"list\" - the statement is allowed only in YANG 1.1 modules.", NULL, 1);
     lysp_node_free(&fctx, (struct lysp_node *)l); l = NULL;
 }
 
@@ -1341,7 +1341,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "ch {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_choice(YCTX, NULL, (struct lysp_node**)&ch)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, (struct lysp_node*)ch); ch = NULL;
 
     TEST_DUP("config", "true", "false");
@@ -1379,7 +1379,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "cs {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_case(YCTX, NULL, (struct lysp_node**)&cs)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, (struct lysp_node*)cs); cs = NULL;
 
     TEST_DUP("description", "text1", "text2");
@@ -1398,7 +1398,7 @@
     /* invalid content */
     in.current = "cs {config true} ...";
     assert_int_equal(LY_EVALID, parse_case(YCTX, NULL, (struct lysp_node **)&cs));
-    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"case\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"case\".", NULL, 1);
     lysp_node_free(&fctx, (struct lysp_node *)cs); cs = NULL;
 }
 
@@ -1417,7 +1417,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "l {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_any(YCTX, kw, NULL, (struct lysp_node**)&any)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, (struct lysp_node*)any); any = NULL;
 
     TEST_DUP("config", "true", "false");
@@ -1463,7 +1463,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "l {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_grouping(YCTX, NULL, &grp)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, &grp->node); grp = NULL;
 
     TEST_DUP("description", "text1", "text2");
@@ -1491,13 +1491,13 @@
     /* invalid content */
     in.current = "grp {config true} ...";
     assert_int_equal(LY_EVALID, parse_grouping(YCTX, NULL, &grp));
-    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"grouping\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"grouping\".", NULL, 1);
     lysp_node_free(&fctx, &grp->node);
     grp = NULL;
 
     in.current = "grp {must 'expr'} ...";
     assert_int_equal(LY_EVALID, parse_grouping(YCTX, NULL, &grp));
-    CHECK_LOG_CTX("Invalid keyword \"must\" as a child of \"grouping\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"must\" as a child of \"grouping\".", NULL, 1);
     lysp_node_free(&fctx, &grp->node);
     grp = NULL;
 }
@@ -1515,7 +1515,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "func {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_action(YCTX, NULL, &rpcs)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, (struct lysp_node*)rpcs); rpcs = NULL;
 
     TEST_DUP("description", "text1", "text2");
@@ -1566,7 +1566,7 @@
     /* invalid content */
     in.current = "func {config true} ...";
     assert_int_equal(LY_EVALID, parse_action(YCTX, NULL, &rpcs));
-    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"rpc\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"rpc\".", NULL, 1);
     lysp_node_free(&fctx, (struct lysp_node *)rpcs); rpcs = NULL;
 
     lysp_node_free(&fctx, (struct lysp_node *)c);
@@ -1585,7 +1585,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "func {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_notif(YCTX, NULL, &notifs)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, (struct lysp_node*)notifs); notifs = NULL;
 
     TEST_DUP("description", "text1", "text2");
@@ -1619,7 +1619,7 @@
     /* invalid content */
     in.current = "ntf {config true} ...";
     assert_int_equal(LY_EVALID, parse_notif(YCTX, NULL, &notifs));
-    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"notification\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid keyword \"config\" as a child of \"notification\".", NULL, 1);
     lysp_node_free(&fctx, (struct lysp_node *)notifs); notifs = NULL;
 
     lysp_node_free(&fctx, (struct lysp_node *)c);
@@ -1636,7 +1636,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "l {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_uses(YCTX, NULL, (struct lysp_node**)&u)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, (struct lysp_node*)u); u = NULL;
 
     TEST_DUP("description", "text1", "text2");
@@ -1665,7 +1665,7 @@
 #define TEST_DUP(MEMBER, VALUE1, VALUE2) \
     in.current = "l {" MEMBER" "VALUE1";"MEMBER" "VALUE2";} ..."; \
     assert_int_equal(LY_EVALID, parse_augment(YCTX, NULL, &a)); \
-    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", "Line number 1."); \
+    CHECK_LOG_CTX("Duplicate keyword \""MEMBER"\".", NULL, 1); \
     lysp_node_free(&fctx, (struct lysp_node *)a); a = NULL;
 
     TEST_DUP("description", "text1", "text2");
@@ -1701,12 +1701,12 @@
     in.current = "l { description text1;description text2;} ...";
     assert_int_equal(LY_EVALID, parse_when(YCTX, &w));
     assert_null(w);
-    CHECK_LOG_CTX("Duplicate keyword \"description\".", "Line number 1.");
+    CHECK_LOG_CTX("Duplicate keyword \"description\".", NULL, 1);
 
     in.current = "l { reference 1;reference 2;} ...";
     assert_int_equal(LY_EVALID, parse_when(YCTX, &w));
     assert_null(w);
-    CHECK_LOG_CTX("Duplicate keyword \"reference\".", "Line number 1.");
+    CHECK_LOG_CTX("Duplicate keyword \"reference\".", NULL, 1);
 }
 
 static void
@@ -1721,7 +1721,7 @@
     in.current = "-0;";
     memset(&enm, 0, sizeof enm);
     assert_int_equal(parse_type_enum_value_pos(YCTX, LY_STMT_POSITION, &enm), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"-0\" of \"position\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"-0\" of \"position\".", NULL, 1);
 }
 
 int
diff --git a/tests/utests/schema/test_yin.c b/tests/utests/schema/test_yin.c
index 13b32b3..329fcda 100644
--- a/tests/utests/schema/test_yin.c
+++ b/tests/utests/schema/test_yin.c
@@ -335,7 +335,7 @@
 
     ret = yin_parse_content(YCTX, subelems2, 2, NULL, LY_STMT_STATUS, NULL, &exts);
     assert_int_equal(ret, LY_EVALID);
-    CHECK_LOG_CTX("Redefinition of \"text\" sub-element in \"status\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Redefinition of \"text\" sub-element in \"status\" element.", NULL, 1);
     lydict_remove(UTEST_LYCTX, prefix_value);
     lydict_remove(UTEST_LYCTX, value);
     RESET_STATE;
@@ -355,7 +355,7 @@
 
     ret = yin_parse_content(YCTX, subelems3, 2, NULL, LY_STMT_STATUS, NULL, &exts);
     assert_int_equal(ret, LY_EVALID);
-    CHECK_LOG_CTX("Sub-element \"text\" of \"status\" element must be defined as it's first sub-element.", "Line number 1.");
+    CHECK_LOG_CTX("Sub-element \"text\" of \"status\" element must be defined as it's first sub-element.", NULL, 1);
     lydict_remove(UTEST_LYCTX, prefix_value);
     RESET_STATE;
 
@@ -369,7 +369,7 @@
 
     ret = yin_parse_content(YCTX, subelems4, 1, NULL, LY_STMT_STATUS, NULL, &exts);
     assert_int_equal(ret, LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory sub-element \"prefix\" of \"status\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory sub-element \"prefix\" of \"status\" element.", NULL, 1);
 }
 
 static void
@@ -386,7 +386,7 @@
     YCTX->xmlctx->value = "#invalid";
     YCTX->xmlctx->value_len = 8;
     assert_int_equal(yin_validate_value(YCTX, Y_IDENTIF_ARG), LY_EVALID);
-    CHECK_LOG_CTX("Invalid identifier first character '#' (0x0023).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid identifier first character '#' (0x0023).", NULL, 1);
 
     YCTX->xmlctx->value = "";
     YCTX->xmlctx->value_len = 0;
@@ -395,13 +395,13 @@
     YCTX->xmlctx->value = "pre:b";
     YCTX->xmlctx->value_len = 5;
     assert_int_equal(yin_validate_value(YCTX, Y_IDENTIF_ARG), LY_EVALID);
-    CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", NULL, 1);
     assert_int_equal(yin_validate_value(YCTX, Y_PREF_IDENTIF_ARG), LY_SUCCESS);
 
     YCTX->xmlctx->value = "pre:pre:b";
     YCTX->xmlctx->value_len = 9;
     assert_int_equal(yin_validate_value(YCTX, Y_PREF_IDENTIF_ARG), LY_EVALID);
-    CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", NULL, 1);
 }
 
 static void
@@ -1354,7 +1354,7 @@
     data = ELEMENT_WRAPPER_START "<status value=\"invalid\"></status>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID);
     CHECK_LOG_CTX("Invalid value \"invalid\" of \"value\" attribute in \"status\" element. "
-            "Valid values are \"current\", \"deprecated\" and \"obsolete\".", "Line number 1.");
+            "Valid values are \"current\", \"deprecated\" and \"obsolete\".", NULL, 1);
 }
 
 static void
@@ -1366,7 +1366,7 @@
     data = ELEMENT_WRAPPER_START "<yin-element value=\"invalid\" />" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID);
     CHECK_LOG_CTX("Invalid value \"invalid\" of \"value\" attribute in \"yin-element\" element. "
-            "Valid values are \"true\" and \"false\".", "Line number 1.");
+            "Valid values are \"true\" and \"false\".", NULL, 1);
 }
 
 static void
@@ -1379,7 +1379,7 @@
     data = ELEMENT_WRAPPER_START "<yang-version value=\"version\" />" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &version, NULL, NULL), LY_EVALID);
     CHECK_LOG_CTX("Invalid value \"version\" of \"value\" attribute in \"yang-version\" element. "
-            "Valid values are \"1\" and \"1.1\".", "Line number 1.");
+            "Valid values are \"1\" and \"1.1\".", NULL, 1);
 }
 
 static void
@@ -1411,7 +1411,7 @@
 
     data = ELEMENT_WRAPPER_START "<belongs-to module=\"module-name\"></belongs-to>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &submod, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory sub-element \"prefix\" of \"belongs-to\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory sub-element \"prefix\" of \"belongs-to\" element.", NULL, 1);
 }
 
 static void
@@ -1428,7 +1428,7 @@
     data = ELEMENT_WRAPPER_START "<config value=\"invalid\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID);
     CHECK_LOG_CTX("Invalid value \"invalid\" of \"value\" attribute in \"config\" element. "
-            "Valid values are \"true\" and \"false\".", "Line number 1.");
+            "Valid values are \"true\" and \"false\".", NULL, 1);
 }
 
 static void
@@ -1439,7 +1439,7 @@
 
     data = ELEMENT_WRAPPER_START "<default/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory attribute value of default element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory attribute value of default element.", NULL, 1);
 }
 
 static void
@@ -1450,7 +1450,7 @@
 
     data = ELEMENT_WRAPPER_START "<error-app-tag/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory attribute value of error-app-tag element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory attribute value of error-app-tag element.", NULL, 1);
 }
 
 static void
@@ -1461,11 +1461,11 @@
 
     data = ELEMENT_WRAPPER_START "<error-message></error-message>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory sub-element \"value\" of \"error-message\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory sub-element \"value\" of \"error-message\" element.", NULL, 1);
 
     data = ELEMENT_WRAPPER_START "<error-message invalid=\"text\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Unexpected attribute \"invalid\" of \"error-message\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Unexpected attribute \"invalid\" of \"error-message\" element.", NULL, 1);
 }
 
 static void
@@ -1477,23 +1477,23 @@
     /* invalid values */
     data = ELEMENT_WRAPPER_START "<fraction-digits value=\"-1\"></fraction-digits>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"-1\" of \"value\" attribute in \"fraction-digits\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"-1\" of \"value\" attribute in \"fraction-digits\" element.", NULL, 1);
 
     data = ELEMENT_WRAPPER_START "<fraction-digits value=\"02\"></fraction-digits>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"02\" of \"value\" attribute in \"fraction-digits\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"02\" of \"value\" attribute in \"fraction-digits\" element.", NULL, 1);
 
     data = ELEMENT_WRAPPER_START "<fraction-digits value=\"1p\"></fraction-digits>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"1p\" of \"value\" attribute in \"fraction-digits\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"1p\" of \"value\" attribute in \"fraction-digits\" element.", NULL, 1);
 
     data = ELEMENT_WRAPPER_START "<fraction-digits value=\"19\"></fraction-digits>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"19\" of \"value\" attribute in \"fraction-digits\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"19\" of \"value\" attribute in \"fraction-digits\" element.", NULL, 1);
 
     data = ELEMENT_WRAPPER_START "<fraction-digits value=\"999999999999999999\"></fraction-digits>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"999999999999999999\" of \"value\" attribute in \"fraction-digits\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"999999999999999999\" of \"value\" attribute in \"fraction-digits\" element.", NULL, 1);
 }
 
 static void
@@ -1504,7 +1504,7 @@
 
     data = ELEMENT_WRAPPER_START "<if-feature/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &iffeatures, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory attribute name of if-feature element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory attribute name of if-feature element.", NULL, 1);
     LY_ARRAY_FREE(iffeatures);
     iffeatures = NULL;
 }
@@ -1547,7 +1547,7 @@
 
     data = ELEMENT_WRAPPER_START "<length></length>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory attribute value of length element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory attribute value of length element.", NULL, 1);
     lysp_type_free(&fctx, &type);
     memset(&type, 0, sizeof(type));
 }
@@ -1562,7 +1562,7 @@
     data = ELEMENT_WRAPPER_START "<modifier value=\"invert\" />" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &pat, NULL, NULL), LY_EVALID);
     CHECK_LOG_CTX("Invalid value \"invert\" of \"value\" attribute in \"modifier\" element. "
-            "Only valid value is \"invert-match\".", "Line number 1.");
+            "Only valid value is \"invert-match\".", NULL, 1);
     lydict_remove(UTEST_LYCTX, pat);
 }
 
@@ -1574,7 +1574,7 @@
 
     data = ELEMENT_WRAPPER_START "<namespace/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &ns, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory attribute uri of namespace element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory attribute uri of namespace element.", NULL, 1);
 }
 
 static void
@@ -1641,32 +1641,32 @@
     /* invalid values */
     data = ELEMENT_WRAPPER_START "<value value=\"99999999999999999999999\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"99999999999999999999999\" of \"value\" attribute in \"value\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"99999999999999999999999\" of \"value\" attribute in \"value\" element.", NULL, 1);
 
     data = ELEMENT_WRAPPER_START "<value value=\"1k\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"1k\" of \"value\" attribute in \"value\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"1k\" of \"value\" attribute in \"value\" element.", NULL, 1);
 
     data = ELEMENT_WRAPPER_START "<value value=\"\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"\" of \"value\" attribute in \"value\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"\" of \"value\" attribute in \"value\" element.", NULL, 1);
 
     /*invalid positions */
     data = ELEMENT_WRAPPER_START "<position value=\"-5\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"-5\" of \"value\" attribute in \"position\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"-5\" of \"value\" attribute in \"position\" element.", NULL, 1);
 
     data = ELEMENT_WRAPPER_START "<position value=\"-0\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"-0\" of \"value\" attribute in \"position\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"-0\" of \"value\" attribute in \"position\" element.", NULL, 1);
 
     data = ELEMENT_WRAPPER_START "<position value=\"99999999999999999999\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"99999999999999999999\" of \"value\" attribute in \"position\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"99999999999999999999\" of \"value\" attribute in \"position\" element.", NULL, 1);
 
     data = ELEMENT_WRAPPER_START "<position value=\"\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"\" of \"value\" attribute in \"position\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"\" of \"value\" attribute in \"position\" element.", NULL, 1);
 }
 
 static void
@@ -1738,7 +1738,7 @@
     assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);
     memset(&type, 0, sizeof(type));
     CHECK_LOG_CTX("Invalid value \"invalid\" of \"value\" attribute in \"require-instance\" element. "
-            "Valid values are \"true\" and \"false\".", "Line number 1.");
+            "Valid values are \"true\" and \"false\".", NULL, 1);
 }
 
 static void
@@ -1753,7 +1753,7 @@
 
     data = ELEMENT_WRAPPER_START "<revision-date date=\"2000-50-05\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, rev, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"2000-50-05\" of \"revision-date\".", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"2000-50-05\" of \"revision-date\".", NULL, 1);
 }
 
 static void
@@ -1877,19 +1877,19 @@
 
     data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"0\"/> </list>";
     assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"0\" of \"value\" attribute in \"max-elements\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"0\" of \"value\" attribute in \"max-elements\" element.", NULL, 1);
 
     data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"-10\"/> </list>";
     assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"-10\" of \"value\" attribute in \"max-elements\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"-10\" of \"value\" attribute in \"max-elements\" element.", NULL, 1);
 
     data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"k\"/> </list>";
     assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"k\" of \"value\" attribute in \"max-elements\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"k\" of \"value\" attribute in \"max-elements\" element.", NULL, 1);
 
     data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"u12\"/> </list>";
     assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"u12\" of \"value\" attribute in \"max-elements\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"u12\" of \"value\" attribute in \"max-elements\" element.", NULL, 1);
 }
 
 static void
@@ -1900,19 +1900,19 @@
 
     data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"-5\"/> </leaf-list>";
     assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Value \"-5\" of \"value\" attribute in \"min-elements\" element is out of bounds.", "Line number 1.");
+    CHECK_LOG_CTX("Value \"-5\" of \"value\" attribute in \"min-elements\" element is out of bounds.", NULL, 1);
 
     data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"99999999999999999\"/> </leaf-list>";
     assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Value \"99999999999999999\" of \"value\" attribute in \"min-elements\" element is out of bounds.", "Line number 1.");
+    CHECK_LOG_CTX("Value \"99999999999999999\" of \"value\" attribute in \"min-elements\" element is out of bounds.", NULL, 1);
 
     data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"5k\"/> </leaf-list>";
     assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"5k\" of \"value\" attribute in \"min-elements\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"5k\" of \"value\" attribute in \"min-elements\" element.", NULL, 1);
 
     data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"05\"/> </leaf-list>";
     assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid value \"05\" of \"value\" attribute in \"min-elements\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid value \"05\" of \"value\" attribute in \"min-elements\" element.", NULL, 1);
 }
 
 static void
@@ -1928,7 +1928,7 @@
     data = ELEMENT_WRAPPER_START "<ordered-by value=\"inv\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID);
     CHECK_LOG_CTX("Invalid value \"inv\" of \"value\" attribute in \"ordered-by\" element. "
-            "Valid values are \"system\" and \"user\".", "Line number 1.");
+            "Valid values are \"system\" and \"user\".", NULL, 1);
 }
 
 static void
@@ -2179,7 +2179,8 @@
             "</leaf-list>"
             ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid combination of min-elements and max-elements: min value 15 is bigger than the max value 5.", "Line number 4.");
+    CHECK_LOG_CTX("Invalid combination of min-elements and max-elements: min value 15 is bigger than the max value 5.",
+            NULL, 4);
     lysp_node_free(&fctx, siblings);
     siblings = NULL;
 
@@ -2191,7 +2192,7 @@
             "</leaf-list>"
             ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Invalid combination of sub-elemnts \"min-elements\" and \"default\" in \"leaf-list\" element.", "Line number 5.");
+    CHECK_LOG_CTX("Invalid combination of sub-elemnts \"min-elements\" and \"default\" in \"leaf-list\" element.", NULL, 5);
     lysp_node_free(&fctx, siblings);
     siblings = NULL;
 
@@ -2200,7 +2201,7 @@
             "</leaf-list>"
             ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory sub-element \"type\" of \"leaf-list\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory sub-element \"type\" of \"leaf-list\" element.", NULL, 1);
     lysp_node_free(&fctx, siblings);
     siblings = NULL;
 }
@@ -2218,7 +2219,7 @@
 
     data = ELEMENT_WRAPPER_START "<presence/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory attribute value of presence element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory attribute value of presence element.", NULL, 1);
 }
 
 static void
@@ -2234,7 +2235,7 @@
 
     data = ELEMENT_WRAPPER_START "<key/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory attribute value of key element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory attribute value of key element.", NULL, 1);
 }
 
 static void
@@ -2825,7 +2826,7 @@
     data = ELEMENT_WRAPPER_START "<input name=\"test\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &inout_meta, NULL, NULL), LY_EVALID);
     lysp_node_free(&fctx, (struct lysp_node *)&inout);
-    CHECK_LOG_CTX("Unexpected attribute \"name\" of \"input\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Unexpected attribute \"name\" of \"input\" element.", NULL, 1);
     memset(&inout, 0, sizeof inout);
 }
 
@@ -2995,25 +2996,25 @@
     data = ELEMENT_WRAPPER_START "<deviate value=\"\" />" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_EVALID);
     CHECK_LOG_CTX("Invalid value \"\" of \"value\" attribute in \"deviate\" element. "
-            "Valid values are \"not-supported\", \"add\", \"replace\" and \"delete\".", "Line number 1.");
+            "Valid values are \"not-supported\", \"add\", \"replace\" and \"delete\".", NULL, 1);
     deviates = NULL;
 
     data = ELEMENT_WRAPPER_START "<deviate value=\"invalid\" />" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_EVALID);
     CHECK_LOG_CTX("Invalid value \"invalid\" of \"value\" attribute in \"deviate\" element. "
-            "Valid values are \"not-supported\", \"add\", \"replace\" and \"delete\".", "Line number 1.");
+            "Valid values are \"not-supported\", \"add\", \"replace\" and \"delete\".", NULL, 1);
     deviates = NULL;
 
     data = ELEMENT_WRAPPER_START "<deviate value=\"ad\" />" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_EVALID);
     CHECK_LOG_CTX("Invalid value \"ad\" of \"value\" attribute in \"deviate\" element. "
-            "Valid values are \"not-supported\", \"add\", \"replace\" and \"delete\".", "Line number 1.");
+            "Valid values are \"not-supported\", \"add\", \"replace\" and \"delete\".", NULL, 1);
     deviates = NULL;
 
     data = ELEMENT_WRAPPER_START "<deviate value=\"adds\" />" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_EVALID);
     CHECK_LOG_CTX("Invalid value \"adds\" of \"value\" attribute in \"deviate\" element. "
-            "Valid values are \"not-supported\", \"add\", \"replace\" and \"delete\".", "Line number 1.");
+            "Valid values are \"not-supported\", \"add\", \"replace\" and \"delete\".", NULL, 1);
     deviates = NULL;
 
     data = ELEMENT_WRAPPER_START
@@ -3022,7 +3023,7 @@
             "</deviate>"
             ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Deviate of this type doesn't allow \"must\" as it's sub-element.", "Line number 2.");
+    CHECK_LOG_CTX("Deviate of this type doesn't allow \"must\" as it's sub-element.", NULL, 2);
 }
 
 static void
@@ -3034,7 +3035,7 @@
     /* invalid */
     data = ELEMENT_WRAPPER_START "<deviation target-node=\"target\"/>" ELEMENT_WRAPPER_END;
     assert_int_equal(test_element_helper(state, data, &deviations, NULL, NULL), LY_EVALID);
-    CHECK_LOG_CTX("Missing mandatory sub-element \"deviate\" of \"deviation\" element.", "Line number 1.");
+    CHECK_LOG_CTX("Missing mandatory sub-element \"deviate\" of \"deviation\" element.", NULL, 1);
 }
 
 static struct lysp_module *
@@ -3166,7 +3167,7 @@
     assert_int_equal(ly_in_new_memory(data, &UTEST_IN), LY_SUCCESS);
     assert_int_equal(lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx), LY_SUCCESS);
     assert_int_equal(yin_parse_mod(YCTX, lysp_mod), LY_EVALID);
-    CHECK_LOG_CTX("Invalid order of module\'s sub-elements \"namespace\" can\'t appear after \"feature\".", "Line number 3.");
+    CHECK_LOG_CTX("Invalid order of module\'s sub-elements \"namespace\" can\'t appear after \"feature\".", NULL, 3);
 }
 
 static struct lysp_submodule *
@@ -3233,7 +3234,7 @@
 
     assert_int_equal(yin_parse_submod(YCTX, lysp_submod), LY_SUCCESS);
     CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (mod) are not necessary.",
-            NULL);
+            NULL, 0);
     assert_string_equal(lysp_submod->name, "mod");
     assert_string_equal(lysp_submod->revs[0].date, "2019-02-02");
     assert_string_equal(lysp_submod->prefix, "pref");
@@ -3300,7 +3301,7 @@
     assert_int_equal(ly_in_new_memory(data, &UTEST_IN), LY_SUCCESS);
     assert_int_equal(lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx), LY_SUCCESS);
     assert_int_equal(yin_parse_submod(YCTX, lysp_submod), LY_EVALID);
-    CHECK_LOG_CTX("Invalid order of submodule's sub-elements \"belongs-to\" can't appear after \"reference\".", "Line number 4.");
+    CHECK_LOG_CTX("Invalid order of submodule's sub-elements \"belongs-to\" can't appear after \"reference\".", NULL, 4);
 }
 
 static void
@@ -3403,7 +3404,7 @@
             "</submodule>\n";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
     assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_EINVAL);
-    CHECK_LOG_CTX("Input data contains submodule which cannot be parsed directly without its main module.", NULL);
+    CHECK_LOG_CTX("Input data contains submodule which cannot be parsed directly without its main module.", NULL, 0);
     lys_module_free(&fctx, mod, 0);
     lysp_yin_ctx_free(yin_ctx);
     ly_in_free(in, 0);
@@ -3418,7 +3419,7 @@
             "<module>";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
     assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_EVALID);
-    CHECK_LOG_CTX("Trailing garbage \"<module>\" after module, expected end-of-input.", "Line number 6.");
+    CHECK_LOG_CTX("Trailing garbage \"<module>\" after module, expected end-of-input.", NULL, 6);
     lys_module_free(&fctx, mod, 0);
     lysp_yin_ctx_free(yin_ctx);
     ly_in_free(in, 0);
@@ -3488,7 +3489,7 @@
             "</module>";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
     assert_int_equal(yin_parse_submodule(&yin_ctx, UTEST_LYCTX, (struct lysp_ctx *)YCTX, in, &submod), LY_EINVAL);
-    CHECK_LOG_CTX("Input data contains module when a submodule is expected.", NULL);
+    CHECK_LOG_CTX("Input data contains module when a submodule is expected.", NULL, 0);
     lysp_module_free(&fctx, (struct lysp_module *)submod);
     lysp_yin_ctx_free(yin_ctx);
     ly_in_free(in, 0);
@@ -3510,7 +3511,7 @@
             "</submodule>";
     assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
     assert_int_equal(yin_parse_submodule(&yin_ctx, UTEST_LYCTX, (struct lysp_ctx *)YCTX, in, &submod), LY_EVALID);
-    CHECK_LOG_CTX("Trailing garbage \"<submodule name...\" after submodule, expected end-of-input.", "Line number 8.");
+    CHECK_LOG_CTX("Trailing garbage \"<submodule name...\" after submodule, expected end-of-input.", NULL, 8);
     lysp_module_free(&fctx, (struct lysp_module *)submod);
     lysp_yin_ctx_free(yin_ctx);
     ly_in_free(in, 0);
diff --git a/tests/utests/types/bits.c b/tests/utests/types/bits.c
index eb40965..184e1f8 100644
--- a/tests/utests/types/bits.c
+++ b/tests/utests/types/bits.c
@@ -179,7 +179,8 @@
             "leaf port {type my_type {"
             "   bit ten {position 11;} bit two;}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Invalid bits - position of the item \"ten\" has changed from 10 to 11 in the derived type.", "Path \"/TERR_0:port\".");
+    CHECK_LOG_CTX("Invalid bits - position of the item \"ten\" has changed from 10 to 11 in the derived type.",
+            "/TERR_0:port", 0);
 
     /* add new bit */
     schema = MODULE_CREATE_YANG("TERR_1", "typedef my_type{type bits {"
@@ -187,15 +188,15 @@
             "leaf port {type my_type {"
             "   bit ten {position 10;} bit two;  bit test;}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Invalid bits - derived type adds new item \"test\".", "Path \"/TERR_1:port\".");
+    CHECK_LOG_CTX("Invalid bits - derived type adds new item \"test\".", "/TERR_1:port", 0);
 
     /* different max value => autoadd index */
     schema = MODULE_CREATE_YANG("TERR_2", "leaf port {type bits {"
             " bit first {position -1;} bit second;"
             "}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_2\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid value \"-1\" of \"position\".", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERR_2\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid value \"-1\" of \"position\".", NULL, 5);
 
     /* different max value => autoadd index */
     schema = MODULE_CREATE_YANG("TERR_3", "leaf port {type bits {"
@@ -203,48 +204,48 @@
             "}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid bits - it is not possible to auto-assign bit position for \"second\" since the highest value is already 4294967295.",
-            "Path \"/TERR_3:port\".");
+            "/TERR_3:port", 0);
 
     schema = MODULE_CREATE_YANG("TERR_4", "leaf port {type bits {"
             " bit first {position 10;} bit \"\";"
             "}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_4\" failed.", NULL);
-    CHECK_LOG_CTX("Statement argument is required.", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERR_4\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Statement argument is required.", NULL, 5);
 
     /* wrong character */
     schema = MODULE_CREATE_YANG("TERR_5", "leaf port {type bits {"
             " bit first {position 10;} bit abcd^;"
             "}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_5\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid identifier character '^' (0x005e).", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERR_5\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid identifier character '^' (0x005e).", NULL, 5);
 
     schema = MODULE_CREATE_YANG("TERR_6", "leaf port {type bits {"
             " bit hi; bit hi;"
             "}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_6\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"hi\" of bit statement.", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERR_6\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"hi\" of bit statement.", NULL, 5);
 
     /* wrong character */
     schema = MODULE_CREATE_YANG("TERR_7", "leaf port {type bits {"
             " bit first {position 10;} bit \"ab&cd\";"
             "}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_7\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid identifier character '&' (0x0026).", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERR_7\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid identifier character '&' (0x0026).", NULL, 5);
 
     schema = MODULE_CREATE_YANG("TERR_8", "leaf port {type bits {"
             " bit first {position 10;} bit \"4abcd\";"
             "}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_8\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid identifier first character '4' (0x0034).", "Line number 5.");
+    CHECK_LOG_CTX("Parsing module \"TERR_8\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid identifier first character '4' (0x0034).", NULL, 5);
 
     schema = MODULE_CREATE_YANG("TERR_9", "leaf port {type bits;}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Missing bit substatement for bits type.", "Path \"/TERR_9:port\".");
+    CHECK_LOG_CTX("Missing bit substatement for bits type.", "/TERR_9:port", 0);
 
     /* new features of YANG 1.1 in YANG 1.0 */
     schema = "module TERR_10 {"
@@ -256,9 +257,9 @@
             "  }}"
             "}";
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_10\" failed.", NULL);
+    CHECK_LOG_CTX("Parsing module \"TERR_10\" failed.", NULL, 0);
     CHECK_LOG_CTX("Invalid keyword \"if-feature\" as a child of \"bit\" - the statement is allowed only in YANG 1.1 modules.",
-            "Line number 1.");
+            NULL, 1);
 
     schema = "module TERR_11 {"
             "  namespace \"urn:tests:TERR_10\";"
@@ -267,7 +268,7 @@
             "  leaf l {type mytype {bit one;}}"
             "}";
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Bits type can be subtyped only in YANG 1.1 modules.", "Path \"/TERR_11:l\".");
+    CHECK_LOG_CTX("Bits type can be subtyped only in YANG 1.1 modules.", "/TERR_11:l", 0);
 
     /* feature is not present */
     schema = MODULE_CREATE_YANG("IF_0", "feature f;"
@@ -415,7 +416,8 @@
             "   <bit name=\"ten\"> <position value=\"11\"/> </bit> <bit name=\"two\"/>"
             "</type></leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Invalid bits - position of the item \"ten\" has changed from 10 to 11 in the derived type.", "Path \"/TERR_0:port\".");
+    CHECK_LOG_CTX("Invalid bits - position of the item \"ten\" has changed from 10 to 11 in the derived type.",
+            "/TERR_0:port", 0);
 
     /* add new bit */
     schema = MODULE_CREATE_YIN("TERR_1",
@@ -431,7 +433,7 @@
             "   <bit name=\"test\"/>"
             "</type></leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Invalid bits - derived type adds new item \"test\".", "Path \"/TERR_1:port\".");
+    CHECK_LOG_CTX("Invalid bits - derived type adds new item \"test\".", "/TERR_1:port", 0);
 
     /* different max value => autoadd index */
     schema = MODULE_CREATE_YIN("TERR_2",
@@ -440,8 +442,8 @@
             "   <bit name=\"second\">"
             "</type></leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_2\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid value \"-1\" of \"value\" attribute in \"position\" element.", "Line number 8.");
+    CHECK_LOG_CTX("Parsing module \"TERR_2\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid value \"-1\" of \"value\" attribute in \"position\" element.", NULL, 8);
 
     /* different max value => autoadd index */
     schema = MODULE_CREATE_YIN("TERR_3",
@@ -451,7 +453,7 @@
             "</type></leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid bits - it is not possible to auto-assign bit position for \"second\" since the highest value is already 4294967295.",
-            "Path \"/TERR_3:port\".");
+            "/TERR_3:port", 0);
 
     schema = MODULE_CREATE_YIN("TERR_4",
             "<leaf name=\"port\"> <type name=\"bits\">"
@@ -459,8 +461,8 @@
             "  <bit name=\"second\"/>"
             "</type></leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_4\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid identifier first character ' ' (0x0020).", "Line number 8.");
+    CHECK_LOG_CTX("Parsing module \"TERR_4\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid identifier first character ' ' (0x0020).", NULL, 8);
 
     schema = MODULE_CREATE_YIN("TERR_5",
             "<leaf name=\"port\"> <type name=\"bits\">"
@@ -468,8 +470,8 @@
             "  <bit name=\"second\"/>"
             "</type></leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_5\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid identifier character ' ' (0x0020).", "Line number 8.");
+    CHECK_LOG_CTX("Parsing module \"TERR_5\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid identifier character ' ' (0x0020).", NULL, 8);
 
     schema = MODULE_CREATE_YIN("TERR_6",
             "<leaf name=\"port\"> <type name=\"bits\">"
@@ -477,8 +479,8 @@
             "  <bit name=\"hi\"/>"
             "</type></leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_6\" failed.", NULL);
-    CHECK_LOG_CTX("Duplicate identifier \"hi\" of bit statement.", "Line number 8.");
+    CHECK_LOG_CTX("Parsing module \"TERR_6\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Duplicate identifier \"hi\" of bit statement.", NULL, 8);
 
     schema = MODULE_CREATE_YIN("TERR_7",
             "<leaf name=\"port\"> <type name=\"bits\">"
@@ -486,8 +488,8 @@
             "  <bit name=\"second\"/>"
             "</type></leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_7\" failed.", NULL);
-    CHECK_LOG_CTX("Invalid identifier first character '4' (0x0034).", "Line number 8.");
+    CHECK_LOG_CTX("Parsing module \"TERR_7\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Invalid identifier first character '4' (0x0034).", NULL, 8);
 
     /* TEST EMPTY NAME*/
     schema = MODULE_CREATE_YIN("TERR_8",
@@ -496,8 +498,8 @@
             "  <bit name=\"second\"/>"
             "</type></leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Parsing module \"TERR_8\" failed.", NULL);
-    CHECK_LOG_CTX("Empty identifier is not allowed.", "Line number 8.");
+    CHECK_LOG_CTX("Parsing module \"TERR_8\" failed.", NULL, 0);
+    CHECK_LOG_CTX("Empty identifier is not allowed.", NULL, 8);
 }
 
 static void
@@ -620,14 +622,11 @@
     TEST_SUCCESS_XML("T0", "\n\t", BITS, "");
 
     TEST_ERROR_XML("T0", "twelvea");
-    CHECK_LOG_CTX("Invalid bit \"twelvea\".",
-            "Schema location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Invalid bit \"twelvea\".", "/T0:port", 1);
     TEST_ERROR_XML("T0", "twelve t");
-    CHECK_LOG_CTX("Invalid bit \"t\".",
-            "Schema location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Invalid bit \"t\".", "/T0:port", 1);
     TEST_ERROR_XML("T0", "ELEVEN");
-    CHECK_LOG_CTX("Invalid bit \"ELEVEN\".",
-            "Schema location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Invalid bit \"ELEVEN\".", "/T0:port", 1);
 
     /* empty value  */
     data = "<port xmlns=\"urn:tests:T0\"/>"; \
@@ -662,14 +661,11 @@
     TEST_SUCCESS_JSON("T0", "\\n\\t", BITS, "");
 
     TEST_ERROR_JSON("T0", "twelvea");
-    CHECK_LOG_CTX("Invalid character sequence \"twelvea}\", expected a JSON value.",
-            "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"twelvea}\", expected a JSON value.", NULL, 1);
     TEST_ERROR_JSON("T0", "twelve t");
-    CHECK_LOG_CTX("Invalid character sequence \"twelve t}\", expected a JSON value.",
-            "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"twelve t}\", expected a JSON value.", NULL, 1);
     TEST_ERROR_JSON("T0", "ELEVEN");
-    CHECK_LOG_CTX("Invalid character sequence \"ELEVEN}\", expected a JSON value.",
-            "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"ELEVEN}\", expected a JSON value.", NULL, 1);
 }
 
 static void
diff --git a/tests/utests/types/boolean.c b/tests/utests/types/boolean.c
index 841db2a..2aba30f 100644
--- a/tests/utests/types/boolean.c
+++ b/tests/utests/types/boolean.c
@@ -79,12 +79,10 @@
 
     /* invalid value */
     TEST_ERROR_XML("defs", "l1", "unsure");
-    CHECK_LOG_CTX("Invalid boolean value \"unsure\".",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid boolean value \"unsure\".", "/defs:l1", 1);
 
     TEST_ERROR_XML("defs", "l1", " true");
-    CHECK_LOG_CTX("Invalid boolean value \" true\".",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid boolean value \" true\".", "/defs:l1", 1);
 }
 
 static void
diff --git a/tests/utests/types/decimal64.c b/tests/utests/types/decimal64.c
index e0a7cab..ebfb2b0 100644
--- a/tests/utests/types/decimal64.c
+++ b/tests/utests/types/decimal64.c
@@ -78,28 +78,22 @@
     TEST_SUCCESS_XML("defs", "l2", "9.223372036854775807", DEC64, "9.223372036854775807", INT64_C(9223372036854775807));
 
     TEST_ERROR_XML("defs", "l1", "\n 15 \t\n  ");
-    CHECK_LOG_CTX("Unsatisfied range - value \"15.0\" is out of the allowed range.",
-            "Schema location \"/defs:l1\", line number 3.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"15.0\" is out of the allowed range.", "/defs:l1", 3);
 
     TEST_ERROR_XML("defs", "l1", "\n 0 \t\n  ");
-    CHECK_LOG_CTX("Unsatisfied range - value \"0.0\" is out of the allowed range.",
-            "Schema location \"/defs:l1\", line number 3.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"0.0\" is out of the allowed range.", "/defs:l1", 3);
 
     TEST_ERROR_XML("defs", "l1", "xxx");
-    CHECK_LOG_CTX("Invalid 1. character of decimal64 value \"xxx\".",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid 1. character of decimal64 value \"xxx\".", "/defs:l1", 1);
 
     TEST_ERROR_XML("defs", "l1", "");
-    CHECK_LOG_CTX("Invalid empty decimal64 value.",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid empty decimal64 value.", "/defs:l1", 1);
 
     TEST_ERROR_XML("defs", "l1", "8.5  xxx");
-    CHECK_LOG_CTX("Invalid 6. character of decimal64 value \"8.5  xxx\".",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid 6. character of decimal64 value \"8.5  xxx\".", "/defs:l1", 1);
 
     TEST_ERROR_XML("defs", "l1", "8.55  xxx");
-    CHECK_LOG_CTX("Value \"8.55\" of decimal64 type exceeds defined number (1) of fraction digits.",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Value \"8.55\" of decimal64 type exceeds defined number (1) of fraction digits.", "/defs:l1", 1);
 }
 
 static void
diff --git a/tests/utests/types/empty.c b/tests/utests/types/empty.c
index 0ab9710..39b1179 100644
--- a/tests/utests/types/empty.c
+++ b/tests/utests/types/empty.c
@@ -77,12 +77,10 @@
 
     /* invalid value */
     TEST_ERROR_XML("defs", "l1", "x");
-    CHECK_LOG_CTX("Invalid empty value length 1.",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid empty value length 1.", "/defs:l1", 1);
 
     TEST_ERROR_XML("defs", "l1", " ");
-    CHECK_LOG_CTX("Invalid empty value length 1.",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid empty value length 1.", "/defs:l1", 1);
 }
 
 static void
diff --git a/tests/utests/types/enumeration.c b/tests/utests/types/enumeration.c
index 660479f..88c6a69 100644
--- a/tests/utests/types/enumeration.c
+++ b/tests/utests/types/enumeration.c
@@ -73,22 +73,18 @@
 
     /* disabled feature */
     TEST_ERROR_XML("defs", "l1", "yellow");
-    CHECK_LOG_CTX("Invalid enumeration value \"yellow\".",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid enumeration value \"yellow\".", "/defs:l1", 1);
 
     /* leading/trailing whitespaces */
     TEST_ERROR_XML("defs", "l1", " white");
-    CHECK_LOG_CTX("Invalid enumeration value \" white\".",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid enumeration value \" white\".", "/defs:l1", 1);
 
     TEST_ERROR_XML("defs", "l1", "white\n");
-    CHECK_LOG_CTX("Invalid enumeration value \"white\n\".",
-            "Schema location \"/defs:l1\", line number 2.");
+    CHECK_LOG_CTX("Invalid enumeration value \"white\n\".", "/defs:l1", 2);
 
     /* invalid value */
     TEST_ERROR_XML("defs", "l1", "black");
-    CHECK_LOG_CTX("Invalid enumeration value \"black\".",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid enumeration value \"black\".", "/defs:l1", 1);
 }
 
 static void
diff --git a/tests/utests/types/identityref.c b/tests/utests/types/identityref.c
index 107164d..16c638e 100644
--- a/tests/utests/types/identityref.c
+++ b/tests/utests/types/identityref.c
@@ -96,20 +96,17 @@
 
     /* invalid value */
     TEST_ERROR_XML("defs", "", "l1", "fast-ethernet");
-    CHECK_LOG_CTX("Invalid identityref \"fast-ethernet\" value - identity not found in module \"defs\".",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid identityref \"fast-ethernet\" value - identity not found in module \"defs\".", "/defs:l1", 1);
 
     TEST_ERROR_XML("defs", "xmlns:x=\"urn:tests:defs\"", "l1", "x:slow-ethernet");
-    CHECK_LOG_CTX("Invalid identityref \"x:slow-ethernet\" value - identity not found in module \"defs\".",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid identityref \"x:slow-ethernet\" value - identity not found in module \"defs\".", "/defs:l1", 1);
 
     TEST_ERROR_XML("defs", "xmlns:x=\"urn:tests:ident-base\"", "l1", "x:ident-base");
     CHECK_LOG_CTX("Invalid identityref \"x:ident-base\" value - identity not derived from the base \"ident-base:ident-base\".",
-            "Schema location \"/defs:l1\", line number 1.");
+            "/defs:l1", 1);
 
     TEST_ERROR_XML("defs", "xmlns:x=\"urn:tests:unknown\"", "l1", "x:ident-base");
-    CHECK_LOG_CTX("Invalid identityref \"x:ident-base\" value - unable to map prefix to YANG schema.",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid identityref \"x:ident-base\" value - unable to map prefix to YANG schema.", "/defs:l1", 1);
 }
 
 static void
diff --git a/tests/utests/types/instanceid.c b/tests/utests/types/instanceid.c
index 3126f61..ce5a24e 100644
--- a/tests/utests/types/instanceid.c
+++ b/tests/utests/types/instanceid.c
@@ -137,35 +137,34 @@
             "<list xmlns=\"urn:tests:defs\"><id>b</id><value>x</value></list>",
             "defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l1", "/xdf:list[2]/xdf:value", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:list[2]/xdf:value\" value - semantic error: "
-            "Positional predicate defined for configuration list \"list\" in path.",
-            "Schema location \"/defs:l1\", line number 1.");
+            "Positional predicate defined for configuration list \"list\" in path.", "/defs:l1", 1);
 
     TEST_ERROR_XML2("",
             "defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l1", "/t:cont/t:1l", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/t:cont/t:1l\" value - syntax error: Invalid character 't'[9] of expression '/t:cont/t:1l'.",
-            "Schema location \"/defs:l1\", line number 1.");
+            "/defs:l1", 1);
 
     TEST_ERROR_XML2("",
             "defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l1", "/t:cont:t:1l", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/t:cont:t:1l\" value - syntax error: Invalid character ':'[8] of expression '/t:cont:t:1l'.",
-            "Schema location \"/defs:l1\", line number 1.");
+            "/defs:l1", 1);
 
     TEST_ERROR_XML2("",
             "defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l1", "/xdf:cont/xdf:invalid/xdf:path", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:cont/xdf:invalid/xdf:path\" value - semantic error: Not found node \"invalid\" in path.",
-            "Schema location \"/defs:l1\", line number 1.");
+            "/defs:l1", 1);
 
     /* non-existing instances, instance-identifier is here in JSON format because it is already in internal
      * representation without canonical prefixes */
     TEST_ERROR_XML2("<cont xmlns=\"urn:tests:mod\"/>",
             "defs", "xmlns:m=\"urn:tests:mod\"", "l1", "/m:cont/m:l2", LY_ENOTFOUND);
     CHECK_LOG_CTX_APPTAG("Invalid instance-identifier \"/mod:cont/l2\" value - required instance not found.",
-            "Data location \"/defs:l1\".", "instance-required");
+            "/defs:l1", 0, "instance-required");
 
     TEST_ERROR_XML2("<llist xmlns=\"urn:tests:defs\">1</llist>",
             "defs", "xmlns:a=\"urn:tests:defs\"", "l1", "/a:llist[.='2']", LY_ENOTFOUND);
     CHECK_LOG_CTX_APPTAG("Invalid instance-identifier \"/defs:llist[.='2']\" value - required instance not found.",
-            "Data location \"/defs:l1\".", "instance-required");
+            "/defs:l1", 0, "instance-required");
 
     TEST_ERROR_XML2("<list2 xmlns=\"urn:tests:defs\"><id>a</id><id2>a</id2></list2>"
             "<list2 xmlns=\"urn:tests:defs\"><id>c</id><id2>b</id2></list2>"
@@ -173,7 +172,7 @@
             "<llist xmlns=\"urn:tests:defs\">b</llist>",
             "defs", "xmlns:a=\"urn:tests:defs\"", "l1", "/a:list2[a:id='a'][a:id2='a']/a:id", LY_ENOTFOUND);
     CHECK_LOG_CTX_APPTAG("Invalid instance-identifier \"/defs:list2[id='a'][id2='a']/id\" value - required instance not found.",
-            "Data location \"/defs:l1\".", "instance-required");
+            "/defs:l1", 0, "instance-required");
 
     TEST_ERROR_XML2("<list2 xmlns=\"urn:tests:defs\"><id>a</id><id2>a</id2></list2>"
             "<list2 xmlns=\"urn:tests:defs\"><id>c</id><id2>b</id2></list2>"
@@ -181,83 +180,83 @@
             "<llist xmlns=\"urn:tests:defs\">2</llist>",
             "defs", "xmlns:a=\"urn:tests:defs\"", "l1", "/a:llist[.='3']", LY_ENOTFOUND);
     CHECK_LOG_CTX_APPTAG("Invalid instance-identifier \"/defs:llist[.='3']\" value - required instance not found.",
-            "Data location \"/defs:l1\".", "instance-required");
+            "/defs:l1", 0, "instance-required");
 
     TEST_ERROR_XML2("",
             "defs", "xmlns:a=\"urn:tests:defs\"", "l1", "/a:list-keyless[3]", LY_ENOTFOUND);
     CHECK_LOG_CTX_APPTAG("Invalid instance-identifier \"/defs:list-keyless[3]\" value - required instance not found.",
-            "Data location \"/defs:l1\".", "instance-required");
+            "/defs:l1", 0, "instance-required");
 
     /* more errors */
     TEST_ERROR_XML2("<llist xmlns=\"urn:tests:defs\">x</llist>",
             "defs", "xmlns:t=\"urn:tests:defs\"", "t:l1", "/t:llist[1", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[1\" value - syntax error: Unexpected XPath expression end.",
-            "Schema location \"/defs:l1\", line number 1.");
+            "/defs:l1", 1);
 
     TEST_ERROR_XML2("<cont xmlns=\"urn:tests:mod\"/>",
             "defs", "xmlns:m=\"urn:tests:mod\"", "l1", "/m:cont[1]", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/m:cont[1]\" value - semantic error: Positional predicate defined for container \"cont\" in path.",
-            "Schema location \"/defs:l1\", line number 1.");
+            "/defs:l1", 1);
 
     TEST_ERROR_XML2("<cont xmlns=\"urn:tests:mod\"/>",
             "defs", "xmlns:m=\"urn:tests:mod\"", "l1", "[1]", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"[1]\" value - syntax error: Unexpected XPath token \"[\" (\"[1]\"), expected \"Operator(Path)\".",
-            "Schema location \"/defs:l1\", line number 1.");
+            "/defs:l1", 1);
 
     TEST_ERROR_XML2("<cont xmlns=\"urn:tests:mod\"><l2/></cont>",
             "defs", "xmlns:m=\"urn:tests:mod\"", "l1", "/m:cont/m:l2[l2='1']", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/m:cont/m:l2[l2='1']\" value - syntax error: Prefix missing for \"l2\" in path.",
-            "Schema location \"/defs:l1\", line number 1.");
+            "/defs:l1", 1);
 
     TEST_ERROR_XML2("<cont xmlns=\"urn:tests:mod\"><l2/></cont>",
             "defs", "xmlns:m=\"urn:tests:mod\"", "l1", "/m:cont/m:l2[m:l2='1']", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/m:cont/m:l2[m:l2='1']\" value - semantic error: List predicate defined for leaf \"l2\" in path.",
-            "Schema location \"/defs:l1\", line number 1.");
+            "/defs:l1", 1);
 
     TEST_ERROR_XML2("<llist xmlns=\"urn:tests:defs\">1</llist><llist xmlns=\"urn:tests:defs\">2</llist>",
             "defs", "xmlns:t=\"urn:tests:defs\"", "t:l1", "/t:llist[4]", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[4]\" value - semantic error: Positional predicate defined for configuration leaf-list \"llist\" in path.",
-            "Schema location \"/defs:l1\", line number 1.");
+            "/defs:l1", 1);
 
     TEST_ERROR_XML2("",
             "defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/t:llist[6]", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[6]\" value - semantic error: No module connected with the prefix \"t\" found (prefix format XML prefixes).",
-            "Schema location \"/defs:l2\", line number 1.");
+            "/defs:l2", 1);
 
     TEST_ERROR_XML2("<list xmlns=\"urn:tests:defs\"><id>1</id><value>x</value></list>",
             "defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/xdf:list[xdf:value='x']", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:list[xdf:value='x']\" value - semantic error: Key expected instead of leaf \"value\" in path.",
-            "Schema location \"/defs:l2\", line number 1.");
+            "/defs:l2", 1);
 
     TEST_ERROR_XML2("",
             "defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/xdf:list[.='x']", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:list[.='x']\" value - semantic error: Leaf-list predicate defined for list \"list\" in path.",
-            "Schema location \"/defs:l2\", line number 1.");
+            "/defs:l2", 1);
 
     TEST_ERROR_XML2("<llist xmlns=\"urn:tests:defs\">1</llist>",
             "defs", "xmlns:t=\"urn:tests:defs\"", "t:l1", "/t:llist[.='x']", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[.='x']\" value - semantic error: Invalid type uint32 value \"x\".",
-            "Schema location \"/defs:l1\", line number 1.");
+            "/defs:l1", 1);
 
     TEST_ERROR_XML2("",
             "defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/t:llist[1][2]", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[1][2]\" value - syntax error: Unparsed characters \"[2]\" left at the end of path.",
-            "Schema location \"/defs:l2\", line number 1.");
+            "/defs:l2", 1);
 
     TEST_ERROR_XML2("",
             "defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/t:llist[.='a'][.='b']", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[.='a'][.='b']\" value - syntax error: Unparsed characters \"[.='b']\" left at the end of path.",
-            "Schema location \"/defs:l2\", line number 1.");
+            "/defs:l2", 1);
 
     TEST_ERROR_XML2("<list xmlns=\"urn:tests:defs\"><id>1</id><value>x</value></list>",
             "defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/xdf:list[xdf:id='1'][xdf:id='2']/xdf:value", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:list[xdf:id='1'][xdf:id='2']/xdf:value\" value - syntax error: Duplicate predicate key \"id\" in path.",
-            "Schema location \"/defs:l2\", line number 1.");
+            "/defs:l2", 1);
 
     TEST_ERROR_XML2("",
             "defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/xdf:list2[xdf:id='1']/xdf:value", LY_EVALID);
     CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:list2[xdf:id='1']/xdf:value\" value - semantic error: Predicate missing for a key of list \"list2\" in path.",
-            "Schema location \"/defs:l2\", line number 1.");
+            "/defs:l2", 1);
 }
 
 static void
diff --git a/tests/utests/types/instanceid_keys.c b/tests/utests/types/instanceid_keys.c
index 6d527cb..34a449f 100644
--- a/tests/utests/types/instanceid_keys.c
+++ b/tests/utests/types/instanceid_keys.c
@@ -56,14 +56,13 @@
     TEST_SUCCESS_XML_NS1("defs", "l1", "px", "urn:tests:defs", "[px:key='val']", STRING, "[defs:key='val']");
 
     TEST_ERROR_XML("defs", "l1", "black");
-    CHECK_LOG_CTX("Invalid first character 'b', list key predicates expected.", "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid first character 'b', list key predicates expected.", "/defs:l1", 1);
 
     TEST_ERROR_XML("defs", "l1", "[this is not a valid xpath]");
-    CHECK_LOG_CTX("Invalid character 0x69 ('i'), perhaps \"this\" is supposed to be a function call.",
-            "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Invalid character 0x69 ('i'), perhaps \"this\" is supposed to be a function call.", "/defs:l1", 1);
 
     TEST_ERROR_XML("defs", "l1", "[px:key='val']");
-    CHECK_LOG_CTX("Failed to resolve prefix \"px\".", "Schema location \"/defs:l1\", line number 1.");
+    CHECK_LOG_CTX("Failed to resolve prefix \"px\".", "/defs:l1", 1);
 }
 
 int
diff --git a/tests/utests/types/int16.c b/tests/utests/types/int16.c
index f6796a1..96828e0 100644
--- a/tests/utests/types/int16.c
+++ b/tests/utests/types/int16.c
@@ -60,8 +60,7 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     TEST_ERROR_XML("defs", "100");
-    CHECK_LOG_CTX("Unsatisfied range - value \"100\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"100\" is out of the allowed range.", "/defs:port", 1);
 }
 
 int
diff --git a/tests/utests/types/int32.c b/tests/utests/types/int32.c
index 9989a67..fa2b341 100644
--- a/tests/utests/types/int32.c
+++ b/tests/utests/types/int32.c
@@ -60,8 +60,7 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     TEST_ERROR_XML("defs", "0x01");
-    CHECK_LOG_CTX("Invalid type int32 value \"0x01\".",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Invalid type int32 value \"0x01\".", "/defs:port", 1);
 }
 
 int
diff --git a/tests/utests/types/int64.c b/tests/utests/types/int64.c
index 6b5e47e..0406673 100644
--- a/tests/utests/types/int64.c
+++ b/tests/utests/types/int64.c
@@ -60,16 +60,13 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     TEST_ERROR_XML("defs", "");
-    CHECK_LOG_CTX("Invalid type int64 empty value.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Invalid type int64 empty value.", "/defs:port", 1);
 
     TEST_ERROR_XML("defs", "   ");
-    CHECK_LOG_CTX("Invalid type int64 empty value.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Invalid type int64 empty value.", "/defs:port", 1);
 
     TEST_ERROR_XML("defs", "-10  xxx");
-    CHECK_LOG_CTX("Invalid type int64 value \"-10  xxx\".",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Invalid type int64 value \"-10  xxx\".", "/defs:port", 1);
 }
 
 int
diff --git a/tests/utests/types/int8.c b/tests/utests/types/int8.c
index 198d1f7..3a8f226 100644
--- a/tests/utests/types/int8.c
+++ b/tests/utests/types/int8.c
@@ -240,22 +240,22 @@
     /* TEST ERROR -60 .. 0 | 0 .. 127 */
     schema = MODULE_CREATE_YANG("ERR0", "leaf port {type int8 {range \"-60 .. 0 | 0 .. 127\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EEXIST);
-    CHECK_LOG_CTX("Invalid range restriction - values are not in ascending order (0).", "Path \"/ERR0:port\".");
+    CHECK_LOG_CTX("Invalid range restriction - values are not in ascending order (0).", "/ERR0:port", 0);
 
     /* TEST ERROR 0 .. 128 */
     schema = MODULE_CREATE_YANG("ERR1", "leaf port {type int8 {range \"0 .. 128\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EDENIED);
-    CHECK_LOG_CTX("Invalid range restriction - value \"128\" does not fit the type limitations.", "Path \"/ERR1:port\".");
+    CHECK_LOG_CTX("Invalid range restriction - value \"128\" does not fit the type limitations.", "/ERR1:port", 0);
 
     /* TEST ERROR -129 .. 126 */
     schema = MODULE_CREATE_YANG("ERR2", "leaf port {type int8 {range \"-129 .. 0\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EDENIED);
-    CHECK_LOG_CTX("Invalid range restriction - value \"-129\" does not fit the type limitations.", "Path \"/ERR2:port\".");
+    CHECK_LOG_CTX("Invalid range restriction - value \"-129\" does not fit the type limitations.", "/ERR2:port", 0);
 
     /* TEST ERROR 0 */
     schema = MODULE_CREATE_YANG("ERR3", "leaf port {type int8 {range \"-129\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EDENIED);
-    CHECK_LOG_CTX("Invalid range restriction - value \"-129\" does not fit the type limitations.", "Path \"/ERR3:port\".");
+    CHECK_LOG_CTX("Invalid range restriction - value \"-129\" does not fit the type limitations.", "/ERR3:port", 0);
 
     /*
      * TEST MODULE SUBTYPE
@@ -374,7 +374,7 @@
             "leaf my_leaf {type my_int_type {range \"min .. max\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid range restriction - the derived restriction (min .. max) is not equally or more limiting.",
-            "Path \"/TS_ERR0:my_leaf\".");
+            "/TS_ERR0:my_leaf", 0);
 
     /* TEST SUBTYPE ERROR -80 .. 80 */
     schema = MODULE_CREATE_YANG("TS_ERR1",
@@ -382,7 +382,7 @@
             " leaf my_leaf {type my_int_type {range \"-80 .. 80\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid range restriction - the derived restriction (-80 .. 80) is not equally or more limiting.",
-            "Path \"/TS_ERR1:my_leaf\".");
+            "/TS_ERR1:my_leaf", 0);
 
     /* TEST SUBTYPE ERROR 0 .. max */
     schema = MODULE_CREATE_YANG("TS_ERR2",
@@ -390,7 +390,7 @@
             "leaf my_leaf {type my_int_type {range \"0 .. max\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid range restriction - the derived restriction (0 .. max) is not equally or more limiting.",
-            "Path \"/TS_ERR2:my_leaf\".");
+            "/TS_ERR2:my_leaf", 0);
 
     /* TEST SUBTYPE ERROR -2 .. 2 */
     schema = MODULE_CREATE_YANG("TS_ERR3",
@@ -398,7 +398,7 @@
             "leaf my_leaf {type my_int_type {range \"-2 .. 2\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid range restriction - the derived restriction (-2 .. 2) is not equally or more limiting.",
-            "Path \"/TS_ERR3:my_leaf\".");
+            "/TS_ERR3:my_leaf", 0);
 
     /* TEST SUBTYPE ERROR -2 .. 2 */
     schema = MODULE_CREATE_YANG("TS_ERR4",
@@ -406,7 +406,7 @@
             "leaf my_leaf {type my_int_type {range \"-100 .. -90 | 100 .. 128\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EDENIED);
     CHECK_LOG_CTX("Invalid range restriction - value \"128\" does not fit the type limitations.",
-            "Path \"/TS_ERR4:my_leaf\".");
+            "/TS_ERR4:my_leaf", 0);
 
     /*
      * TEST DEFAULT VALUE
@@ -461,7 +461,7 @@
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"128\" is out of type int8 min/max bounds.).",
-            "Schema location \"/TD_ERR0:port\".");
+            "/TD_ERR0:port", 0);
 
     /* TEST DEFAULT VALUE ERROR */
     schema = MODULE_CREATE_YANG("TD_ERR1",
@@ -471,7 +471,7 @@
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Unsatisfied range - value \"-1\" is out of the allowed range.).",
-            "Schema location \"/TD_ERR1:port\".");
+            "/TD_ERR1:port", 0);
 
     /* TEST DEFAULT VALUE ERROR */
     schema = MODULE_CREATE_YANG("TD_ERR2",
@@ -481,7 +481,7 @@
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Unsatisfied range - value \"60\" is out of the allowed range.).",
-            "Schema location \"/TD_ERR2:port\".");
+            "/TD_ERR2:port", 0);
 
     /* TEST DEFAULT VALUE ERROR */
     schema = MODULE_CREATE_YANG("TD_ERR3",
@@ -489,7 +489,7 @@
             "leaf my_leaf {type my_int_type {range \"70 .. 80\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Unsatisfied range - value \"127\" is out of the allowed range.).",
-            "Schema location \"/TD_ERR3:my_leaf\".");
+            "/TD_ERR3:my_leaf", 0);
 
     /* TEST DEFAULT HEXADECIMAL */
     schema = MODULE_CREATE_YANG("DF_HEX0",
@@ -554,7 +554,7 @@
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"0xff\" is out of type int8 min/max bounds.).",
-            "Schema location \"/DF_HEX2:port\".");
+            "/DF_HEX2:port", 0);
 
     /* TEST DEFAULT HEXADECIMAL ERROR */
     schema = MODULE_CREATE_YANG("DF_HEX3",
@@ -564,7 +564,7 @@
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"-0x81\" is out of type int8 min/max bounds.).",
-            "Schema location \"/DF_HEX3:port\".");
+            "/DF_HEX3:port", 0);
 
     /* TEST DEFAULT HEXADECIMAL ERROR */
     schema = MODULE_CREATE_YANG("DF_HEX4",
@@ -574,7 +574,7 @@
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"0x80\" is out of type int8 min/max bounds.).",
-            "Schema location \"/DF_HEX4:port\".");
+            "/DF_HEX4:port", 0);
 
     /* TEST DEFAULT VALUE OCTAL */
     schema = MODULE_CREATE_YANG("DF_OCT0",
@@ -632,7 +632,7 @@
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"0377\" is out of type int8 min/max bounds.).",
-            "Schema location \"/DF_OCT2:port\".");
+            "/DF_OCT2:port", 0);
 
     /* TEST DEFAULT VALUE OCTAL ERROR*/
     schema = MODULE_CREATE_YANG("DF_OCT3",
@@ -642,7 +642,7 @@
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"-0201\" is out of type int8 min/max bounds.).",
-            "Schema location \"/DF_OCT3:port\".");
+            "/DF_OCT3:port", 0);
 
     /* TEST DEFAULT VALUE OCTAL ERROR*/
     schema = MODULE_CREATE_YANG("DF_OCT4",
@@ -652,7 +652,7 @@
             "}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"0200\" is out of type int8 min/max bounds.).",
-            "Schema location \"/DF_OCT4:port\".");
+            "/DF_OCT4:port", 0);
 }
 
 static void
@@ -745,7 +745,7 @@
             "   <type name=\"int8\"> <range value = \"min .. 0 | 0 .. 12\"/>  </type>"
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EEXIST);
-    CHECK_LOG_CTX("Invalid range restriction - values are not in ascending order (0).", "Path \"/TE0:port\".");
+    CHECK_LOG_CTX("Invalid range restriction - values are not in ascending order (0).", "/TE0:port", 0);
 
     /* TEST ERROR 0 .. 128 */
     schema = MODULE_CREATE_YIN("TE1",
@@ -753,7 +753,7 @@
             "   <type name=\"int8\"> <range value = \"0 .. 128\"/>  </type>"
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EDENIED);
-    CHECK_LOG_CTX("Invalid range restriction - value \"128\" does not fit the type limitations.", "Path \"/TE1:port\".");
+    CHECK_LOG_CTX("Invalid range restriction - value \"128\" does not fit the type limitations.", "/TE1:port", 0);
 
     /* TEST ERROR -129 .. 126 */
     schema = MODULE_CREATE_YIN("TE2",
@@ -761,7 +761,7 @@
             "   <type name=\"int8\"> <range value =\"-129 .. 126\"/>  </type>"
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EDENIED);
-    CHECK_LOG_CTX("Invalid range restriction - value \"-129\" does not fit the type limitations.", "Path \"/TE2:port\".");
+    CHECK_LOG_CTX("Invalid range restriction - value \"-129\" does not fit the type limitations.", "/TE2:port", 0);
 
     /* TEST YIN */
     schema = MODULE_CREATE_YIN("TS0",
@@ -817,7 +817,7 @@
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid range restriction - the derived restriction (min .. max) is not equally or more limiting.",
-            "Path \"/TS_ERR1:port\".");
+            "/TS_ERR1:port", 0);
 
     /* TEST ERROR */
     schema = MODULE_CREATE_YIN("TS_ERR2",
@@ -829,7 +829,7 @@
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid range restriction - the derived restriction (5 .. 11) is not equally or more limiting.",
-            "Path \"/TS_ERR2:port\".");
+            "/TS_ERR2:port", 0);
 
     /* TEST DEFAULT VALUE */
     schema = MODULE_CREATE_YIN("DF0",
@@ -862,7 +862,7 @@
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"128\" is out of type int8 min/max bounds.).",
-            "Schema location \"/TD_ERR0:port\".");
+            "/TD_ERR0:port", 0);
 
     /* TEST ERROR TD1 */
     schema = MODULE_CREATE_YIN("TD_ERR1",
@@ -872,7 +872,7 @@
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Unsatisfied range - value \"13\" is out of the allowed range.).",
-            "Schema location \"/TD_ERR1:port\".");
+            "/TD_ERR1:port", 0);
 
     /* TEST ERROR TD1 */
     schema = MODULE_CREATE_YIN("TD_ERR3",
@@ -886,7 +886,7 @@
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Unsatisfied range - value \"10\" is out of the allowed range.).",
-            "Schema location \"/TD_ERR3:my_leaf\".");
+            "/TD_ERR3:my_leaf", 0);
 
     /* TEST DEFAULT VALUE HEXADECIMAL */
     schema = MODULE_CREATE_YIN("DF_HEX0",
@@ -928,7 +928,7 @@
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"0xff\" is out of type int8 min/max bounds.).",
-            "Schema location \"/DF_HEX2:port\".");
+            "/DF_HEX2:port", 0);
 
     /* TEST DEFAULT VALUE HEXADECIMAL ERROR */
     schema = MODULE_CREATE_YIN("DF_HEX2",
@@ -938,7 +938,7 @@
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"-0x81\" is out of type int8 min/max bounds.).",
-            "Schema location \"/DF_HEX2:port\".");
+            "/DF_HEX2:port", 0);
 
     /* TEST DEFAULT VALUE HEXADECIMAL ERROR */
     schema = MODULE_CREATE_YIN("DF_HEX4",
@@ -948,7 +948,7 @@
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"0x80\" is out of type int8 min/max bounds.).",
-            "Schema location \"/DF_HEX4:port\".");
+            "/DF_HEX4:port", 0);
 
     /* TEST DEFAULT VALUE OCTAL */
     schema = MODULE_CREATE_YIN("DF_OCT0",
@@ -990,7 +990,7 @@
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"-0201\" is out of type int8 min/max bounds.).",
-            "Schema location \"/DF_OCT2:port\".");
+            "/DF_OCT2:port", 0);
 
     /* TEST DEFAULT VALUE OCTAL ERROR */
     schema = MODULE_CREATE_YIN("DF_OCT3",
@@ -1000,7 +1000,7 @@
             "</leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Value \"0200\" is out of type int8 min/max bounds.).",
-            "Schema location \"/DF_OCT3:port\".");
+            "/DF_OCT3:port", 0);
 }
 
 static void
@@ -1117,20 +1117,15 @@
     TEST_SUCCESS_XML("defs", "0", INT8, "0", 0);
     TEST_SUCCESS_XML("defs", "-0", INT8, "0", 0);
     TEST_ERROR_XML("defs", "-1");
-    CHECK_LOG_CTX("Unsatisfied range - value \"-1\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"-1\" is out of the allowed range.", "/defs:port", 1);
     TEST_ERROR_XML("defs", "51");
-    CHECK_LOG_CTX("Unsatisfied range - value \"51\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"51\" is out of the allowed range.", "/defs:port", 1);
     TEST_ERROR_XML("defs", "106");
-    CHECK_LOG_CTX("Unsatisfied range - value \"106\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"106\" is out of the allowed range.", "/defs:port", 1);
     TEST_ERROR_XML("defs", "104");
-    CHECK_LOG_CTX("Unsatisfied range - value \"104\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"104\" is out of the allowed range.", "/defs:port", 1);
     TEST_ERROR_XML("defs", "60");
-    CHECK_LOG_CTX("Unsatisfied range - value \"60\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"60\" is out of the allowed range.", "/defs:port", 1);
 
     schema = MODULE_CREATE_YANG("T0", "leaf port {type int8; }");
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
@@ -1144,17 +1139,13 @@
     TEST_SUCCESS_XML("T0", "-015", INT8, "-15", -15);
     TEST_SUCCESS_XML("T0", "015", INT8, "15", 15);
     TEST_ERROR_XML("T0", "-129");
-    CHECK_LOG_CTX("Value \"-129\" is out of type int8 min/max bounds.",
-            "Schema location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Value \"-129\" is out of type int8 min/max bounds.", "/T0:port", 1);
     TEST_ERROR_XML("T0", "128");
-    CHECK_LOG_CTX("Value \"128\" is out of type int8 min/max bounds.",
-            "Schema location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Value \"128\" is out of type int8 min/max bounds.", "/T0:port", 1);
     TEST_ERROR_XML("T0", "256");
-    CHECK_LOG_CTX("Value \"256\" is out of type int8 min/max bounds.",
-            "Schema location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Value \"256\" is out of type int8 min/max bounds.", "/T0:port", 1);
     TEST_ERROR_XML("T0", "1024");
-    CHECK_LOG_CTX("Value \"1024\" is out of type int8 min/max bounds.",
-            "Schema location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Value \"1024\" is out of type int8 min/max bounds.", "/T0:port", 1);
 
     /*
      * default value
@@ -1195,7 +1186,7 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     TEST_ERROR_XML("T2", "120");
-    CHECK_LOG_CTX_APPTAG("invalid range of value", "Schema location \"/T2:port\", line number 1.", "range-violation");
+    CHECK_LOG_CTX_APPTAG("invalid range of value", "/T2:port", 1, "range-violation");
 }
 
 static void
@@ -1218,20 +1209,15 @@
     TEST_SUCCESS_JSON("defs", "0", INT8, "0", 0);
     TEST_SUCCESS_JSON("defs", "-0", INT8, "0", 0);
     TEST_ERROR_JSON("defs", "-1");
-    CHECK_LOG_CTX("Unsatisfied range - value \"-1\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"-1\" is out of the allowed range.", "/defs:port", 1);
     TEST_ERROR_JSON("defs", "51");
-    CHECK_LOG_CTX("Unsatisfied range - value \"51\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"51\" is out of the allowed range.", "/defs:port", 1);
     TEST_ERROR_JSON("defs", "106");
-    CHECK_LOG_CTX("Unsatisfied range - value \"106\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"106\" is out of the allowed range.", "/defs:port", 1);
     TEST_ERROR_JSON("defs", "104");
-    CHECK_LOG_CTX("Unsatisfied range - value \"104\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"104\" is out of the allowed range.", "/defs:port", 1);
     TEST_ERROR_JSON("defs", "60");
-    CHECK_LOG_CTX("Unsatisfied range - value \"60\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"60\" is out of the allowed range.", "/defs:port", 1);
 
     schema = MODULE_CREATE_YANG("T0", "leaf port {type int8; }");
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
@@ -1243,26 +1229,19 @@
     TEST_SUCCESS_JSON("T0", "127", INT8, "127", 127);
     /* leading zeros */
     TEST_ERROR_JSON("T0", "015");
-    CHECK_LOG_CTX("Invalid character sequence \"15}\", expected a JSON object-end or next item.",
-            "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"15}\", expected a JSON object-end or next item.", NULL, 1);
     TEST_ERROR_JSON("T0", "-015");
-    CHECK_LOG_CTX("Invalid character sequence \"15}\", expected a JSON object-end or next item.",
-            "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"15}\", expected a JSON object-end or next item.", NULL, 1);
     TEST_ERROR_JSON("defs", "+50");
-    CHECK_LOG_CTX("Invalid character sequence \"+50}\", expected a JSON value.",
-            "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"+50}\", expected a JSON value.", NULL, 1);
     TEST_ERROR_JSON("T0", "-129");
-    CHECK_LOG_CTX("Value \"-129\" is out of type int8 min/max bounds.",
-            "Schema location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Value \"-129\" is out of type int8 min/max bounds.", "/T0:port", 1);
     TEST_ERROR_JSON("T0", "128");
-    CHECK_LOG_CTX("Value \"128\" is out of type int8 min/max bounds.",
-            "Schema location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Value \"128\" is out of type int8 min/max bounds.", "/T0:port", 1);
     TEST_ERROR_JSON("T0", "256");
-    CHECK_LOG_CTX("Value \"256\" is out of type int8 min/max bounds.",
-            "Schema location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Value \"256\" is out of type int8 min/max bounds.", "/T0:port", 1);
     TEST_ERROR_JSON("T0", "1024");
-    CHECK_LOG_CTX("Value \"1024\" is out of type int8 min/max bounds.",
-            "Schema location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Value \"1024\" is out of type int8 min/max bounds.", "/T0:port", 1);
 
     /*
      * default value
@@ -1360,8 +1339,7 @@
             "yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"5\">"
             "121</port>";
     CHECK_PARSE_LYD_PARAM(diff_expected, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, model_1);
-    CHECK_LOG_CTX("Unsatisfied range - value \"121\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"121\" is out of the allowed range.", "/defs:port", 1);
 
     /*
      * diff from default value
diff --git a/tests/utests/types/leafref.c b/tests/utests/types/leafref.c
index 21e91cd..5d510b9 100644
--- a/tests/utests/types/leafref.c
+++ b/tests/utests/types/leafref.c
@@ -131,7 +131,7 @@
     TEST_ERROR_XML2("<leaflisttarget xmlns=\"urn:tests:defs\">x</leaflisttarget>",
             "defs", "", "lref", "y", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"y\" - no target instance \"/leaflisttarget\" with the same value.",
-            "Data location \"/defs:lref\".", "instance-required");
+            "/defs:lref", 0, "instance-required");
 
     TEST_ERROR_XML2("<list xmlns=\"urn:tests:defs\"><id>x</id><targets>a</targets><targets>b</targets></list>"
             "<list xmlns=\"urn:tests:defs\"><id>y</id><targets>x</targets><targets>y</targets></list>"
@@ -139,36 +139,36 @@
             "defs", "", "lref2", "b", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"b\" - "
             "no target instance \"../list[id = current()/../str-norestr]/targets\" with the same value.",
-            "Data location \"/defs:lref2\".", "instance-required");
+            "/defs:lref2", 0, "instance-required");
 
     TEST_ERROR_XML2("<list xmlns=\"urn:tests:defs\"><id>x</id><targets>a</targets><targets>b</targets></list>"
             "<list xmlns=\"urn:tests:defs\"><id>y</id><targets>x</targets><targets>y</targets></list>",
             "defs", "", "lref2", "b", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"b\" - "
             "no target instance \"../list[id = current()/../str-norestr]/targets\" with the same value.",
-            "Data location \"/defs:lref2\".", "instance-required");
+            "/defs:lref2", 0, "instance-required");
 
     TEST_ERROR_XML2("<str-norestr xmlns=\"urn:tests:defs\">y</str-norestr>",
             "defs", "", "lref2", "b", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"b\" - "
             "no target instance \"../list[id = current()/../str-norestr]/targets\" with the same value.",
-            "Data location \"/defs:lref2\".", "instance-required");
+            "/defs:lref2", 0, "instance-required");
 
     TEST_ERROR_XML2("<str-norestr xmlns=\"urn:tests:defs\">y</str-norestr>",
             "leafrefs", "", "c", "<l><id>x</id><value>x</value><lr1>a</lr1></l>", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"a\" - no target instance \"../../../t:str-norestr\" with the same value.",
-            "Data location \"/leafrefs:c/l[id='x'][value='x']/lr1\".", "instance-required");
+            "/leafrefs:c/l[id='x'][value='x']/lr1", 0, "instance-required");
 
     TEST_ERROR_XML2("<str-norestr xmlns=\"urn:tests:defs\">z</str-norestr>",
             "leafrefs", "", "c", "<l><id>y</id><value>y</value></l><l><id>x</id><value>x</value><lr2>z</lr2></l>", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"z\" - no target instance \"../../l[id=current()/../../../t:str-norestr]"
             "[value=current()/../../../t:str-norestr]/value\" with the same value.",
-            "Data location \"/leafrefs:c/l[id='x'][value='x']/lr2\".", "instance-required");
+            "/leafrefs:c/l[id='x'][value='x']/lr2", 0, "instance-required");
 
     TEST_ERROR_XML2("",
             "defs", "", "lref", "%n", LY_EVALID);
     CHECK_LOG_CTX_APPTAG("Invalid leafref value \"%n\" - no target instance \"/leaflisttarget\" with the same value.",
-            "Data location \"/defs:lref\".", "instance-required");
+            "/defs:lref", 0, "instance-required");
 }
 
 static void
@@ -257,7 +257,7 @@
             "leaf r1 {type leafref {path \"deref(../l1)/../l2/t2\";}}");
 
     UTEST_INVALID_MODULE(schema1, LYS_IN_YANG, NULL, LY_EVALID)
-    CHECK_LOG_CTX("The deref function target node \"l1\" is not leaf nor leaflist", "Schema location \"/xp_test:r1\".");
+    CHECK_LOG_CTX("The deref function target node \"l1\" is not leaf nor leaflist", "/xp_test:r1", 0);
 
     schema2 = MODULE_CREATE_YANG("xp_test",
             "list l1 {key t1;"
@@ -270,7 +270,7 @@
             "leaf r2 {type leafref {path \"deref(../r1)/../l2/t2\";}}");
 
     UTEST_INVALID_MODULE(schema2, LYS_IN_YANG, NULL, LY_EVALID)
-    CHECK_LOG_CTX("The deref function target node \"r1\" is not leafref", "Schema location \"/xp_test:r2\".");
+    CHECK_LOG_CTX("The deref function target node \"r1\" is not leafref", "/xp_test:r2", 0);
 }
 
 int
diff --git a/tests/utests/types/string.c b/tests/utests/types/string.c
index ce5ae8d..ebe4ec6 100644
--- a/tests/utests/types/string.c
+++ b/tests/utests/types/string.c
@@ -200,15 +200,15 @@
     /* ERROR TESTS NEGATIVE VALUE */
     schema = MODULE_CREATE_YANG("ERR0", "leaf port {type string {length \"-1 .. 20\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EDENIED);
-    CHECK_LOG_CTX("Invalid length restriction - value \"-1\" does not fit the type limitations.", "Path \"/ERR0:port\".");
+    CHECK_LOG_CTX("Invalid length restriction - value \"-1\" does not fit the type limitations.", "/ERR0:port", 0);
 
     schema = MODULE_CREATE_YANG("ERR1", "leaf port {type string {length \"100 .. 18446744073709551616\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Invalid length restriction - invalid value \"18446744073709551616\".", "Path \"/ERR1:port\".");
+    CHECK_LOG_CTX("Invalid length restriction - invalid value \"18446744073709551616\".", "/ERR1:port", 0);
 
     schema = MODULE_CREATE_YANG("ERR2", "leaf port {type string {length \"10 .. 20 | 20 .. 30\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EEXIST);
-    CHECK_LOG_CTX("Invalid length restriction - values are not in ascending order (20).", "Path \"/ERR2:port\".");
+    CHECK_LOG_CTX("Invalid length restriction - values are not in ascending order (20).", "/ERR2:port", 0);
 
     schema = MODULE_CREATE_YANG("ERR3",
             "typedef my_type {"
@@ -216,7 +216,7 @@
             "}"
             "leaf port {type my_type {length \"-1 .. 15\";}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EDENIED);
-    CHECK_LOG_CTX("Invalid length restriction - value \"-1\" does not fit the type limitations.", "Path \"/ERR3:port\".");
+    CHECK_LOG_CTX("Invalid length restriction - value \"-1\" does not fit the type limitations.", "/ERR3:port", 0);
 
     /*
      * PATTERN
@@ -286,7 +286,7 @@
             "}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Regular expression \"[a-zA-Z_[a-zA-Z0-9\\-_.*\" is not valid (\"\": missing terminating ] for character class).",
-            "Path \"/TPATTERN_ERR_0:port\".");
+            "/TPATTERN_ERR_0:port", 0);
 
     schema = MODULE_CREATE_YANG("TDEFAULT_0",
             "typedef my_type {"
@@ -323,14 +323,14 @@
             "}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Regular expression \"\\[a]b\" is not valid (\"]b\": character group doesn't begin with '[').",
-            "Path \"/TPATTERN_BC_ERR_1:port\".");
+            "/TPATTERN_BC_ERR_1:port", 0);
 
     schema = MODULE_CREATE_YANG("TPATTERN_BC_ERR_2", "leaf port {type string {"
             "pattern \"\\\\[a]b\";" /* pattern "\\[a]b"; */
             "}}");
     UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
     CHECK_LOG_CTX("Regular expression \"\\[a]b\" is not valid (\"]b\": character group doesn't begin with '[').",
-            "Path \"/TPATTERN_BC_ERR_2:port\".");
+            "/TPATTERN_BC_ERR_2:port", 0);
 
     /* PATTERN AND LENGTH */
     schema = MODULE_CREATE_YANG("TPL_0",
@@ -467,26 +467,26 @@
     schema = MODULE_CREATE_YIN("ERR0", "<leaf name=\"port\"> <type name=\"string\">"
             "<length value =\"-1 .. 20\"/> </type></leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EDENIED);
-    CHECK_LOG_CTX("Invalid length restriction - value \"-1\" does not fit the type limitations.", "Path \"/ERR0:port\".");
+    CHECK_LOG_CTX("Invalid length restriction - value \"-1\" does not fit the type limitations.", "/ERR0:port", 0);
 
     schema = MODULE_CREATE_YIN("ERR1", "<leaf name=\"port\"> <type name=\"string\">"
             "<length value=\"100 .. 18446744073709551616\"/>"
             "</type> </leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-    CHECK_LOG_CTX("Invalid length restriction - invalid value \"18446744073709551616\".", "Path \"/ERR1:port\".");
+    CHECK_LOG_CTX("Invalid length restriction - invalid value \"18446744073709551616\".", "/ERR1:port", 0);
 
     schema = MODULE_CREATE_YIN("ERR2", "<leaf name=\"port\">"
             "<type name=\"string\"> <length value=\"10 .. 20 | 20 .. 30\"/>"
             "</type> </leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EEXIST);
-    CHECK_LOG_CTX("Invalid length restriction - values are not in ascending order (20).", "Path \"/ERR2:port\".");
+    CHECK_LOG_CTX("Invalid length restriction - values are not in ascending order (20).", "/ERR2:port", 0);
 
     schema = MODULE_CREATE_YIN("ERR3",
             "<typedef name=\"my_type\"> <type name=\"string\"/> </typedef>"
             "<leaf name=\"port\"> <type name=\"my_type\"> <length value=\"-1 .. 15\"/>"
             "</type> </leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EDENIED);
-    CHECK_LOG_CTX("Invalid length restriction - value \"-1\" does not fit the type limitations.", "Path \"/ERR3:port\".");
+    CHECK_LOG_CTX("Invalid length restriction - value \"-1\" does not fit the type limitations.", "/ERR3:port", 0);
 
     /*
      * PATTERN
@@ -557,7 +557,7 @@
             "</type> </leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Regular expression \"[a-zA-Z_][a-zA-Z0-9\\-_.*\" is not valid (\"\": missing terminating ] for character class).",
-            "Path \"/TPATTERN_ERR_0:port\".");
+            "/TPATTERN_ERR_0:port", 0);
 
     /*
      * DEFAUT VALUE
@@ -619,7 +619,7 @@
             "<leaf name=\"port\"> <type name=\"my_type\"/> </leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Unsatisfied length - string \"a1i-j<\" length is not allowed.).",
-            "Schema location \"/TDEFAULT_2:port\".");
+            "/TDEFAULT_2:port", 0);
 
     schema = MODULE_CREATE_YIN("TDEFAULT_3",
             "<typedef name=\"my_type\">"
@@ -629,7 +629,7 @@
             "<leaf name=\"port\"><type name=\"my_type\"> <pattern value=\"bcd.*\"/> </type></leaf>");
     UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
     CHECK_LOG_CTX("Invalid default - value does not fit the type (Unsatisfied pattern - \"a1i-j<\" does not conform to \"bcd.*\".).",
-            "Schema location \"/TDEFAULT_3:port\".");
+            "/TDEFAULT_3:port", 0);
 
 }
 
@@ -737,12 +737,11 @@
 
     /* error */
     TEST_ERROR_XML("T0", "< df");
-    CHECK_LOG_CTX("Child element \"df\" inside a terminal node \"port\" found.",
-            "Data location \"/T0:port\", line number 1.");
+    CHECK_LOG_CTX("Child element \"df\" inside a terminal node \"port\" found.", "/T0:port", 1);
     TEST_ERROR_XML("T0", "&text;");
-    CHECK_LOG_CTX("Entity reference \"&text;</po\" not supported, only predefined references allowed.", "Line number 1.");
+    CHECK_LOG_CTX("Entity reference \"&text;</po\" not supported, only predefined references allowed.", NULL, 1);
     TEST_ERROR_XML("T0", "\"&#x8;\"");
-    CHECK_LOG_CTX("Invalid character reference \"&#x8;\"</port\" (0x00000008).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character reference \"&#x8;\"</port\" (0x00000008).", NULL, 1);
 
     /* TEST INVERTED PATTERN ADN LENGTH */
     schema = MODULE_CREATE_YANG("T1", "leaf port {type string {"
@@ -756,14 +755,13 @@
     TEST_SUCCESS_XML("T1", "abcde",    STRING, "abcde");
     TEST_SUCCESS_XML("T1", "abcde&lt;", STRING, "abcde<");
     TEST_ERROR_XML("T1", "p4abc");
-    CHECK_LOG_CTX_APPTAG("invalid pattern of value", "Schema location \"/T1:port\", line number 1.", "pattern-violation");
+    CHECK_LOG_CTX_APPTAG("invalid pattern of value", "/T1:port", 1, "pattern-violation");
     /* size 20 */
     TEST_SUCCESS_XML("T1", "ahojahojahojahojahoj", STRING, "ahojahojahojahojahoj");
     TEST_SUCCESS_XML("T1", "abc-de", STRING, "abc-de");
     /* ERROR LENGTH  */
     TEST_ERROR_XML("T1", "p4a&lt;");
-    CHECK_LOG_CTX("Unsatisfied length - string \"p4a<\" length is not allowed.",
-            "Schema location \"/T1:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied length - string \"p4a<\" length is not allowed.", "/T1:port", 1);
 
     /* TEST DEFAULT VALUE */
     schema = MODULE_CREATE_YANG("T2",
@@ -806,11 +804,9 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
     TEST_SUCCESS_XML("T_UTF8", "€€€€€",    STRING, "€€€€€");
     TEST_ERROR_XML("T_UTF8", "€€€");
-    CHECK_LOG_CTX("Unsatisfied length - string \"€€€\" length is not allowed.",
-            "Schema location \"/T_UTF8:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied length - string \"€€€\" length is not allowed.", "/T_UTF8:port", 1);
     TEST_ERROR_XML("T_UTF8", "€€€€€€€€");
-    CHECK_LOG_CTX("Unsatisfied pattern - \"€€€€€€€€\" does not conform to \"[€]{5,7}\".",
-            "Schema location \"/T_UTF8:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied pattern - \"€€€€€€€€\" does not conform to \"[€]{5,7}\".", "/T_UTF8:port", 1);
 
     /* ANCHOR TEST ^$ is implicit */
     schema = MODULE_CREATE_YANG("T_ANCHOR", "leaf port {type string {"
@@ -818,11 +814,9 @@
             "}}");
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
     TEST_ERROR_XML("T_ANCHOR", "abc");
-    CHECK_LOG_CTX("Unsatisfied pattern - \"abc\" does not conform to \"a.*b\".",
-            "Schema location \"/T_ANCHOR:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied pattern - \"abc\" does not conform to \"a.*b\".", "/T_ANCHOR:port", 1);
     TEST_ERROR_XML("T_ANCHOR", "cab");
-    CHECK_LOG_CTX("Unsatisfied pattern - \"cab\" does not conform to \"a.*b\".",
-            "Schema location \"/T_ANCHOR:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied pattern - \"cab\" does not conform to \"a.*b\".", "/T_ANCHOR:port", 1);
 }
 
 static void
@@ -858,20 +852,19 @@
 
     /* ERROR invalid json string */
     TEST_ERROR_JSON("T0", "\n");
-    CHECK_LOG_CTX("Invalid character in JSON string \"\n\" (0x0000000a).",
-            "Line number 1.");
+    CHECK_LOG_CTX("Invalid character in JSON string \"\n\" (0x0000000a).", NULL, 1);
     /* backspace and form feed are valid JSON escape sequences, but the control characters they represents are not allowed values for YANG string type */
     TEST_ERROR_JSON("T0", "\\b");
-    CHECK_LOG_CTX("Invalid character reference \"\\b\" (0x00000008).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character reference \"\\b\" (0x00000008).", NULL, 1);
 
     TEST_ERROR_JSON("T0", "\\f");
-    CHECK_LOG_CTX("Invalid character reference \"\\f\" (0x0000000c).", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character reference \"\\f\" (0x0000000c).", NULL, 1);
 
     TEST_ERROR_JSON("T0", "\"");
-    CHECK_LOG_CTX("Invalid character sequence \"\"}\", expected a JSON object-end or next item.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character sequence \"\"}\", expected a JSON object-end or next item.", NULL, 1);
 
     TEST_ERROR_JSON("T0", "aabb \\x");
-    CHECK_LOG_CTX("Invalid character escape sequence \\x.", "Line number 1.");
+    CHECK_LOG_CTX("Invalid character escape sequence \\x.", NULL, 1);
 
     /* TEST INVERTED PATTERN ADN LENGTH */
     schema = MODULE_CREATE_YANG("T1", "leaf port {type string {"
@@ -883,15 +876,13 @@
     /* inverted value */
     TEST_SUCCESS_JSON("T1", "a\\nbcde",     STRING, "a\nbcde");
     TEST_ERROR_JSON("T1", "p4abc\\n");
-    CHECK_LOG_CTX("Unsatisfied pattern - \"p4abc\n\" does not conform to inverted \"p4.*\\n\".",
-            "Schema location \"/T1:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied pattern - \"p4abc\n\" does not conform to inverted \"p4.*\\n\".", "/T1:port", 1);
     /* size 20 */
     TEST_SUCCESS_JSON("T1", "ahojahojaho\\njahojaho", STRING, "ahojahojaho\njahojaho");
     TEST_SUCCESS_JSON("T1", "abc\\n-de", STRING, "abc\n-de");
     /* ERROR LENGTH  */
     TEST_ERROR_JSON("T1", "p4a\u042F");
-    CHECK_LOG_CTX("Unsatisfied length - string \"p4aЯ\" length is not allowed.",
-            "Schema location \"/T1:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied length - string \"p4aЯ\" length is not allowed.", "/T1:port", 1);
 
     /* TEST DEFAULT VALUE */
     schema = MODULE_CREATE_YANG("T_DEFAULT2",
@@ -928,11 +919,9 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
     TEST_SUCCESS_JSON("T_UTF8", "€€€€€",    STRING, "€€€€€");
     TEST_ERROR_JSON("T_UTF8", "€€€");
-    CHECK_LOG_CTX("Unsatisfied length - string \"€€€\" length is not allowed.",
-            "Schema location \"/T_UTF8:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied length - string \"€€€\" length is not allowed.", "/T_UTF8:port", 1);
     TEST_ERROR_JSON("T_UTF8", "€€€€€€€€");
-    CHECK_LOG_CTX("Unsatisfied pattern - \"€€€€€€€€\" does not conform to \"[€]{5,7}\".",
-            "Schema location \"/T_UTF8:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied pattern - \"€€€€€€€€\" does not conform to \"[€]{5,7}\".", "/T_UTF8:port", 1);
 
     /* ANCHOR TEST ^$ is implicit */
     schema = MODULE_CREATE_YANG("T_ANCHOR", "leaf port {type string {"
@@ -940,11 +929,9 @@
             "}}");
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
     TEST_ERROR_JSON("T_ANCHOR", "abc");
-    CHECK_LOG_CTX("Unsatisfied pattern - \"abc\" does not conform to \"a.*b\".",
-            "Schema location \"/T_ANCHOR:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied pattern - \"abc\" does not conform to \"a.*b\".", "/T_ANCHOR:port", 1);
     TEST_ERROR_JSON("T_ANCHOR", "cb");
-    CHECK_LOG_CTX("Unsatisfied pattern - \"cb\" does not conform to \"a.*b\".",
-            "Schema location \"/T_ANCHOR:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied pattern - \"cb\" does not conform to \"a.*b\".", "/T_ANCHOR:port", 1);
 }
 
 static void
@@ -1010,8 +997,7 @@
             "yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\" 555 555\">"
             "121</port>";
     CHECK_PARSE_LYD_PARAM(diff_expected, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, model_1);
-    CHECK_LOG_CTX("Unsatisfied length - string \"121\" length is not allowed.",
-            "Schema location \"/T_DIFF:port\", line number 1.");
+    CHECK_LOG_CTX("Unsatisfied length - string \"121\" length is not allowed.", "/T_DIFF:port", 1);
 
     /* diff from default value */
     data_1 = "<cont xmlns=\"urn:tests:T_DIFF1\"></cont>";
diff --git a/tests/utests/types/uint16.c b/tests/utests/types/uint16.c
index 7cbb014..2ded9eb 100644
--- a/tests/utests/types/uint16.c
+++ b/tests/utests/types/uint16.c
@@ -60,8 +60,7 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     TEST_ERROR_XML("defs", "\n 1500 \t\n  ");
-    CHECK_LOG_CTX("Unsatisfied range - value \"1500\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 3.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"1500\" is out of the allowed range.", "/defs:port", 3);
 }
 
 int
diff --git a/tests/utests/types/uint32.c b/tests/utests/types/uint32.c
index e3e6377..89221c4 100644
--- a/tests/utests/types/uint32.c
+++ b/tests/utests/types/uint32.c
@@ -60,8 +60,7 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     TEST_ERROR_XML("defs", "-10");
-    CHECK_LOG_CTX("Value \"-10\" is out of type uint32 min/max bounds.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Value \"-10\" is out of type uint32 min/max bounds.", "/defs:port", 1);
 }
 
 int
diff --git a/tests/utests/types/uint64.c b/tests/utests/types/uint64.c
index 401c37c..71e024e 100644
--- a/tests/utests/types/uint64.c
+++ b/tests/utests/types/uint64.c
@@ -60,16 +60,13 @@
     UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
 
     TEST_ERROR_XML("defs", "");
-    CHECK_LOG_CTX("Invalid type uint64 empty value.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Invalid type uint64 empty value.", "/defs:port", 1);
 
     TEST_ERROR_XML("defs", "   ");
-    CHECK_LOG_CTX("Invalid type uint64 empty value.",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Invalid type uint64 empty value.", "/defs:port", 1);
 
     TEST_ERROR_XML("defs", "10  xxx");
-    CHECK_LOG_CTX("Invalid type uint64 value \"10  xxx\".",
-            "Schema location \"/defs:port\", line number 1.");
+    CHECK_LOG_CTX("Invalid type uint64 value \"10  xxx\".", "/defs:port", 1);
 }
 
 int
diff --git a/tests/utests/types/uint8.c b/tests/utests/types/uint8.c
index dad4039..89b89a7 100644
--- a/tests/utests/types/uint8.c
+++ b/tests/utests/types/uint8.c
@@ -62,8 +62,7 @@
     TEST_SUCCESS_XML("defs", "\n 150 \t\n  ", UINT8, "150", 150);
 
     TEST_ERROR_XML("defs", "\n 15 \t\n  ");
-    CHECK_LOG_CTX("Unsatisfied range - value \"15\" is out of the allowed range.",
-            "Schema location \"/defs:port\", line number 3.");
+    CHECK_LOG_CTX("Unsatisfied range - value \"15\" is out of the allowed range.", "/defs:port", 3);
 }
 
 int
diff --git a/tests/utests/types/union.c b/tests/utests/types/union.c
index d23cbf1..07c386e 100644
--- a/tests/utests/types/union.c
+++ b/tests/utests/types/union.c
@@ -110,7 +110,7 @@
             "    libyang 2 - identityref, version 1: Invalid identityref \"123456789012345678901\" value - identity not found in module \"defs\".\n"
             "    libyang 2 - instance-identifier, version 1: Invalid instance-identifier \"123456789012345678901\" value - syntax error.\n"
             "    libyang 2 - string, version 1: Unsatisfied length - string \"123456789012345678901\" length is not allowed.\n",
-            "Schema location \"/defs:un1\", line number 1.");
+            "/defs:un1", 1);
 }
 
 static void
diff --git a/tests/utests/types/yang_types.c b/tests/utests/types/yang_types.c
index 0f78455..56778c4 100644
--- a/tests/utests/types/yang_types.c
+++ b/tests/utests/types/yang_types.c
@@ -114,13 +114,13 @@
     TEST_ERROR_XML("a", "l", "2005-05-31T23:15:15.-08:00", LY_EVALID);
     CHECK_LOG_CTX("Unsatisfied pattern - \"2005-05-31T23:15:15.-08:00\" does not conform to "
             "\"\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[\\+\\-]\\d{2}:\\d{2})\".",
-            "Schema location \"/a:l\", line number 1.");
+            "/a:l", 1);
 
     TEST_ERROR_XML("a", "l", "2023-16-15T20:13:01+01:00", LY_EINVAL);
-    CHECK_LOG_CTX("Invalid date-and-time month \"15\".", "Schema location \"/a:l\", line number 1.");
+    CHECK_LOG_CTX("Invalid date-and-time month \"15\".", "/a:l", 1);
 
     TEST_ERROR_XML("a", "l", "2023-10-15T20:13:01+95:00", LY_EINVAL);
-    CHECK_LOG_CTX("Invalid date-and-time timezone hour \"95\".", "Schema location \"/a:l\", line number 1.");
+    CHECK_LOG_CTX("Invalid date-and-time timezone hour \"95\".", "/a:l", 1);
 
     /* hex-string */
     TEST_SUCCESS_XML("a", "l21", "DB:BA:12:54:fa", STRING, "db:ba:12:54:fa");
@@ -138,12 +138,11 @@
     TEST_SUCCESS_XML("a", "l3", "/l3[. = '4']", STRING, "/l3[.='4']");
 
     TEST_ERROR_XML("a", "l3", "/a:l3[. = '4']", LY_EVALID);
-    CHECK_LOG_CTX("Failed to resolve prefix \"a\".", "Schema location \"/a:l3\", line number 1.");
+    CHECK_LOG_CTX("Failed to resolve prefix \"a\".", "/a:l3", 1);
     TEST_ERROR_XML("a\" xmlns:yl=\"urn:ietf:params:xml:ns:yang:ietf-yang-library", "l3",
             "/yl:yang-library/yl:datastore/yl::name", LY_EVALID);
-    CHECK_LOG_CTX("Storing value failed.", "Schema location \"/a:l3\", line number 1.");
-    CHECK_LOG_CTX("Invalid character 'y'[31] of expression '/yl:yang-library/yl:datastore/yl::name'.",
-            "Schema location \"/a:l3\", line number 1.");
+    CHECK_LOG_CTX("Storing value failed.", "/a:l3", 1);
+    CHECK_LOG_CTX("Invalid character 'y'[31] of expression '/yl:yang-library/yl:datastore/yl::name'.", "/a:l3", 1);
 }
 
 static void
diff --git a/tests/utests/utests.h b/tests/utests/utests.h
index 0e0649d..6824db4 100644
--- a/tests/utests/utests.h
+++ b/tests/utests/utests.h
@@ -93,9 +93,6 @@
 struct utest_context {
     struct ly_ctx *ctx;  /**< libyang context */
 
-    char *err_msg;       /**< Directly logged error message */
-    char *err_path;      /**< Directly logged error path */
-
     struct ly_in *in;    /**< Input handler */
     struct ly_out *out;  /**< Outpu handler */
 
@@ -1216,8 +1213,8 @@
         LY_ERR __r = lys_parse(_UC->ctx, _UC->in, FORMAT, FEATURES, MOD); \
         if (__r != LY_SUCCESS) { \
             print_message("[  MSG     ] Module parsing failed:\n"); \
-            for (struct ly_err_item *e = ly_err_first(_UC->ctx); e; e = e->next) { \
-                print_message("[  MSG     ] \t%s Path %s\n", e->msg, e->path); \
+            for (const struct ly_err_item *e = ly_err_first(_UC->ctx); e; e = e->next) { \
+                print_message("[  MSG     ] \t%s Schema path %s\n", e->msg, e->schema_path); \
             } \
             fail(); \
         } \
@@ -1231,24 +1228,30 @@
  * @param[in] MSG Expected error message.
  */
 #define CHECK_LOG_LASTMSG(MSG) \
-    CHECK_STRING(ly_last_errmsg(), MSG)
+    CHECK_STRING(ly_last_logmsg(), MSG)
 
 /**
  * @brief Check expected last error in libyang context, which is then cleared. Can be called repeatedly to check
  * several errors. If NULL is provided as MSG, no error info record (NULL) is expected.
  *
  * @param[in] MSG Expected error message.
- * @param[in] PATH Expected error path.
+ * @param[in] PATH Expected error data/schema path.
+ * @param[in] LINE Expected error line.
  */
-#define CHECK_LOG_CTX(MSG, PATH) \
+#define CHECK_LOG_CTX(MSG, PATH, LINE) \
     { \
-        struct ly_err_item *_e = ly_err_last(_UC->ctx); \
+        struct ly_err_item *_e = (struct ly_err_item *)ly_err_last(_UC->ctx); \
         if (!MSG) { \
             assert_null(_e); \
         } else { \
             assert_non_null(_e); \
             CHECK_STRING(_e->msg, MSG); \
-            CHECK_STRING(_e->path, PATH); \
+            if (_e->data_path) { \
+                CHECK_STRING(_e->data_path, PATH); \
+            } else { \
+                CHECK_STRING(_e->schema_path, PATH); \
+            } \
+            assert_int_equal(_e->line, LINE); \
         } \
         ly_err_clean(_UC->ctx, _e); \
     }
@@ -1257,18 +1260,24 @@
  * @brief Check expected error in libyang context including error-app-tag.
  *
  * @param[in] MSG Expected error message.
- * @param[in] PATH Expected error path.
+ * @param[in] PATH Expected error data/schema path.
+ * @param[in] LINE Expected error line.
  * @param[in] APPTAG Expected error-app-tag.
  */
-#define CHECK_LOG_CTX_APPTAG(MSG, PATH, APPTAG) \
+#define CHECK_LOG_CTX_APPTAG(MSG, PATH, LINE, APPTAG) \
     { \
-        struct ly_err_item *_e = ly_err_last(_UC->ctx); \
+        struct ly_err_item *_e = (struct ly_err_item *)ly_err_last(_UC->ctx); \
         if (!MSG) { \
             assert_null(_e); \
         } else { \
             assert_non_null(_e); \
             CHECK_STRING(_e->msg, MSG); \
-            CHECK_STRING(_e->path, PATH); \
+            if (_e->data_path) { \
+                CHECK_STRING(_e->data_path, PATH); \
+            } else { \
+                CHECK_STRING(_e->schema_path, PATH); \
+            } \
+            assert_int_equal(_e->line, LINE); \
             CHECK_STRING(_e->apptag, APPTAG); \
         } \
         ly_err_clean(_UC->ctx, _e); \
@@ -1280,26 +1289,6 @@
 #define UTEST_LOG_CTX_CLEAN \
     ly_err_clean(_UC->ctx, NULL)
 
-/**
- * @brief Clean up the logging callback's storage.
- */
-#define UTEST_LOG_CLEAN \
-    free(_UC->err_msg); \
-    free(_UC->err_path); \
-    _UC->err_msg = NULL; \
-    _UC->err_path = NULL;
-
-/**
- * @brief Check expected error directly logged via logging callback.
- * Useful mainly for messages logged by functions without access to libyang context.
- * @param[in] MSG Expected error message.
- * @param[in] PATH Expected error path.
- */
-#define CHECK_LOG(MSG, PATH) \
-    CHECK_STRING(_UC->err_msg, MSG); \
-    CHECK_STRING(_UC->err_path, PATH); \
-    UTEST_LOG_CLEAN
-
 #ifdef _UTEST_MAIN_
 /*
  * Functions inlined into each C source file including this header with _UTEST_MAIN_ defined
@@ -1310,27 +1299,6 @@
  */
 struct utest_context *current_utest_context;
 
-/* set to 0 to printing error messages to stderr instead of checking them in code */
-#define ENABLE_LOGGER_CHECKING 1
-
-/**
- * @brief Logging callback for libyang.
- */
-static void
-_utest_logger(LY_LOG_LEVEL level, const char *msg, const char *path)
-{
-    (void) level; /* unused */
-
-    if (ENABLE_LOGGER_CHECKING == 0) {
-        printf("\tERROR:\n\t\tMESSAGE: %s\n\t\tPATH: %s\n\t\tLEVEL: %i\n", msg, path, level);
-    } else {
-        free(current_utest_context->err_msg);
-        current_utest_context->err_msg = msg ? strdup(msg) : NULL;
-        free(current_utest_context->err_path);
-        current_utest_context->err_path = path ? strdup(path) : NULL;
-    }
-}
-
 /**
  * @brief Generic utest's setup
  */
@@ -1340,8 +1308,7 @@
     char *cur_tz;
 
     /* setup the logger */
-    ly_set_log_clb(_utest_logger, 1);
-    ly_log_options(LY_LOLOG | LY_LOSTORE);
+    ly_log_options(/*LY_LOLOG |*/ LY_LOSTORE);
 
     current_utest_context = calloc(1, sizeof *current_utest_context);
     assert_non_null(current_utest_context);
@@ -1350,9 +1317,6 @@
     /* libyang context */
     assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, 0, &current_utest_context->ctx));
 
-    /* clean all errors from the setup - usually warnings regarding the plugins directories */
-    UTEST_LOG_CLEAN;
-
     /* backup timezone, if any */
     cur_tz = getenv("TZ");
     if (cur_tz) {
@@ -1392,8 +1356,6 @@
 
     /* utest context */
     ly_in_free(current_utest_context->in, 0);
-    free(current_utest_context->err_msg);
-    free(current_utest_context->err_path);
     free(current_utest_context->orig_tz);
     free(current_utest_context);
     current_utest_context = NULL;
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index df51257..7572248 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -223,7 +223,7 @@
 }
 
 static void
-libyang_verbclb(LY_LOG_LEVEL level, const char *msg, const char *path)
+libyang_verbclb(LY_LOG_LEVEL level, const char *msg, const char *data_path, const char *schema_path, uint64_t line)
 {
     char *levstr;
 
@@ -241,8 +241,12 @@
         levstr = "dbg :";
         break;
     }
-    if (path) {
-        fprintf(stderr, "libyang %s %s (%s)\n", levstr, msg, path);
+    if (data_path) {
+        fprintf(stderr, "libyang %s %s (%s)\n", levstr, msg, data_path);
+    } else if (schema_path) {
+        fprintf(stderr, "libyang %s %s (%s)\n", levstr, msg, schema_path);
+    } else if (line) {
+        fprintf(stderr, "libyang %s %s (line %" PRIu64 ")\n", levstr, msg, line);
     } else {
         fprintf(stderr, "libyang %s %s\n", levstr, msg);
     }
@@ -719,7 +723,7 @@
     uint32_t u;
 
     /* set callback for printing libyang messages */
-    ly_set_log_clb(libyang_verbclb, 1);
+    ly_set_log_clb(libyang_verbclb);
 
     r = fill_context(argc, argv, &yo, &ctx);
     if (r < 0) {
diff --git a/tools/re/main.c b/tools/re/main.c
index 5e33536..5d1edd5 100644
--- a/tools/re/main.c
+++ b/tools/re/main.c
@@ -73,10 +73,9 @@
 }
 
 void
-pattern_error(LY_LOG_LEVEL level, const char *msg, const char *path)
+pattern_error(LY_LOG_LEVEL level, const char *msg, const char *UNUSED(data_path), const char *UNUSED(schema_path),
+        uint64_t UNUSED(line))
 {
-    (void) path; /* unused */
-
     if (level == LY_LLERR) {
         fprintf(stderr, "yangre error: %s\n", msg);
     }
@@ -301,7 +300,7 @@
 }
 
 static void
-print_verbose(struct ly_ctx *ctx, struct yr_pattern *patterns, int patterns_count, char *str, LY_ERR match)
+print_verbose(struct yr_pattern *patterns, int patterns_count, char *str, LY_ERR match)
 {
     int i;
 
@@ -315,7 +314,7 @@
     } else if (match == LY_EVALID) {
         fprintf(stdout, "result    : not matching\n");
     } else {
-        fprintf(stdout, "result    : error (%s)\n", ly_errmsg(ctx));
+        fprintf(stdout, "result    : error (%s)\n", ly_last_logmsg());
     }
 }
 
@@ -425,7 +424,7 @@
         goto cleanup;
     }
 
-    ly_set_log_clb(pattern_error, 0);
+    ly_set_log_clb(pattern_error);
     if (lys_parse_mem(ctx, modstr, LYS_IN_YANG, &mod) || !mod->compiled || !mod->compiled->data) {
         goto cleanup;
     }
@@ -434,7 +433,7 @@
     match = lyd_value_validate(ctx, mod->compiled->data, str, strlen(str), NULL, NULL, NULL);
 
     if (verbose) {
-        print_verbose(ctx, patterns, patterns_count, str, match);
+        print_verbose(patterns, patterns_count, str, match);
     }
     if (match == LY_SUCCESS) {
         ret = 0;