FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
slog/syslog.go at main · unrolled/slog · GitHub
This repository was archived by the owner on Dec 27, 2023. It is now read-only.
unrolled
/
slog
Public archive
Notifications
You must be signed in to change notification settings
Fork
1
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
slog
/
syslog.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (34 loc) · 810 Bytes
Breadcrumbs
slog
/
syslog.go
Copy path
File metadata and controls
40 lines (34 loc) · 810 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package
slog
import
(
"log"
"log/syslog"
"os"
"sync"
)
// LockedSyslogWriteSyncer logs to syslog as well as stdout.
type
LockedSyslogWriteSyncer
struct
{
sync.
Mutex
w
*
syslog.
Writer
ws
WriteSyncer
}
// NewLockedSyslogWriteSyncer creates a new write syncer for syslog.
func
NewLockedSyslogWriteSyncer
(
network
,
address
,
tag
string
)
WriteSyncer
{
w
,
err
:=
syslog
.
Dial
(
network
,
address
,
syslog
.
LOG_INFO
,
tag
)
if
err
!=
nil
{
log
.
Fatalf
(
"Failed to dial syslog: %s"
,
err
.
Error
())
}
return
&
LockedSyslogWriteSyncer
{
w
:
w
,
ws
:
os
.
Stdout
}
}
func
(
l
*
LockedSyslogWriteSyncer
)
Write
(
bs
[]
byte
) (
int
,
error
) {
l
.
Lock
()
n
,
err
:=
l
.
w
.
Write
(
bs
)
_
,
_
=
l
.
ws
.
Write
(
bs
)
l
.
Unlock
()
return
n
,
err
}
func
(
l
*
LockedSyslogWriteSyncer
)
Sync
()
error
{
l
.
Lock
()
err
:=
l
.
ws
.
Sync
()
l
.
Unlock
()
return
err
}
Back
|
FazBrowse Home
|
New Git URL