forked from Mirrors/bubbletea
Utility function for logging to the system log
This commit is contained in:
parent
4f42c502ed
commit
051a370769
15
tea.go
15
tea.go
|
@ -3,6 +3,8 @@ package tea
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
|
"log/syslog"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/term"
|
"github.com/pkg/term"
|
||||||
|
@ -210,3 +212,16 @@ func ExitFullscreen() {
|
||||||
func ClearScreen() {
|
func ClearScreen() {
|
||||||
fmt.Printf(esc + "2J" + esc + "3J" + esc + "1;1H")
|
fmt.Printf(esc + "2J" + esc + "3J" + esc + "1;1H")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UseSysLog logs to 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