Giter Club home page Giter Club logo

thoth's Introduction

Thoth

Thoth

What is Thoth?

In Egyptian Mythology, Thoth was the Egyptian ibis-headed god of knowledge, magic and wisdom.

In this Context

Thoth is an error logger for golang. It helps log errors to a log file so you can go back to find how why and when something breaks in production.

Installation

You can install Thoth by running:

go get github.com/ichtrojan/thoth

Usage

Thoth supports logging to two filetypes:

  • log
  • json

Step one - Initiate Thoth

Thoth Initiation for log

...
file, err := thoth.Init("log")

if err != nil {
    log.Fatal(err)
}
...

Thoth Initiation for json

...
json, err := thoth.Init("json")

if err != nil {
    log.Fatal(err)
}
...

Step two - Log errors

Regardless of the variable assigned to a Thoth Init function and log format; errors can be logged using the Log function.

Thoth Initiation for log

Logging errors from packages

...
if err != nil {
    file.Log(err)
}
...

Logging custom errors based on a given condition

...
isBroke := true

if isBroke {
    file.Log(errors.New("something went wrong"))
}
...

Thoth Initiation for json

Logging errors from packages

...
if err != nil {
    json.Log(err)
}
...

Logging custom errors based on a given condition

...
high := true

if high {
    json.Log(errors.New("highest in the room"))
}
...

Step three - Serve real-time logs dashboard

You can serve a dashboard to view your logs in realtime using the Serve function. Depending on the filetype specified in the Init function, it will serve the content of your log file.

Usage format

file.Serve({dashboard route}, {dashboard password})

Thoth serve for log

...
if err := file.Serve("/logs", "12345"); err != nil {
    log.Fatal(err)
}

if err := http.ListenAndServe(":8000", nil); err != nil {
    file.Log(err)
}
...

The snippet above will serve your realtime log dashboard on port 8000 and can be visited on /logs route.

You can also check the example directory to see a sample usage.

NOTE The realtime dashboard for json is currently on beta, it can be used but still looks experimental.

Contributors

Conclusion

Contributions are welcome to this project to further improve it to suit the general public need. I hope you enjoy the simplicity of Thoth and cannot wait to see the wonderful project you build with it.

thoth's People

Contributors

dumebi avatar elvis-chuks avatar ichtrojan avatar

Watchers

 avatar  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.