forked from Mirrors/bubbletea
syslog is only available on unix systems
This commit is contained in:
parent
bc67e3896b
commit
1c98700015
|
@ -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
|
||||
}
|
17
tea.go
17
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue