mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-28 18:12:53 +00:00
move syslog into logger
This commit is contained in:
parent
10bf7bad43
commit
c10faac9e5
@ -6,8 +6,6 @@ import (
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/aler9/rtsp-simple-server/internal/syslog"
|
||||
)
|
||||
|
||||
// Level is a log level.
|
||||
@ -63,7 +61,7 @@ func New(level Level, destinations map[Destination]struct{}, filePath string) (*
|
||||
|
||||
if _, ok := destinations[DestinationSyslog]; ok {
|
||||
var err error
|
||||
lh.syslog, err = syslog.New("rtsp-simple-server")
|
||||
lh.syslog, err = newSyslog("rtsp-simple-server")
|
||||
if err != nil {
|
||||
lh.Close()
|
||||
return nil, err
|
||||
|
@ -1,6 +1,6 @@
|
||||
// +build !windows
|
||||
|
||||
package syslog
|
||||
package logger
|
||||
|
||||
import (
|
||||
"io"
|
||||
@ -11,8 +11,7 @@ type syslog struct {
|
||||
inner *native.Writer
|
||||
}
|
||||
|
||||
// New allocates a io.WriteCloser that writes to the system log.
|
||||
func New(prefix string) (io.WriteCloser, error) {
|
||||
func newSyslog(prefix string) (io.WriteCloser, error) {
|
||||
inner, err := native.New(native.LOG_INFO|native.LOG_DAEMON, prefix)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -23,12 +22,10 @@ func New(prefix string) (io.WriteCloser, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Close implements io.WriteCloser.
|
||||
func (ls *syslog) Close() error {
|
||||
return ls.inner.Close()
|
||||
}
|
||||
|
||||
// Write implements io.WriteCloser.
|
||||
func (ls *syslog) Write(p []byte) (int, error) {
|
||||
return ls.inner.Write(p)
|
||||
}
|
12
internal/logger/syslog_win.go
Normal file
12
internal/logger/syslog_win.go
Normal file
@ -0,0 +1,12 @@
|
||||
// +build windows
|
||||
|
||||
package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
func newSyslog(prefix string) (io.WriteCloser, error) {
|
||||
return nil, fmt.Errorf("not implemented on windows")
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
// +build windows
|
||||
|
||||
package syslog
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
// New allocates a io.WriteCloser that writes to the system log.
|
||||
func New(prefix string) (io.WriteCloser, error) {
|
||||
return nil, fmt.Errorf("not implemented on windows")
|
||||
}
|
Loading…
Reference in New Issue
Block a user