Giter VIP home page Giter VIP logo

rogu's Introduction

rogu

ログ (rogu, jap. log) is yet another taggable, human readable, colorful, structured logging package with a builder-like API. This package is mainly created to be used within shinpuru and other projects of mine. Feel free to use it too, but beware that this package is not optimized for performance.

Warning
Just wanna let you know, the API of this package is not yet final and might change in coming updates.

This package is very much inspired by the colored output style of charmbracelet/log and the builder API style of rs/zerolog.

Levels

Log levels can be set to a Logger via the SetLevel method. Levels are defined in the sub-package level. Levels can be interpreted from a string using the function LevelFromString. Below, you can see available levels with their numeral values, names and aliases. The given names and aliases are valid values which can be passed to LevelFromString.

Level Numeral Value Name and aliases
Panic 1 "panic", "pnc", "p", "1"
Fatal 2 "fatal", "ftl", "f", "2"
Error 3 "error", "err", "e", "3"
Warn 4 "warn", "wrn", "w", "4"
Info 5 "info", "inf", "i", "5"
Debug 6 "debug", "dbg", "f", "6"
Trace 7 "trace", "trc", "t", "7"

slog Support

The rogu.Logger can be used as slog.Handler, so that rogu's pretty writer can be used to format slog records.

roguLogger := slog.New(rogu.NewLogger(rogu.NewPrettyWriter()))
slog.SetDefault(roguLogger)

slog.Info("Hello, world!")

See example/slog for a more complete example.

Because of the architecture of rogu, some implications of slog are not met. Keep those in mind when using rogu as your slog backend!

  • In rogu loggers, the caller is recorded when an event has been sent (using e.Send() or e.Msg(...)). Slog on the other hand sets the caller to the function which has created the record/event.
  • Also, rogu records the event time when the event has been sent. Slog, on the other hand, records the event time when the record/event has been created.

rogu's People

Contributors

zekrotja avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.