HedariKun / rogu

a simple logging library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go Report Card License

Introduction

This is yet another simple logging library written in go to fit what I need and the style I like. yes, there might be a better option out there but what this includes fits me more <3

Installation

go get github.com/hedarikun/rogu

Features

  • Having the ability to disable/enable some types of logging as well as define the output using io.Writer interface
  • Supports Optional Dates
  • Supports Optional Log Stack Trace (it tells you from where the log is being called)
  • Supports being able to create a Log with custom type
  • Supports Coloring of messages for better viewing using different methods depending on the platform
  • Supporting multiple io.Writer interfaces to able to log to console and to a seperate file

Example

package main
import (
  "github.com/hedarikun/rogu"
)

func main() {
  r := rogu.New()
  r.Log("this is a Log message")
  r.Error("this is an Error message")
  r.Warn("this is a Warning message")
}

the result of the above code is

[LOG][main.go:8 - main][2023-09-05 10:22:05 Tue]: this is a Log message
[ERROR][main.go:9 - main][2023-09-05 10:22:05 Tue]: this is an Error message
[WARN][main.go:10 - main][2023-09-05 10:22:05 Tue]: this is a Warning message

Note

By default showing log stack and current date is on by default but you can change this behavior

it supports creating some custom made tags for the logging like in the following example

package main
import (
  "github.com/hedarikun/rogu"
)

func main() {
  r := rogu.New()
  notify := r.Logger("NOTIFY")
  notify("this is a notify log!!")
}

it will show as

[NOTIFY][main.go:9 - main][2023-09-05 11:29:05 Tue]: this is a notify log!!

About

a simple logging library

License:Apache License 2.0


Languages

Language:Go 100.0%