Skip to content

Commit f8266fd

Browse files
committed
remove logging
1 parent 3dfbb27 commit f8266fd

31 files changed

+71
-228
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ For more information see the [wiki pages](https://github.com/isacikgoz/gitbatch/
3434
## Credits
3535
- [go-git](https://github.com/src-d/go-git) for git interface (partially)
3636
- [gocui](https://github.com/jroimartin/gocui) for user interface
37-
- [logrus](https://github.com/sirupsen/logrus) for logging
3837
- [viper](https://github.com/spf13/viper) for configuration management
3938
- [color](https://github.com/fatih/color) for colored text
4039
- [kingpin](https://github.com/alecthomas/kingpin) for command-line flag&options

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ require (
1111
github.com/mattn/go-isatty v0.0.7 // indirect
1212
github.com/mattn/go-runewidth v0.0.4 // indirect
1313
github.com/nsf/termbox-go v0.0.0-20190325093121-288510b9734e // indirect
14-
github.com/sirupsen/logrus v1.4.0
1514
github.com/spf13/viper v1.3.2
1615
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
1716
gopkg.in/alecthomas/kingpin.v2 v2.2.6

go.sum

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ github.com/jroimartin/gocui v0.4.0 h1:52jnalstgmc25FmtGcWqa0tcbMEWS6RpFLsOIO+I+E
2727
github.com/jroimartin/gocui v0.4.0/go.mod h1:7i7bbj99OgFHzo7kB2zPb8pXLqMBSQegY7azfqXMkyY=
2828
github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e h1:RgQk53JHp/Cjunrr1WlsXSZpqXn+uREuHvUVcK82CV8=
2929
github.com/kevinburke/ssh_config v0.0.0-20180830205328-81db2a75821e/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
30-
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
3130
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
3231
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
3332
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
@@ -54,8 +53,6 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
5453
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5554
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
5655
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
57-
github.com/sirupsen/logrus v1.4.0 h1:yKenngtzGh+cUSSh6GWbxW2abRqhYUSR/t/6+2QqNvE=
58-
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
5956
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
6057
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
6158
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
@@ -68,7 +65,6 @@ github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M=
6865
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
6966
github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
7067
github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
71-
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
7268
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
7369
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
7470
github.com/xanzy/ssh-agent v0.2.0 h1:Adglfbi5p9Z0BmK2oKU9nTG+zKfniSfnaMYB+ULd+Ro=
@@ -82,7 +78,6 @@ golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73r
8278
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI=
8379
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
8480
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
85-
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
8681
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
8782
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
8883
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

internal/app/builder.go

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package app
22

33
import (
4-
"errors"
4+
"fmt"
55
"os"
66

77
"github.com/isacikgoz/gitbatch/internal/gui"
8-
log "github.com/sirupsen/logrus"
98
)
109

1110
// The App struct is responsible to hold app-wide related entities. Currently
@@ -38,12 +37,6 @@ func Setup(argConfig *Config) (*App, error) {
3837
return nil, err
3938
}
4039
appConfig := overrideConfig(presetConfig, argConfig)
41-
42-
setLogLevel(appConfig.LogLevel)
43-
44-
// hopefull everything went smooth as butter
45-
log.Trace("App configuration completed")
46-
4740
dirs := generateDirectories(appConfig.Directories, appConfig.Depth)
4841

4942
if appConfig.QuickMode {
@@ -63,27 +56,6 @@ func Setup(argConfig *Config) (*App, error) {
6356
return app, nil
6457
}
6558

66-
// set the level of logging it is fatal by default
67-
func setLogLevel(logLevel string) {
68-
switch logLevel {
69-
case "trace":
70-
log.SetLevel(log.TraceLevel)
71-
case "debug":
72-
log.SetLevel(log.DebugLevel)
73-
case "info":
74-
log.SetLevel(log.InfoLevel)
75-
case "warn":
76-
log.SetLevel(log.WarnLevel)
77-
case "error":
78-
log.SetLevel(log.ErrorLevel)
79-
default:
80-
log.SetLevel(log.FatalLevel)
81-
}
82-
log.WithFields(log.Fields{
83-
"level": logLevel,
84-
}).Trace("logging level has been set")
85-
}
86-
8759
func overrideConfig(appConfig, setupConfig *Config) *Config {
8860
if len(setupConfig.Directories) > 0 {
8961
appConfig.Directories = setupConfig.Directories
@@ -107,7 +79,7 @@ func execQuickMode(dirs []string, cfg *Config) error {
10779
x := cfg.Mode == "fetch"
10880
y := cfg.Mode == "pull"
10981
if x == y {
110-
return errors.New("unrecognized quick mode: " + cfg.Mode)
82+
return fmt.Errorf("unrecognized quick mode: " + cfg.Mode)
11183
}
11284
quick(dirs, cfg.Mode)
11385
return nil

internal/app/builder_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"time"
88

99
"github.com/isacikgoz/gitbatch/internal/git"
10-
log "github.com/sirupsen/logrus"
1110
ggit "gopkg.in/src-d/go-git.v4"
1211
)
1312

@@ -55,21 +54,6 @@ func TestSetup(t *testing.T) {
5554
}
5655
}
5756

58-
func TestSetLogLevel(t *testing.T) {
59-
var tests = []struct {
60-
input string
61-
}{
62-
{"debug"},
63-
{"info"},
64-
}
65-
for _, test := range tests {
66-
setLogLevel(test.input)
67-
if test.input != log.GetLevel().String() {
68-
t.Errorf("Test Failed: %s inputted, actual: %s", test.input, log.GetLevel().String())
69-
}
70-
}
71-
}
72-
7357
func TestOverrideConfig(t *testing.T) {
7458
var tests = []struct {
7559
inp1 *Config

internal/app/config.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"path/filepath"
66
"runtime"
77

8-
log "github.com/sirupsen/logrus"
98
"github.com/spf13/viper"
109
)
1110

@@ -26,7 +25,6 @@ var (
2625
modeKeyDefault = "fetch"
2726
pathsKey = "paths"
2827
pathsKeyDefault = []string{"."}
29-
logLevelKey = "loglevel"
3028
logLevelKeyDefault = "error"
3129
qucikKey = "quick"
3230
qucikKeyDefault = false
@@ -54,7 +52,6 @@ func LoadConfiguration() (*Config, error) {
5452
}
5553
config := &Config{
5654
Directories: directories,
57-
LogLevel: viper.GetString(logLevelKey),
5855
Depth: viper.GetInt(recursionKey),
5956
QuickMode: viper.GetBool(qucikKey),
6057
Mode: viper.GetString(modeKey),
@@ -64,7 +61,6 @@ func LoadConfiguration() (*Config, error) {
6461

6562
// set default configuration parameters
6663
func setDefaults() error {
67-
viper.SetDefault(logLevelKey, logLevelKeyDefault)
6864
viper.SetDefault(qucikKey, qucikKeyDefault)
6965
viper.SetDefault(recursionKey, recursionKeyDefault)
7066
viper.SetDefault(modeKey, modeKeyDefault)
@@ -116,8 +112,6 @@ func osConfigDirectory(osname string) (osConfigDirectory string) {
116112
osConfigDirectory = os.Getenv("HOME") + "/Library/Application Support"
117113
case "linux":
118114
osConfigDirectory = os.Getenv("HOME") + "/.config"
119-
default:
120-
log.Warn("Operating system couldn't be recognized")
121115
}
122116
return osConfigDirectory
123117
}

internal/app/files.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"io/ioutil"
55
"os"
66
"path/filepath"
7-
8-
log "github.com/sirupsen/logrus"
97
)
108

119
// generateDirectories returns poosible git repositories to pipe into git pkg's
@@ -31,9 +29,6 @@ func walkRecursive(search, appendant []string) ([]string, []string) {
3129
// find possible repositories and remaining ones, b slice is possible ones
3230
a, b, err := seperateDirectories(search[i])
3331
if err != nil {
34-
log.WithFields(log.Fields{
35-
"directory": search[i],
36-
}).WithError(err).Trace("Can't read directory")
3732
continue
3833
}
3934
// since we started to search let's get rid of it and remove from search
@@ -55,20 +50,13 @@ func seperateDirectories(directory string) ([]string, []string, error) {
5550
files, err := ioutil.ReadDir(directory)
5651
// can we read the directory?
5752
if err != nil {
58-
log.WithFields(log.Fields{
59-
"directory": directory,
60-
}).Trace("Can't read directory")
6153
return nil, nil, nil
6254
}
6355
for _, f := range files {
6456
repo := directory + string(os.PathSeparator) + f.Name()
6557
file, err := os.Open(repo)
6658
// if we cannot open it, simply continue to iteration and don't consider
6759
if err != nil {
68-
log.WithFields(log.Fields{
69-
"file": file,
70-
"directory": repo,
71-
}).WithError(err).Trace("Failed to open file in the directory")
7260
file.Close()
7361
continue
7462
}

internal/command/add.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package command
22

33
import (
4-
"errors"
4+
"fmt"
55

66
"github.com/isacikgoz/gitbatch/internal/git"
7-
log "github.com/sirupsen/logrus"
87
)
98

109
// AddOptions defines the rules for "git add" command
@@ -33,7 +32,7 @@ func Add(r *git.Repository, f *git.File, o *AddOptions) error {
3332
err := addWithGoGit(r, f)
3433
return err
3534
}
36-
return errors.New("Unhandled add operation")
35+
return fmt.Errorf("unhandled add operation")
3736
}
3837

3938
// AddAll function is the wrapper of "git add ." command
@@ -44,10 +43,9 @@ func AddAll(r *git.Repository, o *AddOptions) error {
4443
args = append(args, "--dry-run")
4544
}
4645
args = append(args, ".")
47-
out, err := Run(r.AbsPath, "git", args)
46+
_, err := Run(r.AbsPath, "git", args)
4847
if err != nil {
49-
log.Warn("Error while add command")
50-
return errors.New(out + "\n" + err.Error())
48+
return fmt.Errorf("could not run add function: %v", err)
5149
}
5250
return nil
5351
}
@@ -65,10 +63,9 @@ func addWithGit(r *git.Repository, f *git.File, o *AddOptions) error {
6563
if o.DryRun {
6664
args = append(args, "--dry-run")
6765
}
68-
out, err := Run(r.AbsPath, "git", args)
66+
_, err := Run(r.AbsPath, "git", args)
6967
if err != nil {
70-
log.Warn("Error while add command")
71-
return errors.New(out + "\n" + err.Error())
68+
return fmt.Errorf("could not add %s: %v", f.AbsPath, err)
7269
}
7370
return nil
7471
}

internal/command/commit.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package command
22

33
import (
4-
"errors"
4+
"fmt"
55
"time"
66

77
giterr "github.com/isacikgoz/gitbatch/internal/errors"
88
"github.com/isacikgoz/gitbatch/internal/git"
9-
log "github.com/sirupsen/logrus"
109
gogit "gopkg.in/src-d/go-git.v4"
1110
"gopkg.in/src-d/go-git.v4/plumbing/object"
1211
)
@@ -33,7 +32,7 @@ func Commit(r *git.Repository, o *CommitOptions) (err error) {
3332
case ModeNative:
3433
return commitWithGoGit(r, o)
3534
}
36-
return errors.New("Unhandled commit operation")
35+
return fmt.Errorf("unhandled commit operation")
3736
}
3837

3938
// commitWithGit is simply a bare git commit -m <msg> command which is flexible
@@ -46,7 +45,6 @@ func commitWithGit(r *git.Repository, opt *CommitOptions) (err error) {
4645
args = append(args, opt.CommitMsg)
4746
}
4847
if out, err := Run(r.AbsPath, "git", args); err != nil {
49-
log.Warn("Error at git command (commit)")
5048
r.Refresh()
5149
return giterr.ParseGitError(out, err)
5250
}

internal/command/config.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package command
22

33
import (
4-
"errors"
4+
"fmt"
55

66
"github.com/isacikgoz/gitbatch/internal/git"
7-
log "github.com/sirupsen/logrus"
87
)
98

109
// ConfigOptions defines the rules for commit operation
@@ -40,7 +39,7 @@ func Config(r *git.Repository, o *ConfigOptions) (value string, err error) {
4039
case ModeNative:
4140
return configWithGoGit(r, o)
4241
}
43-
return value, errors.New("Unhandled config operation")
42+
return value, fmt.Errorf("unhandled config operation")
4443
}
4544

4645
// configWithGit is simply a bare git config --site <option>.<section> command which is flexible
@@ -90,7 +89,6 @@ func addConfigWithGit(r *git.Repository, options *ConfigOptions, value string) (
9089
args = append(args, value)
9190
}
9291
if _, err := Run(r.AbsPath, "git", args); err != nil {
93-
log.Warn("Error at git command (config)")
9492
return err
9593
}
9694
// till this step everything should be ok

0 commit comments

Comments
 (0)