• Stars
    star
    8
  • Rank 2,030,533 (Top 42 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automatically persists all the logs of your Go application inside RethinkDB.

go-rethinklogger

Documentation Go Report Card GitHub tag MIT Licence

go-rethinklogger persists and bundles all your logs from stdio and stderr to RethinkDB.

RethinkDB Logo

โ€ข Can be used to monitor logs and analytics of your GO application remotely.

โ€ข It works and is compatible with literally all types of loggers. The API is exceptionally simple and you just need to do normal logging, it automatically reads from stdio and stderr, persists logs for later use and echoes the same back to their respective streams.


Installation.

โ€ข Using Go.

go get github.com/MustansirZia/go-rethinklogger

โ€ข Using Glide.

glide get github.com/MustansirZia/go-rethinklogger
glide up

โ€ข Using go-vendor.

govendor fetch github.com/MustansirZia/go-rethinklogger

Usage.

    // Start persisting logs. Call preferably from init.
    // Start takes a rethinkDB address and the admin password
    // as arguments. Don't worry though, admin user is only
    // used to create the database and a user.

    rethinklogger.Start("localhost:28015", "adminPassword")

    fmt.Fprintln(os.Stdout, "Sample stdio log!")
    fmt.Fprintln(os.Stderr, "Sample stderr log!")

    ...
    ...

    // Query logs from anywhere in your application.
    previousDay := time.Now().Add(0, 0, -1)
    now := time.Now()

    logs, err := rethinklogger.QueryLogs("localhost:28015", previousDay, now)

    if err != nil {
        fmt.Println(err.Error())
    }
    for _, log := range logs {

        /*
            log {
                Log = "Sample stdio log!"
                CreatedAtHuman = "17 Aug 17 15:04 +530"
                CreatedAt = 1503162020
            }
            log {
                Log = "Sample stderr log!"
                CreatedAtHuman = "17 Aug 17 15:04 +530"
                CreatedAt = 1503162020
            }
        */

    }


Sidenotes.

โ€ข This library is built over go-shipit which dispatches std logs to a io.Writer interface. This library is basically a writer for shipit.

โ€ข To avoid our database from getting overwhelmed by logs, logs are first accumulated inside a buffer and then dispatched at an interval of 5 secs.

โ€ข Logging can also be started using StartWithBuffer function which takes an additional buffer size argument. This is the minimum number of logs that must be accumulated inside the buffer before all the logs are dispatched to Rethink. By default the value is 1.


Inspiration.

=> go-loggly - https://github.com/segmentio/go-loggly

=> Winston for nodejs - https://github.com/winstonjs/winston


License.

See License.


Support.

Support my OSS work by buying me a coffee!

Buy Me A Pizza

More Repositories

1

react-native-fused-location

Finest location for react-native on Android using the new Fused API.
Java
128
star
2

next-express-bootstrap-boilerplate

โšก JavaScript boilerplate for a full stack app built using React.js, Next.js, Express.js, react-bootstrap, SCSS and full SSR with eslint.
JavaScript
111
star
3

overlay_container

A flutter widget which renders its child outside the original widget hierarchy.
Dart
30
star
4

serverless-link-preview

A serverless, scalable service to get website description and preview deployed on AWS Lambda.
JavaScript
12
star
5

mustansir.npx

My name "mustansir" as an npx command. ๐Ÿš€
JavaScript
8
star
6

Decky

Android app writtten in Kotlin which showcases fully draggable deck of cards.
Kotlin
6
star
7

pokemon-service

A subdomain service that can serve different Pokemons based on the subdomain (Pokemon slug) from which it was accessed from.
TypeScript
6
star
8

markdown-visitor-badge

๐Ÿ‘‘ Embeddable markdown visitor badge created using Golang, Vercel's serverless functions and distributed Redis.
Go
6
star
9

institutions-api

A RESTful microservice to query all colleges in India, universities in India and all international universities around the world using their name, a prefix of their name or any part of their name.
Go
5
star
10

csgo-dedicated-server

A containerized dedicated server for Counter-Strike: Global Offensive.
Shell
4
star
11

textcord

Serverless function/API for sending and receiving messages from a Discord text channel via SMS.
Go
3
star
12

mustansir.dev

Home for my blog.
HTML
2
star
13

MustansirZia

GitHub Profile Description.
1
star
14

js-exam

This is a very simple JavaScript exam to make you feel comfortable with arrays, strings, objects and JavaScript in general.
JavaScript
1
star