From 1c9870001583fa3161c484378c9f2b332f4901bb Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 25 Jan 2020 07:15:56 +0100 Subject: [PATCH] syslog is only available on unix systems --- logging.go | 22 ++++++++++++++++++++++ tea.go | 17 +---------------- 2 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 logging.go diff --git a/logging.go b/logging.go new file mode 100644 index 0000000..3febb6c --- /dev/null +++ b/logging.go @@ -0,0 +1,22 @@ +// +build darwin dragonfly freebsd linux netbsd openbsd solaris + +package tea + +import ( + "log" + "log/syslog" +) + +// UseSysLog sets up logging to log the system log. This becomes helpful when +// debugging since we can't easily print to the terminal since our TUI is +// occupying it! +// +// On macOS this is a just a matter of: tail -f /var/log/system.log +func UseSysLog(programName string) error { + l, err := syslog.New(syslog.LOG_NOTICE, programName) + if err != nil { + return err + } + log.SetOutput(l) + return nil +} diff --git a/tea.go b/tea.go index 2eb44d6..48db258 100644 --- a/tea.go +++ b/tea.go @@ -3,8 +3,7 @@ package tea import ( "errors" "io" - "log" - "log/syslog" + "os" "strings" ) @@ -176,17 +175,3 @@ func (p *Program) render(model Model, linesRendered int) int { io.WriteString(os.Stdout, view) return strings.Count(view, "\r\n") } - -// UseSysLog sets up logging to log the system log. This becomes helpful when -// debugging since we can't easily print to the terminal since our TUI is -// occupying it! -// -// On macOS this is a just a matter of: tail -f /var/log/system.log -func UseSysLog(programName string) error { - l, err := syslog.New(syslog.LOG_NOTICE, programName) - if err != nil { - return err - } - log.SetOutput(l) - return nil -}