CLI tool to handle JSON logs

logit

logit is a CLI tool that consumes logs in JSON and feeds them into a logs storage like file, Amazon CloudWatch, or Slack.

Why it is important:

  • Your application will contain only bussiness logic. Don't write your own logging library.
  • Your application will not send secondary network requests.
  • Your application will be faster. It's easy to make a JSON entry and feed it into stdout, and logit will take care of the rest.
  • Your application will be more environment-agnostic. Here you run it on your machine, production runs on AWS, tomorrow you migrate on GCP. And in all cases, only the logit config is different, application is the same.

Supported handlers:

  • console and files:
    • json
    • logfmt
    • rolling
    • text
    • zalgo
  • databases:
    • elastic
    • influxdb
    • mongodb
    • redis
  • messengers:
    • discord
    • slack
  • log collectors:
    • aws
    • fluentd
    • gcloud
    • graylog
    • sentry
    • syslog
    • loggly
    • logstash

Installation

The project is "go gettable":

go get github.com/life4/logit

The best practice for your production is to build a minimal binary with only handlers you need:

git clone https://github.com/life4/logit.git
cd logit
go build -tags 'h_clean,h_aws,h_gcloud' -o logit.bin .

Handlers json, logfmt, and text are always included. All other can be disabled by h_clean build tag and then individually enabled with h_{HANDLER} build tags.

Usage

First of all, you need a config. Let's make the following logit.toml:

[[handler]]
format = "text"

And now, pipe some JSON into stdin of logit:

$ export text='{"animal":"walrus","level":"fatal","msg":"A huge walrus appears","time":"2020-12-29 15:09:21"}'
$ echo $text | logit
FATAL  [2020-12-29 15:09:21] A huge walrus appears    animal=walrus

Or just a plain text, why not:

$ echo 'hi' | logit
INFO   [2021-01-04 14:48:50] hi

Easy!

See documentation for more details.

Producing JSON

There are some good libraries that you can use in your application to produce JSON logs:

Owner
Life4
Original cool Open Source projects
Life4
Similar Resources

Small utility to create JSON objects

Small utility to create JSON objects

gjo Small utility to create JSON objects. This was inspired by jpmens/jo. Support OS Mac Linux Windows Requirements Go 1.1.14~ Git Installtion Build $

Dec 8, 2022

A Go package for handling common HTTP JSON responses.

go-respond A Go package for handling common HTTP JSON responses. Installation go get github.com/nicklaw5/go-respond Usage The goal of go-respond is to

Sep 26, 2022

JSON query in Golang

gojq JSON query in Golang. Install go get -u github.com/elgs/gojq This library serves three purposes: makes parsing JSON configuration file much easie

Dec 28, 2022

Automatically generate Go (golang) struct definitions from example JSON

gojson gojson generates go struct definitions from json or yaml documents. Example $ curl -s https://api.github.com/repos/chimeracoder/gojson | gojson

Jan 1, 2023

A JSON diff utility

JayDiff A JSON diff utility. Install Downloading the compiled binary Download the latest version of the binary: releases extract the archive and place

Dec 11, 2022

Fast and flexible JSON encoder for Go

Fast and flexible JSON encoder for Go

Jettison Jettison is a fast and flexible JSON encoder for the Go programming language, inspired by bet365/jingo, with a richer features set, aiming at

Dec 21, 2022

Create go type representation from json

json2go Package json2go provides utilities for creating go type representation from json inputs. Json2go can be used in various ways: CLI tool Web pag

Dec 26, 2022

Console JSON formatter with query feature

Console JSON formatter with query feature

Console JSON formatter with query feature. Install: $ go get github.com/miolini/jsonf Usage: Usage of jsonf: -c=true: colorize output -d=false: de

Dec 4, 2022

Fluent API to make it easier to create Json objects.

Jsongo Fluent API to make it easier to create Json objects. Install go get github.com/ricardolonga/jsongo Usage To create this: { "name":"Ricar

Nov 7, 2022
Get JSON values quickly - JSON parser for Go
Get JSON values quickly - JSON parser for Go

get json values quickly GJSON is a Go package that provides a fast and simple way to get values from a json document. It has features such as one line

Dec 28, 2022
JSON diff library for Go based on RFC6902 (JSON Patch)

jsondiff jsondiff is a Go package for computing the diff between two JSON documents as a series of RFC6902 (JSON Patch) operations, which is particula

Dec 4, 2022
Fast JSON encoder/decoder compatible with encoding/json for Go
Fast JSON encoder/decoder compatible with encoding/json for Go

Fast JSON encoder/decoder compatible with encoding/json for Go

Jan 6, 2023
Package json implements encoding and decoding of JSON as defined in RFC 7159

Package json implements encoding and decoding of JSON as defined in RFC 7159. The mapping between JSON and Go values is described in the documentation for the Marshal and Unmarshal functions

Jun 26, 2022
JSON Spanner - A Go package that provides a fast and simple way to filter or transform a json document

JSON SPANNER JSON Spanner is a Go package that provides a fast and simple way to

Sep 14, 2022
/ˈdʏf/ - diff tool for YAML files, and sometimes JSON
/ˈdʏf/ - diff tool for YAML files, and sometimes JSON

dyff is inspired by the way the old BOSH v1 deployment output reported changes from one version to another by only showing the parts of a YAML file that change.

Dec 29, 2022
Online tool that convert JSON to Go.

json-to-go 将json生成go的数据结构。Online tool that convert JSON to Go. Online Link | 地址 Link1 | 国内 Link2 | 国外 Local Develope | 本地开发 suggest use(强烈建议使用) pnpm !

Aug 28, 2022
A tool to aggregate and mine data from JSON reports of Go tests.

teststat A tool to aggregate and mine data from JSON reports of Go tests. Why? Mature Go projects often have a lot of tests, and not all of them are i

Sep 15, 2022
Abstract JSON for golang with JSONPath support

Abstract JSON Abstract JSON is a small golang package provides a parser for JSON with support of JSONPath, in case when you are not sure in its struct

Jan 5, 2023
Fast JSON parser and validator for Go. No custom structs, no code generation, no reflection

fastjson - fast JSON parser and validator for Go Features Fast. As usual, up to 15x faster than the standard encoding/json. See benchmarks. Parses arb

Jan 5, 2023