Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(proxy): add structured logging (#99) #100

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ test/data/research/scientist/

.DS_Store
thumbs.db
pixa.log
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"mockgen",
"mohae",
"nakedret",
"natefinch",
"nolint",
"nolintlint",
"nosec",
Expand All @@ -77,6 +78,7 @@
"watchv",
"wgan",
"Wrapf",
"xutils"
"xutils",
"zapslog"
]
}
19 changes: 12 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,33 @@ require (
github.com/onsi/gomega v1.30.0
github.com/pkg/errors v0.9.1
github.com/samber/lo v1.39.0
github.com/snivilised/extendio v0.5.2
github.com/snivilised/lorax v0.4.2
github.com/snivilised/extendio v0.5.3
github.com/snivilised/lorax v0.4.4
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
go.uber.org/zap v1.26.0
go.uber.org/zap/exp v0.2.0
)

require (
github.com/avfs/avfs v0.33.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20231212022811-ec68065c825e // indirect
github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect
golang.org/x/tools v0.16.0 // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
golang.org/x/tools v0.16.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
)

require (
Expand All @@ -48,7 +53,7 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/mock v0.4.0
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
23 changes: 23 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/avfs/avfs v0.33.0 h1:5WQXbUbr6VS7aani39ZN2Vrd/s3wLnyih1Sc4ExWTxs=
github.com/avfs/avfs v0.33.0/go.mod h1:Q59flcFRYe9KYkNMfrLUJney3yeKGQpcWRyxsDBW7vI=
github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ=
github.com/chzyer/readline v1.5.1 h1:upd/6fQk4src78LMRzh5vItIt361/o4uq553V8B5sGI=
github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObkaSkeBlk=
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cubiest/jibberjabber v1.0.1 h1:JxKC9EZcdw8azEbyWaNj62ppPMkbFJBf2ayPY1vBeDI=
github.com/cubiest/jibberjabber v1.0.1/go.mod h1:Ovt9ZAmzAgwQ8cWgvZ1se9oaGYzjHrlAXKM3NOzlQOs=
Expand All @@ -19,6 +23,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
Expand All @@ -38,11 +44,15 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20231212022811-ec68065c825e h1:bwOy7hAFd0C91URzMIEBfr6BAz29yk7Qj0cy6S7DJlU=
github.com/google/pprof v0.0.0-20231212022811-ec68065c825e/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 h1:dHLYa5D8/Ta0aLR2XcPsrkpAgGeFs6thhMcQK0oQ0n8=
github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab h1:BA4a7pe6ZTd9F8kXETBoijjFJ/ntaa//1wiH9BZu4zU=
github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand Down Expand Up @@ -92,8 +102,12 @@ github.com/snivilised/cobrass v0.4.2 h1:V2LqFKZWYqdewSRPeLFqyKPfOr96ihs4+ixSnP/5
github.com/snivilised/cobrass v0.4.2/go.mod h1:bweMGepAjflKLqlCLkGi+Jvdru6ttdOr3L75rKq2yA8=
github.com/snivilised/extendio v0.5.2 h1:gpaA5hGM0DCyY1PHy51fnmAI76tzCOOo4rteyuWSTDI=
github.com/snivilised/extendio v0.5.2/go.mod h1:Ctp0GkEwMJ51FmgJE9nLLv86VTWILzgILdTgAeQ+BME=
github.com/snivilised/extendio v0.5.3 h1:zuVT1GM2JzqCrC2i6MilKBdFBqGVA0fmwldlgGmEO4Q=
github.com/snivilised/extendio v0.5.3/go.mod h1:2oHYhcClC43GVmhiUkQITujOqCW/RRWR4vXXl2VIfMo=
github.com/snivilised/lorax v0.4.2 h1:jPo+o4cP/BUYBkR6sg3oLybHx0j2R+0wMLnvOf/gh0g=
github.com/snivilised/lorax v0.4.2/go.mod h1:vyhM905Fc4fzShAXPvykS8ZRnO6B85hd0emJgZE4iNY=
github.com/snivilised/lorax v0.4.4 h1:fxuuew+88yUC9JkTq2iQhGx8tvECBzj2ugjssWlTI6A=
github.com/snivilised/lorax v0.4.4/go.mod h1:82r6nAoXWo1sdLXpj5RxYbAmiomu+xYVIXPn+cgG7I4=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
Expand Down Expand Up @@ -126,11 +140,15 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
go.uber.org/zap/exp v0.2.0 h1:FtGenNNeCATRB3CmB/yEUnjEFeJWpB/pMcy7e2bKPYs=
go.uber.org/zap/exp v0.2.0/go.mod h1:t0gqAIdh1MfKv9EwN/dLwfZnJxe9ITAZN78HEWPFWDQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8=
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM=
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
Expand All @@ -153,8 +171,11 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
Expand All @@ -164,6 +185,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM=
golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA=
golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
3 changes: 3 additions & 0 deletions src/app/command/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type Bootstrap struct {
SchemesCFG proxy.SchemesConfig
SamplerCFG proxy.SamplerConfig
AdvancedCFG proxy.AdvancedConfig
LoggingCFG proxy.LoggingConfig
Vfs storage.VirtualFS
}

Expand Down Expand Up @@ -123,6 +124,7 @@ func (b *Bootstrap) Root(options ...ConfigureOptionFn) *cobra.Command {
Schemes: &MsSchemesConfigReader{},
Sampler: &MsSamplerConfigReader{},
Advanced: &MsAdvancedConfigReader{},
Logging: &MsLoggingConfigReader{},
},
},
}
Expand Down Expand Up @@ -260,4 +262,5 @@ func (b *Bootstrap) viper() {
b.SchemesCFG, _ = b.OptionsInfo.Config.Readers.Schemes.Read(b.OptionsInfo.Config.Viper)
b.SamplerCFG, _ = b.OptionsInfo.Config.Readers.Sampler.Read(b.OptionsInfo.Config.Viper)
b.AdvancedCFG, _ = b.OptionsInfo.Config.Readers.Advanced.Read(b.OptionsInfo.Viper)
b.LoggingCFG, _ = b.OptionsInfo.Config.Readers.Logging.Read(b.OptionsInfo.Viper)
}
9 changes: 8 additions & 1 deletion src/app/command/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var _ = Describe("Bootstrap", Ordered, func() {
mockSchemesReader *mocks.MockSchemesConfigReader
mockSamplerReader *mocks.MockSamplerConfigReader
mockAdvancedReader *mocks.MockAdvancedConfigReader
mockLoggingReader *mocks.MockLoggingConfigReader
mockViperConfig *cmocks.MockViperConfig
)

Expand All @@ -69,9 +70,14 @@ var _ = Describe("Bootstrap", Ordered, func() {
mockSchemesReader = mocks.NewMockSchemesConfigReader(ctrl)
mockSamplerReader = mocks.NewMockSamplerConfigReader(ctrl)
mockAdvancedReader = mocks.NewMockAdvancedConfigReader(ctrl)
mockLoggingReader = mocks.NewMockLoggingConfigReader(ctrl)
helpers.DoMockReadInConfig(mockViperConfig)
helpers.DoMockConfigs(config,
mockProfilesReader, mockSchemesReader, mockSamplerReader, mockAdvancedReader,
mockProfilesReader,
mockSchemesReader,
mockSamplerReader,
mockAdvancedReader,
mockLoggingReader,
)
})

Expand All @@ -97,6 +103,7 @@ var _ = Describe("Bootstrap", Ordered, func() {
Schemes: mockSchemesReader,
Sampler: mockSamplerReader,
Advanced: mockAdvancedReader,
Logging: mockLoggingReader,
}
})

