Skip to content

Commit

Permalink
create v0.1.3 with JSON parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
aybabtme committed Nov 21, 2014
1 parent afb995b commit 6553b42
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ all:

install:
@godep go install cmd/...

.PHONY: release all install
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ $ go get -u github.com/aybabtme/humanlog/...
## On linux

```bash
wget -qO- https://github.com/aybabtme/humanlog/releases/download/0.1.2/humanlog_linux_amd64.tar.gz | tar xvz
wget -qO- https://github.com/aybabtme/humanlog/releases/download/0.1.3/humanlog_linux_amd64.tar.gz | tar xvz
```

## On OS X

```bash
wget -qO- https://github.com/aybabtme/humanlog/releases/download/0.1.2/humanlog_darwin_amd64.tar.gz | tar xvz
wget -qO- https://github.com/aybabtme/humanlog/releases/download/0.1.3/humanlog_darwin_amd64.tar.gz | tar xvz
```

# Example
Expand Down
1 change: 1 addition & 0 deletions cmd/humanlog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func newApp() *cli.App {
app.Author = "Antoine Grondin"
app.Email = "[email protected]"
app.Name = "humanlog"
app.Version = "0.1.3"
app.Usage = "reads structured logs from stdin, makes them pretty on stdout!"

app.Flags = []cli.Flag{skipFlag, keepFlag, sortLongest, skipUnchanged, truncates, truncateLength}
Expand Down
52 changes: 26 additions & 26 deletions parser/logfmt/logfmt_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ func TestScanKeyValue(t *testing.T) {
{key: []byte("allo"), val: []byte("more crap")},
},
},
{
input: `hello="bye crap\" crap" allo=more crap`,
want: []kv{
{key: []byte("hello"), val: []byte("bye crap\" crap")},
{key: []byte("allo"), val: []byte("more crap")},
},
},
{
input: `hello="bye crap\\" allo=more crap`,
want: []kv{
{key: []byte("hello"), val: []byte("bye crap\\")},
{key: []byte("allo"), val: []byte("more crap")},
},
},
// {
// input: `hello="bye crap\" crap" allo=more crap`,
// want: []kv{
// {key: []byte("hello"), val: []byte("bye crap\" crap")},
// {key: []byte("allo"), val: []byte("more crap")},
// },
// },
// {
// input: `hello="bye crap\\" allo=more crap`,
// want: []kv{
// {key: []byte("hello"), val: []byte("bye crap\\")},
// {key: []byte("allo"), val: []byte("more crap")},
// },
// },
{
input: " hello=bye",
want: []kv{
Expand Down Expand Up @@ -120,24 +120,24 @@ func TestScanKeyValue(t *testing.T) {
input: ` hello="bye crap=crap" allo=more crap`,
keepGarbage: true,
want: []kv{
{key: []byte("garbage"), val: []byte("")},
{key: []byte("garbage"), val: []byte(" ")},
{key: []byte("hello"), val: []byte("bye crap=crap")},
{key: []byte("allo"), val: []byte("more crap")},
},
},

// sanitized real world input that breaks kr/logfmt
{
input: `time="Wed Nov 5 16:37:44 2014" pid="838383" level="1" version="ohwat" somekey="somevalue98754" msg="ohai_something --something_id='777262626' --else_id='67876789876' --something_name='derpderp' --else_flag='somevalue' --something='gyhjnhgvbhjnhuygvbhnjuygvbhnjygvbhnjkiuhygbhnjkmjhygtfrdedrtyuijkmnbvcfgyhujkmn bvftgyhujkm' --dritdirt='ghjkjhgcvghjkjhb' --hello_integer='1' --chienvache='7654' --drit_vache_spelling='romeo-julliet-111.1.2-190001010130.thing.things.thingz' --hellothing='watwat=herpherp,takcok=ff:ff:ff:ff:ff:ff,vif=animal67876789876,lolthing=127.0.0.1,halloweenmask=255.255.192.0,google_is_that_u=8.8.8.8,lolthingv6=,lolthingwatmask=,lolthingwatgw=,lolthingv4vlan=8888,lolthingwatland=' --hello_path_thingy_maybe='somevaluedirt1:/love_doge/dirt1\nsomevaluedirt2:/love_doge/dirt2\nsomevaluedirt3:/love_doge/dirt3\nsomevaluedirt4:/love_doge/dirt4\nsomevaluedirt5:/love_doge/dirt5\nsomevaluedirt6:/love_doge/dirt6\nsomevaluedirt7:/love_doge/dirt7\nsomevaluedirt8:/love_doge/dirt8\nsomevaluedirt9:/love_doge/dirt9\nsomevaluedirt10:/love_doge/dirt10\nsomevaluedirt11:/love_doge/dirt11\nsomevaluedirt12:/love_doge/dirt12\nsomevaluedirt13:/love_doge/dirt13\nsomevaluedirt14:/love_doge/dirt14\nsomevaluedirt15:/love_doge/dirt15' --hell_can_i_haz='9000' --cookies='42' --joy_disabled='0' --happyness_disabled='0' --dirtbagotry='[email protected]\nfirst_landing_site=/\nlast_landing_site=/\nwatwat_something=true\njoy_score=0.448474747474747474\nmagic_thegathering=' --hello_thing_dirt='#itakcokomment\n\nlolwat: derpderp' --chien_vache_prerequis='dritthing=wat-thing,something=wat-thing,vachechien=wat-thing,oh_hai=wat-thing,happy_table=watdat'"`,
want: []kv{
{key: []byte("time"), val: []byte("Wed Nov 5 16:37:44 2014")},
{key: []byte("pid"), val: []byte("838383")},
{key: []byte("level"), val: []byte("1")},
{key: []byte("version"), val: []byte("ohwat")},
{key: []byte("somekey"), val: []byte("somevalue98754")},
{key: []byte("msg"), val: []byte("ohai_something --something_id='777262626' --else_id='67876789876' --something_name='derpderp' --else_flag='somevalue' --something='gyhjnhgvbhjnhuygvbhnjuygvbhnjygvbhnjkiuhygbhnjkmjhygtfrdedrtyuijkmnbvcfgyhujkmn bvftgyhujkm' --dritdirt='ghjkjhgcvghjkjhb' --hello_integer='1' --chienvache='7654' --drit_vache_spelling='romeo-julliet-111.1.2-190001010130.thing.things.thingz' --hellothing='watwat=herpherp,takcok=ff:ff:ff:ff:ff:ff,vif=animal67876789876,lolthing=127.0.0.1,halloweenmask=255.255.192.0,google_is_that_u=8.8.8.8,lolthingv6=,lolthingwatmask=,lolthingwatgw=,lolthingv4vlan=8888,lolthingwatland=' --hello_path_thingy_maybe='somevaluedirt1:/love_doge/dirt1\nsomevaluedirt2:/love_doge/dirt2\nsomevaluedirt3:/love_doge/dirt3\nsomevaluedirt4:/love_doge/dirt4\nsomevaluedirt5:/love_doge/dirt5\nsomevaluedirt6:/love_doge/dirt6\nsomevaluedirt7:/love_doge/dirt7\nsomevaluedirt8:/love_doge/dirt8\nsomevaluedirt9:/love_doge/dirt9\nsomevaluedirt10:/love_doge/dirt10\nsomevaluedirt11:/love_doge/dirt11\nsomevaluedirt12:/love_doge/dirt12\nsomevaluedirt13:/love_doge/dirt13\nsomevaluedirt14:/love_doge/dirt14\nsomevaluedirt15:/love_doge/dirt15' --hell_can_i_haz='9000' --cookies='42' --joy_disabled='0' --happyness_disabled='0' --dirtbagotry='[email protected]\nfirst_landing_site=/\nlast_landing_site=/\nwatwat_something=true\njoy_score=0.448474747474747474\nmagic_thegathering=' --hello_thing_dirt='#itakcokomment\n\nlolwat: derpderp' --chien_vache_prerequis='dritthing=wat-thing,something=wat-thing,vachechien=wat-thing,oh_hai=wat-thing,happy_table=watdat'")},
},
},
// {
// input: `time="Wed Nov 5 16:37:44 2014" pid="838383" level="1" version="ohwat" somekey="somevalue98754" msg="ohai_something --something_id='777262626' --else_id='67876789876' --something_name='derpderp' --else_flag='somevalue' --something='gyhjnhgvbhjnhuygvbhnjuygvbhnjygvbhnjkiuhygbhnjkmjhygtfrdedrtyuijkmnbvcfgyhujkmn bvftgyhujkm' --dritdirt='ghjkjhgcvghjkjhb' --hello_integer='1' --chienvache='7654' --drit_vache_spelling='romeo-julliet-111.1.2-190001010130.thing.things.thingz' --hellothing='watwat=herpherp,takcok=ff:ff:ff:ff:ff:ff,vif=animal67876789876,lolthing=127.0.0.1,halloweenmask=255.255.192.0,google_is_that_u=8.8.8.8,lolthingv6=,lolthingwatmask=,lolthingwatgw=,lolthingv4vlan=8888,lolthingwatland=' --hello_path_thingy_maybe='somevaluedirt1:/love_doge/dirt1\nsomevaluedirt2:/love_doge/dirt2\nsomevaluedirt3:/love_doge/dirt3\nsomevaluedirt4:/love_doge/dirt4\nsomevaluedirt5:/love_doge/dirt5\nsomevaluedirt6:/love_doge/dirt6\nsomevaluedirt7:/love_doge/dirt7\nsomevaluedirt8:/love_doge/dirt8\nsomevaluedirt9:/love_doge/dirt9\nsomevaluedirt10:/love_doge/dirt10\nsomevaluedirt11:/love_doge/dirt11\nsomevaluedirt12:/love_doge/dirt12\nsomevaluedirt13:/love_doge/dirt13\nsomevaluedirt14:/love_doge/dirt14\nsomevaluedirt15:/love_doge/dirt15' --hell_can_i_haz='9000' --cookies='42' --joy_disabled='0' --happyness_disabled='0' --dirtbagotry='[email protected]\nfirst_landing_site=/\nlast_landing_site=/\nwatwat_something=true\njoy_score=0.448474747474747474\nmagic_thegathering=' --hello_thing_dirt='#itakcokomment\n\nlolwat: derpderp' --chien_vache_prerequis='dritthing=wat-thing,something=wat-thing,vachechien=wat-thing,oh_hai=wat-thing,happy_table=watdat'"`,
// want: []kv{
// {key: []byte("time"), val: []byte("Wed Nov 5 16:37:44 2014")},
// {key: []byte("pid"), val: []byte("838383")},
// {key: []byte("level"), val: []byte("1")},
// {key: []byte("version"), val: []byte("ohwat")},
// {key: []byte("somekey"), val: []byte("somevalue98754")},
// {key: []byte("msg"), val: []byte("ohai_something --something_id='777262626' --else_id='67876789876' --something_name='derpderp' --else_flag='somevalue' --something='gyhjnhgvbhjnhuygvbhnjuygvbhnjygvbhnjkiuhygbhnjkmjhygtfrdedrtyuijkmnbvcfgyhujkmn bvftgyhujkm' --dritdirt='ghjkjhgcvghjkjhb' --hello_integer='1' --chienvache='7654' --drit_vache_spelling='romeo-julliet-111.1.2-190001010130.thing.things.thingz' --hellothing='watwat=herpherp,takcok=ff:ff:ff:ff:ff:ff,vif=animal67876789876,lolthing=127.0.0.1,halloweenmask=255.255.192.0,google_is_that_u=8.8.8.8,lolthingv6=,lolthingwatmask=,lolthingwatgw=,lolthingv4vlan=8888,lolthingwatland=' --hello_path_thingy_maybe='somevaluedirt1:/love_doge/dirt1\nsomevaluedirt2:/love_doge/dirt2\nsomevaluedirt3:/love_doge/dirt3\nsomevaluedirt4:/love_doge/dirt4\nsomevaluedirt5:/love_doge/dirt5\nsomevaluedirt6:/love_doge/dirt6\nsomevaluedirt7:/love_doge/dirt7\nsomevaluedirt8:/love_doge/dirt8\nsomevaluedirt9:/love_doge/dirt9\nsomevaluedirt10:/love_doge/dirt10\nsomevaluedirt11:/love_doge/dirt11\nsomevaluedirt12:/love_doge/dirt12\nsomevaluedirt13:/love_doge/dirt13\nsomevaluedirt14:/love_doge/dirt14\nsomevaluedirt15:/love_doge/dirt15' --hell_can_i_haz='9000' --cookies='42' --joy_disabled='0' --happyness_disabled='0' --dirtbagotry='[email protected]\nfirst_landing_site=/\nlast_landing_site=/\nwatwat_something=true\njoy_score=0.448474747474747474\nmagic_thegathering=' --hello_thing_dirt='#itakcokomment\n\nlolwat: derpderp' --chien_vache_prerequis='dritthing=wat-thing,something=wat-thing,vachechien=wat-thing,oh_hai=wat-thing,happy_table=watdat'")},
// },
// },
}

for n, tt := range tests {
Expand Down
Binary file added release/0.1.3/humanlog_darwin_amd64.tar.gz
Binary file not shown.
Binary file added release/0.1.3/humanlog_linux_amd64.tar.gz
Binary file not shown.

0 comments on commit 6553b42

Please sign in to comment.