Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata is not emitted / Log file is not written to #33

Closed
CuckooEXE opened this issue Mar 16, 2025 · 3 comments
Closed

Metadata is not emitted / Log file is not written to #33

CuckooEXE opened this issue Mar 16, 2025 · 3 comments

Comments

@CuckooEXE
Copy link

CuckooEXE commented Mar 16, 2025

Hi! Would love to use nexlog in my Zig projects, but unfortunately it looks like the metadata and the enableFileLogging logic doesn't work. Here is the code I'm executing (from your example in the README):

const std = @import("std");
const nexlog = @import("nexlog");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();
    const allocator = gpa.allocator();

    var builder = nexlog.LogBuilder.init();
    try builder
        .setMinLevel(.debug)
        .enableColors(true)
        .enableFileLogging(true, "app.log")
        .enableMetadata(true)
        .build(allocator);
    defer nexlog.deinit();

    // Get logger instance
    const logger = nexlog.getDefaultLogger().?;

    // Create metadata
    const metadata = nexlog.LogMetadata{
        .timestamp = std.time.timestamp(),
        .thread_id = std.Thread.getCurrentId(),
        .file = @src().file,
        .line = @src().line,
        .function = @src().fn_name,
    };

    // Log messages
    try logger.log(.info, "Hello {s}", .{"world"}, metadata);
}

Output:

$ zig build run
[1742136349] [INFO] Hello world
$ cat app.log
$ zig version
0.14.0
error: Zig was built/linked incorrectly: LLVM and Clang have separate copies of libc++
       If you are dynamically linking LLVM, make sure you dynamically link libc++ too
@chrischtel
Copy link
Owner

chrischtel commented Mar 19, 2025

Hey @CuckooEXE, thank you very much for your interests. I kind of left this project alone, but I will get back to it. I will have a look into it.
I would suggest to look into the examples folder.

@chrischtel
Copy link
Owner

I also planned to rewrite the Metadata system, I am open to contribiutions!

@chrischtel
Copy link
Owner

Checkout the latest develop branch to use the new. The problem was that I didn't correctly implemented the formatting module and with that, the metadata did not work. I tested you're example and it worked for me.

if you have more problems, feature suggestions and ideas just create an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants