Skip to content

Commit

Permalink
* Updated dependencies
Browse files Browse the repository at this point in the history
* Added interceptors
  • Loading branch information
blaubaer committed Mar 8, 2020
1 parent e6ff6e0 commit b382957
Show file tree
Hide file tree
Showing 20 changed files with 434 additions and 161 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: go
go:
- 1.11.x
- 1.14.x
install: skip
os:
- linux
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2019 echocat
Copyright (c) 2018-2020 echocat

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 8 additions & 12 deletions box/packed/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package packed
import (
"bytes"
"github.com/echocat/goxr/common"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/assert"
"testing"
)

Expand Down Expand Up @@ -53,12 +53,10 @@ func Benchmark_FindHeader(b *testing.B) {

// run the Fib function b.N times
for n := 0; n < b.N; n++ {
g := NewGomegaWithT(b)

header, err := FindHeader(bytes.NewBuffer(in))
g.Expect(err).To(BeNil())
g.Expect(header.Version).To(Equal(version1))
g.Expect(header.TocOffset).To(Equal(offset))
assert.NoError(b, err)
assert.Equal(b, version1, header.Version)
assert.Equal(b, offset, header.TocOffset)
}
}

Expand All @@ -74,15 +72,13 @@ func Test_FindHeader(t *testing.T) {
addCase := func(name string, expectedVersion *Version, expectedOffset common.FileOffset, inArgs ...interface{}) {
in := concatBytes(inArgs...)
t.Run(name, func(t *testing.T) {
g := NewGomegaWithT(t)

header, err := FindHeader(bytes.NewBuffer(in))
g.Expect(err).To(BeNil())
assert.NoError(t, err)
if expectedVersion == nil {
} else {
g.Expect(header).ToNot(BeNil())
g.Expect(header.Version).To(Equal(*expectedVersion))
g.Expect(header.TocOffset).To(Equal(expectedOffset))
assert.NotNil(t, header)
assert.Equal(t, *expectedVersion, header.Version)
assert.Equal(t, expectedOffset, header.TocOffset)
}
})
}
Expand Down
31 changes: 15 additions & 16 deletions box/packed/truncate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package packed

import (
"github.com/echocat/goxr/common"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/assert"
"os"
"testing"
)
Expand All @@ -18,40 +18,39 @@ func Test_Truncate(t *testing.T) {

addCase := func(name string, expectedVersion *Version, expectedTocOffset common.FileOffset, expectedSize int, inArgs ...interface{}) {
t.Run(name, func(t *testing.T) {
g := NewGomegaWithT(t)
fn := tempFileWithBytesOf(inArgs...)
defer deletePathForT(fn, t)
{
f, err := os.Open(fn)
g.Expect(err).To(BeNil())
g.Expect(f).ToNot(BeNil())
assert.NoError(t, err)
assert.NotNil(t, f)
defer closeForT(f, t)
header, err := FindHeader(f)
g.Expect(err).To(BeNil())
assert.NoError(t, err)
if expectedVersion == nil {
g.Expect(header).To(BeNil())
assert.Nil(t, header)
} else {
g.Expect(header).ToNot(BeNil())
g.Expect(header.Version).To(Equal(*expectedVersion))
g.Expect(header.TocOffset).To(Equal(expectedTocOffset))
assert.NotNil(t, header)
assert.Equal(t, *expectedVersion, header.Version)
assert.Equal(t, expectedTocOffset, header.TocOffset)
}
}
{
err := Truncate(fn)
g.Expect(err).To(BeNil())
assert.NoError(t, err)
}
{
f, err := os.Open(fn)
g.Expect(err).To(BeNil())
g.Expect(f).ToNot(BeNil())
assert.NoError(t, err)
assert.NotNil(t, f)
defer closeForT(f, t)
header, err := FindHeader(f)
g.Expect(err).To(BeNil())
g.Expect(header).To(BeNil())
g.Expect(f.Close()).To(BeNil())
assert.NoError(t, err)
assert.NotNil(t, header)
assert.NoError(t, f.Close())
}
{
g.Expect(fileSizeForT(fn, t)).To(Equal(int64(expectedSize)))
assert.Equal(t, int64(expectedSize), fileSizeForT(fn, t))
}
})
}
Expand Down
20 changes: 9 additions & 11 deletions box/packed/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package packed
import (
"fmt"
"github.com/echocat/goxr/common"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/assert"
"io"
"io/ioutil"
"math/rand"
Expand All @@ -18,23 +18,21 @@ var (

func Test_writeGarbageBytes(t *testing.T) {
t.Run("works as expected", func(t *testing.T) {
g := NewGomegaWithT(t)

f, err := ioutil.TempFile("", "goxr.box.packed-writeGarbageBytes.*.bin")
defer deletePathForT(f.Name(), t)
defer closeForT(f, t)
g.Expect(err).To(BeNil())
g.Expect(f).ToNot(BeNil())
g.Expect(f.Sync()).To(BeNil())
assert.NoError(t, err)
assert.NotNil(t, f)
assert.NoError(t, f.Sync())
fi, err := f.Stat()
g.Expect(err).To(BeNil())
g.Expect(fi.Size()).To(Equal(int64(0)))
assert.NoError(t, err)
assert.Equal(t, int64(0), fi.Size())

writeGarbageBytes(garbage(6666), f)
g.Expect(f.Sync()).To(BeNil())
assert.NoError(t, f.Sync())
fi, err = f.Stat()
g.Expect(err).To(BeNil())
g.Expect(fi.Size()).To(Equal(int64(6666)))
assert.NoError(t, err)
assert.Equal(t, int64(6666), fi.Size())
})
}

Expand Down
18 changes: 10 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
module github.com/echocat/goxr

require (
github.com/c2h5oh/datasize v0.0.0-20171227191756-4eba002a5eae
github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee // performance tests
github.com/edsrzf/mmap-go v1.0.0
github.com/onsi/gomega v1.4.2
github.com/pkg/errors v0.8.0
github.com/sirupsen/logrus v1.2.0
github.com/urfave/cli v1.20.0+incompatible
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.5.1
github.com/urfave/cli v1.22.3
github.com/valyala/fasthttp v1.0.0
github.com/vmihailenco/msgpack v4.0.1+incompatible
google.golang.org/appengine v1.4.0 // indirect
gopkg.in/yaml.v2 v2.2.1
github.com/vmihailenco/msgpack v4.0.4+incompatible
google.golang.org/appengine v1.6.5 // indirect
gopkg.in/yaml.v2 v2.2.8
)

go 1.14
73 changes: 35 additions & 38 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,64 +1,61 @@
github.com/c2h5oh/datasize v0.0.0-20171227191756-4eba002a5eae h1:2Zmk+8cNvAGuY8AyvZuWpUdpQUAXwfom4ReVMe/CTIo=
github.com/c2h5oh/datasize v0.0.0-20171227191756-4eba002a5eae/go.mod h1:S/7n9copUssQ56c7aAgHqftWO4LTf4xY6CGWt8Bc+3M=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee h1:BnPxIde0gjtTnc9Er7cxvBk8DHLWhEux0SxayC8dP6I=
github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee/go.mod h1:S/7n9copUssQ56c7aAgHqftWO4LTf4xY6CGWt8Bc+3M=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/klauspost/compress v1.4.0 h1:8nsMz3tWa9SWWPL60G1V6CUsf4lLjWLTNEtibhe8gh8=
github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e h1:+lIPJOWl+jSiJOc70QXJ07+2eg2Jy2EC7Mi11BWujeM=
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/urfave/cli v1.20.0+incompatible h1:QFYT1JjCCJRpORwrHF/Phh9uJGn3BJfdLZq2wuBF5g4=
github.com/urfave/cli v1.20.0+incompatible/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/urfave/cli v1.22.3 h1:FpNT6zq26xNpHZy08emi755QwzLPs6Pukqjlc7RfOMU=
github.com/urfave/cli v1.22.3/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.0.0 h1:BwIoZQbBsTo3v2F5lz5Oy3TlTq4wLKTLV260EVTEWco=
github.com/valyala/fasthttp v1.0.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU=
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3 h1:czFLhve3vsQetD6JOJ8NZZvGQIXlnN3/yXxbT6/awxI=
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65 h1:+rhAzEzT3f4JtomfC371qB+0Ola2caSKcY69NUBZrRQ=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
19 changes: 17 additions & 2 deletions log/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

var DefaultLogger RootLogger = &LogrusLogger{
Level: &LogrusLevel{logrus.InfoLevel},
Format: LogrusFormat("text"),
ColorMode: LogrusColorMode("auto"),
Format: "text",
ColorMode: "auto",
Delegate: logrus.New(),
}

Expand Down Expand Up @@ -50,6 +50,8 @@ type RootLogger interface {
Flags() []cli.Flag
GetLevel() Level
SetLevel(Level) error
GetFormat() Format
SetFormat(Format) error
}

func WithField(key string, value interface{}) Logger {
Expand Down Expand Up @@ -148,6 +150,14 @@ func SetLevel(l Level) error {
return DefaultLogger.SetLevel(l)
}

func GetFormat() Format {
return DefaultLogger.GetFormat()
}

func SetFormat(f Format) error {
return DefaultLogger.SetFormat(f)
}

type JsonValue struct {
Value interface{}
PrettyPrint bool
Expand Down Expand Up @@ -180,3 +190,8 @@ type Level interface {
flag.Value
Equals(Level) bool
}

type Format interface {
flag.Value
Equals(Format) bool
}
Loading

0 comments on commit b382957

Please sign in to comment.