Giter Site home page Giter Site logo

bragi's Introduction

Bragi

GoDoc Go Report Card

Bragi is a simple log lib that is designed to be a dropin repleasement for go's std log lib. But with log output that reflect the output given with java logback. This lib is also going to rotate log files and remove old logs.

Contents

How to use

This is a dropin replace ment, so just add the dependencie and use it as you would do go log. To log to file add the following

log.SetPrefix("vili")
cloaser := log.SetOutputFolder(logDir)
if cloaser == nil {
	log.Fatal("Unable to sett logdir")
}
defer cloaser()

SetPrefix sets the prefix name of the logs. When they rotate the one without any time data in the name is the current and the rest will have the date appended.

SetOutputFolder creates and sets the output folder for bouth human and json logs and returns a function to cloase the files if the process was successfull.

To use the rotating feature add a call to log.StartRotate(done chan func()) after the code example above. Full example below

log.SetPrefix("vili")
cloaser := log.SetOutputFolder(logDir)
if cloaser == nil {
	log.Fatal("Unable to sett logdir")
}
defer cloaser()
log.StartRoute(nil)

Extra functions

If you want to add an error to debug, info, notice, error, crit, fatal with the following pattern

 log.AddError(err).Debug("Information about the error") 

With that pattern you will get bouth the error and the information text in the same log object

bragi's People

Contributors

sindrebrurberg avatar totto avatar renovate[bot] avatar

Watchers

Bård Lind avatar Rickard Öberg avatar Ove Ranheim avatar James Cloos avatar  avatar Thomas Pringle avatar José Díaz avatar  avatar  avatar Steinar Haugen avatar  avatar

bragi's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

gomod
go.mod
  • go 1.21

  • Check this box to trigger a request for Renovate to run again on this repository

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.