Permalink
Browse files

support windows

  • Loading branch information...
justone committed Jan 10, 2017
1 parent 6f5535e commit c66f939a2cce86bfcb0421f8577d995da7920b71
Showing with 38 additions and 12 deletions.
  1. +1 −1 build.sh
  2. +1 −11 main.go
  3. +22 −0 syslog.go
  4. +9 −0 syslog_windows.go
  5. +5 −0 util.go
@@ -13,7 +13,7 @@ VERSION="${DATE}-${ABBREV_SHA1}"
echo "Building $VERSION"
echo
gox -ldflags "-X main.version=$VERSION" -osarch="darwin/amd64 linux/amd64 linux/arm"
gox -ldflags "-X main.version=$VERSION" -osarch="darwin/amd64 linux/amd64 linux/arm windows/amd64"
mkdir $VERSION
12 main.go
@@ -3,12 +3,9 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"log/syslog"
"os"
"github.com/Sirupsen/logrus"
logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog"
"github.com/jessevdk/go-flags"
)
@@ -55,14 +52,7 @@ func main() {
logrus.SetFormatter(&logrus.JSONFormatter{})
}
globalOptions.LogSyslog = func() {
hook, err := logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO, "pmb")
if err == nil {
logrus.SetFormatter(&SyslogFormatter{})
// discard all output
logrus.SetOutput(ioutil.Discard)
logrus.AddHook(hook)
}
setupSyslog()
}
originalArgs = os.Args
@@ -0,0 +1,22 @@
// +build !windows
package main
import (
"io/ioutil"
"log/syslog"
"github.com/Sirupsen/logrus"
logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog"
)
func setupSyslog() {
hook, err := logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO, "pmb")
if err == nil {
logrus.SetFormatter(&SyslogFormatter{})
// discard all output
logrus.SetOutput(ioutil.Discard)
logrus.AddHook(hook)
}
}
@@ -0,0 +1,9 @@
// +build windows
package main
import "github.com/Sirupsen/logrus"
func setupSyslog() {
logrus.Warnf("syslog not supported here.")
}
@@ -23,6 +23,8 @@ func copyToClipboard(data string) error {
cmd = exec.Command("pbcopy")
} else if _, err := exec.LookPath("tmux"); err == nil {
cmd = exec.Command("tmux", "load-buffer", "-")
} else if _, err := exec.LookPath("clip"); err == nil {
cmd = exec.Command("clip")
}
cmd.Stdin = strings.NewReader(data)
@@ -119,6 +121,9 @@ func displayNotice(message string, sticky bool) error {
} else if _, err := exec.LookPath("tmux"); err == nil {
cmd = exec.Command("tmux", "display-message", message)
logrus.Debugf("Using tmux for notification.")
} else if _, err := exec.LookPath("SnoreToast"); err == nil {
cmd = exec.Command("SnoreToast", "-t", "PMB", "-m", message)
logrus.Debugf("Using SnoreToast for notification.")
} else {
logrus.Warningf("Unable to display notice.")
return nil

0 comments on commit c66f939

Please sign in to comment.