Skip to content

juleswhi/stardust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stardust 🌠

Beautiful Zig Logging Library

STARDUST_LOGO(1)

Install

To use Stardust, run the following command to add it to your build.zig.zon

zig fetch --save git+https://github.com/juleswhi/stardust.git#main

Then add these lines to your build.zig

const stardust = b.dependency("stardust", .{
    .target = target,
    .optimize = optimize,
});

exe.root_module.addImport("sd", stardust.module("stardust"));

Usage

stardust

Include Stardust in your project like this:

const sd = @import("sd");

Initiate the logging system

try sd.sd_setup(some_alloc, default_log_level);

To log some data, do the following:

  • Strings will be output a concatonated line
  • Strings beginning with a & will be a 'description'
  • To add trace details include @src()
  • Finally, choose the log level with a one of the following:
    • .info
    • .debug
    • .err
    • .fatal
sd.log(.{ "This is a debug", "&example description", @src(), .debug });
DEB This is a debug
  --> src/main.zig main 01:01
  |> example description

If you want a simple log, you only need some strings

sd.log(.{ "Making Tea.." });

This will use the global log level

INF Making Tea..

About

Colourful and minimalistic Zig logging library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages