Giter VIP home page Giter VIP logo

humanlog's People

Contributors

adamwg avatar aybabtme avatar bettio avatar blockloop avatar bouk avatar choppedpork avatar coccyx avatar daveworth avatar gholt avatar jboelter avatar jdechicchis avatar johnwarden avatar morbidick avatar nanzhong avatar peterjmag avatar soldiermoth avatar ssgreg avatar torfbolt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

humanlog's Issues

Output appears unchanged... perhaps a setup issue on my end?

I'm working to make better use of structured logging, and came across your humanlog utility.
Operating System: OSX
Terminal Client: Bash/Default

I have a small test log I created using gokit.
{"caller":"main.go:25","level":"debug","msg":"Testing Debug","service":"logtestapp","ts":"2016-07-21T19:50:18Z"} {"caller":"main.go:26","level":"info","msg":"Testing Info","service":"logtestapp","ts":"2016-07-21T19:50:18Z"} {"caller":"main.go:27","level":"warn","msg":"Testing Warn","service":"logtestapp","ts":"2016-07-21T19:50:18Z"} {"caller":"main.go:28","level":"error","msg":"Testing Error","service":"logtestapp","ts":"2016-07-21T19:50:18Z"} {"caller":"main.go:29","level":"crit","msg":"Testing Crit","service":"logtestapp","ts":"2016-07-21T19:50:18Z"}

I installed humanlog using the go get method from your README.
go get -u github.com/aybabtme/humanlog/...

Once installed, I run the following command, but am not seeing any change to display of the logs I'm providing, save for the humanlog> reading stdin... at the top of the ouput.
humanlog < logtestapp.log

Is there something I'm missing, or a potential misconfiguration I've encountered? Anything that can point me in the right direction would be greatly appreciated, thanks!

required fields for logfmt

From the main README.md I got the impression that humanlog can handle arbitrary logfmt data ("If you emit logs in JSON or in logfmt, you will enjoy pretty logs..."), and then I wondered why it left some simple logs completely unchanged, like:

msg=hello

After diving into the source I found that a log entry must have a level, time, and msg field (https://github.com/aybabtme/humanlog/blob/master/logrus_handler.go#L39). It would be useful to mention this.

About the implementation:

  • "lvl" and "message" seem to be treated as aliases, but the sanity check doesn't include them, so I'm not sure whether those aliases really work?
  • the check expects "msg" to be quoted. This is too strict, for example the go-logfmt/logfmt Encoder doesn't put quotation marks around values unless absolutely necessary.

Panic on key without value

Consider the following line:

time="2019-12-09T13:56:00Z" level=trace msg="crash" somekey=

This makes humanlog crash horribly:

[root@la1 ~]# ./humanlog < repro.log
humanlog> reading stdin...
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/aybabtme/humanlog/parser/logfmt.scanAllKeyValue(0xc42009e000, 0x3c, 0x1000, 0x101, 0xc420045ab0)
        /Users/antoine/gocode/src/github.com/aybabtme/humanlog/parser/logfmt/logfmt_parser.go:38 +0x31e
github.com/aybabtme/humanlog/parser/logfmt.Parse(0xc42009e000, 0x3c, 0x1000, 0x101, 0xc420045ab0, 0x20)
        /Users/antoine/gocode/src/github.com/aybabtme/humanlog/parser/logfmt/logfmt_parser.go:18 +0x5b
github.com/aybabtme/humanlog.Scanner(0x5c64e0, 0xc42000c018, 0x5c6500, 0xc42000c020, 0x690ca0, 0x2, 0x2)
        /Users/antoine/gocode/src/github.com/aybabtme/humanlog/scanner.go:43 +0x405
main.newApp.func1(0xc420082160, 0xc420082160, 0xc420045ce7)
        /Users/antoine/gocode/src/github.com/aybabtme/humanlog/cmd/humanlog/main.go:124 +0x369
github.com/aybabtme/humanlog/vendor/github.com/urfave/cli.HandleAction(0x56f620, 0xc420098000, 0xc420082160, 0xc4200522a0, 0x0)
        /Users/antoine/gocode/src/github.com/aybabtme/humanlog/vendor/github.com/urfave/cli/app.go:501 +0xc8
github.com/aybabtme/humanlog/vendor/github.com/urfave/cli.(*App).Run(0xc420094000, 0xc42000e1b0, 0x1, 0x1, 0x0, 0x0)
        /Users/antoine/gocode/src/github.com/aybabtme/humanlog/vendor/github.com/urfave/cli/app.go:268 +0x60c
main.main()
        /Users/antoine/gocode/src/github.com/aybabtme/humanlog/cmd/humanlog/main.go:31 +0x11c

This is evidently caused by the somekey= having a zero length value

--light-bg: values to light

Despite calling humanlog with --light-bg, additional values get colored with a very light color that is almost unreadable on a white background.

Apparently because of:

ValColor:          color.New(color.FgHiWhite),

Should different colors be used depending on --light-bg?

Humanlog colors not configurable, and assume dark background

The default colors don't work for me:

screen shot 2016-08-03 at 4 30 08 pm

Due to the way that the underlying rgbterm works, I can't just send a quick \033[40m to set the background color to dark; it only works for the first colored block printed, and then a SGR reset kills that.

It's possible to set the default background color, but it's very terminal dependent, and so my wrapper function for Scanner is getting really ugly:

func ScannerDarkly(src io.Reader, dst io.Writer, opts *humanlog.HandlerOptions) {
    var setBgColorCode string
    if strings.Contains(os.Getenv("TERM_PROGRAM"), "iTerm") {
        // iTerm...
        setBgColorCode = "\033]Ph%.2x%.2x%.2x\033\\"
    } else if strings.Contains(os.Getenv("TERM"), "256") || strings.Contains(os.Getenv("TERM"), "xterm") {
        setBgColorCode = "\033]6;rgb:%.2x/%.2x/%.2x\a"
    }
    if setBgColorCode != "" {
        dst.Write([]byte(fmt.Sprintf(setBgColorCode, bgColor[0], bgColor[1], bgColor[2])))
    }
    humanlog.Scanner(src, dst, opts)
}

I'm not cleaning up the color change, either, so when my program quits it leaves the background dark. Do you think it would be possible to make the code accept some kind of color palette configuration or something (perhaps with regular ANSI code fallbacks), instead of all of the hardcoded color codes?

can't get humanlog to work, please help

$ echo '{"level":"info", "time" : 1533094882, "msg":"logger construction succeeded"}' | humanlog

I get:

humanlog> reading stdin...
{"level":"info", "time" : 1533094882, "msg":"logger construction succeeded"}

And nothing else is happening. I'm hot sure i've built the project correctly, cd

$ cmd/humanlog && go build got me a seemingly working binary

Support for custom columns

I would like to be able to add a custom columns from specific fields, one use case example:

The logs I am using (from python-json-logger" have a field called "name" that shows what module generated that log message
The way it looks now:
image

Homebrew warning (bottle :unneeded)

Warning: Calling bottle :unneeded is deprecated! There is no replacement.
Please report this issue to the aybabtme/tap tap (not Homebrew/brew or Homebrew/core):
/usr/local/Homebrew/Library/Taps/aybabtme/homebrew-tap/humanlog.rb:9

--skip-unchanged defaults to true

Hello!,

Where could I PR to either document that --skip-unchanged defaults to true and duplicate key/values are removed on a naked run, or change it so that it is not default functionality?

Thanks!

Debian package is missing Maintainer: line

Whenever I run something like apt update or apt upgrade, there's a warning in the dpkg output:

dpkg-query: warning: parsing file '/var/lib/dpkg/status' near line 10716 package 'humanlog':
 missing 'Maintainer' field

And inspecting the generated .deb package:

$ curl -LkO https://github.com/aybabtme/humanlog/releases/download/0.5.0/humanlog_0.5.0_linux_amd64.deb
$ ar x humanlog_0.5.0_linux_amd64.deb
$ cat control
Package: humanlog
Version: 0.5.0
Section: 
Priority: 
Architecture: amd64
Installed-Size: 3076
Description: no description given

It seems that the Maintainer field is indeed not set.

It looks like goreleaser can set this when it generates the package: https://goreleaser.com/customization/nfpm/

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.