context BUGFIX use context for logging
diff --git a/src/context.c b/src/context.c
index 98ae10f..d703ed2 100644
--- a/src/context.c
+++ b/src/context.c
@@ -504,8 +504,8 @@
             mod = ly_ctx_load_module(ctx_new, name, revision, feature_arr);
             free(feature_arr);
             if (!mod) {
-                LOGERR(NULL, LY_EINVAL, "Unable to load module %s@%s specified by yang library data.", name,
-                        revision ? revision : "<none>");
+                LOGERR(*ctx ? *ctx : LYD_CTX(tree), LY_EINVAL, "Unable to load module %s@%s specified by yang library data.",
+                        name, revision ? revision : "<none>");
                 ret = LY_EINVAL;
                 goto cleanup;
             }