mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Utility function for logging to the system log
This commit is contained in:
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user