Skip to content

Commit

Permalink
added additional trace logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxcapades committed Jul 23, 2020
1 parent ac4dba9 commit 4087118
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/config/cmd-options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"bytes"
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
"io"
"os"
Expand All @@ -21,24 +22,30 @@ type FileOptions interface {
}

func ParseFileOptions(path string) (FileOptions, error) {
logrus.Trace("config.ParseFileOptions")
file, err := os.Open(path)
if err != nil {
logrus.Debug("failed to open config file")
return nil, err
}
defer file.Close()

buf := new(bytes.Buffer)
if _, err := io.Copy(file, buf); err != nil {
logrus.Debug("failed to read config file")
return nil, err
}

return ParseOptionsReader(buf)
}

func ParseOptionsReader(reader io.Reader) (FileOptions, error) {
logrus.Trace("config.ParseOptionsReader")

out := new(fileOptions)
dec := yaml.NewDecoder(reader)
if err := dec.Decode(out); err != nil {
logrus.Debug("failed to decode byte buffer")
return nil, err
}

Expand All @@ -48,6 +55,7 @@ func ParseOptionsReader(reader io.Reader) (FileOptions, error) {
}

func appendDefaultFileTypes(types []string) []string {
logrus.Trace("config.appendDefaultFileTypes")
return append(types, globalAllowedTypes...)
}

Expand Down

0 comments on commit 4087118

Please sign in to comment.