Fix logging
This commit is contained in:
parent
38dfab9d58
commit
bf8c465560
|
|
@ -38,7 +38,6 @@ after_success:
|
||||||
- ls -l release/
|
- ls -l release/
|
||||||
- |
|
- |
|
||||||
declare -r SSH_FILE="$(mktemp -u $HOME/.ssh/XXXXX)"
|
declare -r SSH_FILE="$(mktemp -u $HOME/.ssh/XXXXX)"
|
||||||
|
|
||||||
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||||
# Get deploy key for golift/homebrew-mugs.
|
# Get deploy key for golift/homebrew-mugs.
|
||||||
openssl aes-256-cbc -K $encrypted_9f3147001275_key -iv $encrypted_9f3147001275_iv -in ".travis/github_deploy_key.enc" -out "$SSH_FILE" -d
|
openssl aes-256-cbc -K $encrypted_9f3147001275_key -iv $encrypted_9f3147001275_iv -in ".travis/github_deploy_key.enc" -out "$SSH_FILE" -d
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
log.SetFlags(log.LstdFlags)
|
||||||
unifi := &unifipoller.UnifiPoller{}
|
unifi := &unifipoller.UnifiPoller{}
|
||||||
if unifi.ParseFlags(os.Args[1:]); unifi.ShowVer {
|
if unifi.ParseFlags(os.Args[1:]); unifi.ShowVer {
|
||||||
fmt.Printf("unifi-poller v%s\n", unifipoller.Version)
|
fmt.Printf("unifi-poller v%s\n", unifipoller.Version)
|
||||||
|
|
|
||||||
|
|
@ -44,29 +44,22 @@ func (u *UnifiPoller) GetConfig() (err error) {
|
||||||
UnifiBase: defaultUnifURL,
|
UnifiBase: defaultUnifURL,
|
||||||
Interval: Dur{defaultInterval},
|
Interval: Dur{defaultInterval},
|
||||||
Sites: []string{"default"},
|
Sites: []string{"default"},
|
||||||
|
Quiet: u.DumpJSON != "",
|
||||||
}
|
}
|
||||||
|
u.Logf("Loading Configuration File: %s", u.ConfigFile)
|
||||||
var buf []byte
|
var buf []byte
|
||||||
switch buf, err = ioutil.ReadFile(u.ConfigFile); {
|
switch buf, err = ioutil.ReadFile(u.ConfigFile); {
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return err
|
return err
|
||||||
case strings.HasSuffix(u.ConfigFile, ".json"):
|
case strings.HasSuffix(u.ConfigFile, ".json"):
|
||||||
err = json.Unmarshal(buf, u.Config)
|
return json.Unmarshal(buf, u.Config)
|
||||||
case strings.HasSuffix(u.ConfigFile, ".xml"):
|
case strings.HasSuffix(u.ConfigFile, ".xml"):
|
||||||
err = xml.Unmarshal(buf, u.Config)
|
return xml.Unmarshal(buf, u.Config)
|
||||||
case strings.HasSuffix(u.ConfigFile, ".yaml"):
|
case strings.HasSuffix(u.ConfigFile, ".yaml"):
|
||||||
err = yaml.Unmarshal(buf, u.Config)
|
return yaml.Unmarshal(buf, u.Config)
|
||||||
default:
|
default:
|
||||||
err = toml.Unmarshal(buf, u.Config)
|
return toml.Unmarshal(buf, u.Config)
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if u.DumpJSON != "" {
|
|
||||||
u.Quiet = true
|
|
||||||
}
|
|
||||||
u.Logf("Loaded Configuration: %s", u.ConfigFile)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run invokes all the application logic and routines.
|
// Run invokes all the application logic and routines.
|
||||||
|
|
@ -74,7 +67,7 @@ func (u *UnifiPoller) Run() (err error) {
|
||||||
if u.DumpJSON != "" {
|
if u.DumpJSON != "" {
|
||||||
return u.DumpJSONPayload()
|
return u.DumpJSONPayload()
|
||||||
}
|
}
|
||||||
if log.SetFlags(0); u.Debug {
|
if u.Debug {
|
||||||
log.SetFlags(log.Lshortfile | log.Lmicroseconds | log.Ldate)
|
log.SetFlags(log.Lshortfile | log.Lmicroseconds | log.Ldate)
|
||||||
u.LogDebugf("Debug Logging Enabled")
|
u.LogDebugf("Debug Logging Enabled")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue