No description
  • Go 59.1%
  • Makefile 40.9%
Find a file
2024-10-19 11:31:57 +02:00
go.mod chore: update dependency because of name change 2024-10-19 11:31:57 +02:00
go.sum feat(build): add Makefile for build and development automation 2024-09-15 18:51:38 +02:00
log.go fix(log): correct color formatting in logger output 2024-09-28 14:33:39 +02:00
Makefile feat(build): add Makefile for build and development automation 2024-09-15 18:51:38 +02:00
readme.md feat(logging): add control over stack trace printing 2024-06-29 22:36:07 +02:00

dnutlogger

Do Not Use This Logger (Seriously, Why Are You Even Here?)


Oh, you found dnutlogger. Guess you're out of good options. This is what I use for logging because I can't be bothered with anything better. If you're here, you must share my questionable standards. Let's get on with it.

What is dnutlogger?

Glad you asked. It's a logger. That's it. It logs stuff. To the console. Wow. Revolutionary, I know. But hey, it works for me, so it might just work for you. Or not. Probably not. But who cares?

How to Install

You really want to do this, huh? Fine. Here you go:

go get github.com/sett17/dnutlogger

Usage

Alright, so youve gone ahead and installed it. Bold move. Heres how you can use this masterpiece of logging technology:

package main

import (
    "errors"
    log "github.com/sett17/dnutlogger"
)

func main() {
    // Optional configurations
    log.SetMinLevel(log.DEBUG) // Set the minimum log level to DEBUG
    log.UseColor(false)        // Disable colored output (default is true)
    log.SetStackTracePrinting(false) // Disable stack trace printing (default is true)

    // Logging a debug message
    log.Debug("This is a debug message")

    // Logging a debug formatted message
    log.Debugf("This is a debug message with a number: %d", 42)

    // Logging an info message
    log.Info("This is an info message")

    // Logging an info formatted message
    log.Infof("This is an info message with a string: %s", "example")

    // Logging a warning message
    log.Warn("This is a warning message")

    // Logging a warning formatted message
    log.Warnf("This is a warning message with a float: %.2f", 3.14)

    // Logging a success message
    log.Success("This is a success message")

    // Logging a success formatted message
    log.Successf("This is a success message with a boolean: %t", true)

    // Logging an error message without exiting
    log.Error(false, "This is an error message without exiting")

    // Logging an error formatted message without exiting
    log.Errorf(false, "This is an error message with a struct: %+v", struct{ Name string }{"example"})

    // Logging an error with a stack trace and exiting
    log.Err(true, errors.New("This is a fatal error"))
}

Log Levels

Wow, you actually care about the log levels? Fine, here they are:

  • DEBUG: For when you need to log every single step because you have no idea what's going on.
  • INFO: Standard log level, because youre supposed to care about these messages.
  • SUCCESS: Everything went better than expected.
  • WARN: Things are getting sketchy, might want to pay attention.
  • ERROR: You messed up. Big time.

This is also the order used with SetMinLevel(), so setting the minimum log level to SUCCESS will log everything from SUCCESS to ERROR.

Configuration

Set Minimum Log Level

Because obviously, you need to filter out the noise:

log.SetMinLevel(log.WARN)

Enable/Disable Color

Make your console pretty, or not:

log.UseColor(true) // or false if you're boring

Enable/Disable Stack Trace Printing

Control whether stack traces are printed for errors:

log.SetStackTracePrinting(true) // or false if you don't want to see where you messed up

License

Do whatever you want. I do not care. Seriously.


Well, there you have it. Youve just spent time reading a README for a logger that I dont even recommend you use. But you do you. Enjoy (or not).