Expand Down
29 changes: 24 additions & 5 deletions src/app/command/config-defaults.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package command

import (
"os"
"path/filepath"

"github.com/pkg/errors"
"github.com/snivilised/cobrass/src/clif"
"github.com/snivilised/pixa/src/app/proxy"
)

const (
defaultNoFiles = 3
defaultNoFolders = 3
defaultNoProgramRetries = 2
defaultNoFiles = 3
defaultNoFolders = 3
defaultNoProgramRetries = 2
defaultLogMaxSizeInMb = 10
defaultLogMaxNoOfBackups = 3
defaultLogMaxAgeInDays = 30
)

type (
defaultSchemes map[string]proxy.SchemeConfig // should be the proxy interface
defaultSchemes map[string]proxy.SchemeConfig
defaultSchemesConfig struct {
schemes defaultSchemes
}
Expand All @@ -31,6 +38,7 @@ var (
DefaultSamplerConfig *MsSamplerConfig
DefaultSchemesConfig *defaultSchemesConfig
DefaultAdvancedConfig *MsAdvancedConfig
DefaultLoggingConfig *MsLoggingConfig
)

func init() {
Expand Down Expand Up @@ -59,7 +67,6 @@ func init() {
},
}

// tbd: repatriate MsSchemesConfig
DefaultSchemesConfig = &defaultSchemesConfig{
schemes: defaultSchemes{
"blur-sf": &defaultSchemeConfig{
Expand Down Expand Up @@ -90,4 +97,16 @@ func init() {
Trash: "TRASH",
},
}

userHomeDir, err := os.UserHomeDir()
if err != nil {
panic(errors.Wrap(err, "could not get home dir"))
}

DefaultLoggingConfig = &MsLoggingConfig{
LogPath: filepath.Join(userHomeDir, "snivilised", "pixa"),
MaxSize: defaultLogMaxSizeInMb,
MaxBackups: defaultLogMaxNoOfBackups,
MaxAge: defaultLogMaxAgeInDays,
}
}
13 changes: 13 additions & 0 deletions src/app/command/config-readers.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,22 @@ func (r *MsAdvancedConfigReader) Read(viper configuration.ViperConfig) (proxy.Ad
return &advancedCFG, err
}

type MsLoggingConfigReader struct{}

func (r *MsLoggingConfigReader) Read(viper configuration.ViperConfig) (proxy.LoggingConfig, error) {
var (
loggingCFG MsLoggingConfig
)

err := viper.UnmarshalKey("logging", &loggingCFG)

return &loggingCFG, err
}

type ConfigReaders struct {
Profiles proxy.ProfilesConfigReader
Schemes proxy.SchemesConfigReader
Sampler proxy.SamplerConfigReader
Advanced proxy.AdvancedConfigReader
Logging proxy.LoggingConfigReader
}
9 changes: 8 additions & 1 deletion src/app/command/magick-cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var _ = Describe("MagickCmd", Ordered, func() {
mockSchemesReader *mocks.MockSchemesConfigReader
mockSamplerReader *mocks.MockSamplerConfigReader
mockAdvancedReader *mocks.MockAdvancedConfigReader
mockLoggingReader *mocks.MockLoggingConfigReader
mockViperConfig *cmocks.MockViperConfig
)

Expand All @@ -48,9 +49,14 @@ var _ = Describe("MagickCmd", Ordered, func() {
mockSchemesReader = mocks.NewMockSchemesConfigReader(ctrl)
mockSamplerReader = mocks.NewMockSamplerConfigReader(ctrl)
mockAdvancedReader = mocks.NewMockAdvancedConfigReader(ctrl)
mockLoggingReader = mocks.NewMockLoggingConfigReader(ctrl)
helpers.DoMockReadInConfig(mockViperConfig)
helpers.DoMockConfigs(config,
mockProfilesReader, mockSchemesReader, mockSamplerReader, mockAdvancedReader,
mockProfilesReader,
mockSchemesReader,
mockSamplerReader,
mockAdvancedReader,
mockLoggingReader,
)
})

Expand All @@ -74,6 +80,7 @@ var _ = Describe("MagickCmd", Ordered, func() {
Schemes: mockSchemesReader,
Sampler: mockSamplerReader,
Advanced: mockAdvancedReader,
Logging: mockLoggingReader,
}
}),
}
Expand Down
33 changes: 33 additions & 0 deletions src/app/command/config.go → src/app/command/ms-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,36 @@ func (cfg *MsAdvancedConfig) LegacyLabel() string {
func (cfg *MsAdvancedConfig) TrashLabel() string {
return cfg.Labels.Trash
}

type MsLoggingConfig struct {
LogPath string `mapstructure:"log-path"`
MaxSize uint `mapstructure:"max-size"`
MaxBackups uint `mapstructure:"max-backups"`
MaxAge uint `mapstructure:"max-age"`
LogLevel string `mapstructure:"level"`
Format string `mapstructure:"time-format"`
}

func (cfg *MsLoggingConfig) Path() string {
return cfg.LogPath
}

func (cfg *MsLoggingConfig) MaxSizeInMb() uint {
return cfg.MaxSize
}

func (cfg *MsLoggingConfig) MaxNoOfBackups() uint {
return cfg.MaxBackups
}

func (cfg *MsLoggingConfig) MaxAgeInDays() uint {
return cfg.MaxAge
}

func (cfg *MsLoggingConfig) Level() string {
return cfg.LogLevel
}

func (cfg *MsLoggingConfig) TimeFormat() string {
return cfg.Format
}
19 changes: 11 additions & 8 deletions src/app/command/shrink-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,17 @@ func (b *Bootstrap) buildShrinkCommand(container *assistant.CobraContainer) *cob
}

appErr = proxy.EnterShrink(
inputs,
b.OptionsInfo.Program,
b.OptionsInfo.Config.Viper,
b.ProfilesCFG,
b.SchemesCFG,
b.SamplerCFG,
b.AdvancedCFG,
b.Vfs,
&proxy.ShrinkParams{
Inputs: inputs,
Program: b.OptionsInfo.Program,
Config: b.OptionsInfo.Config.Viper,
ProfilesCFG: b.ProfilesCFG,
SchemesCFG: b.SchemesCFG,
SamplerCFG: b.SamplerCFG,
AdvancedCFG: b.AdvancedCFG,
LoggingCFG: b.LoggingCFG,
Vfs: b.Vfs,
},
)
} else {
return xvErr
Expand Down
Loading