Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
225e7a6a
Commit
225e7a6a
authored
Dec 11, 2015
by
Carl Bergquist
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3161 from mischief/syslog
syslog support closes #3160
parents
7e9963ae
60e797cc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
0 deletions
+113
-0
conf/defaults.ini
+12
-0
pkg/log/syslog.go
+93
-0
pkg/setting/setting.go
+8
-0
No files found.
conf/defaults.ini
View file @
225e7a6a
...
...
@@ -245,6 +245,18 @@ daily_rotate = true
# Expired days of log file(delete after max days), default is 7
max_days
=
7
[log.syslog]
level
=
# Syslog network type and address. This can be udp, tcp, or unix. If left blank, the default unix endpoints will be used.
network
=
address
=
# Syslog facility. user, daemon and local0 through local7 are valid.
facility
=
# Syslog tag. By default, the process' argv[0] is used.
tag
=
#################################### AMPQ Event Publisher ##########################
[event_publisher]
enabled
=
false
...
...
pkg/log/syslog.go
0 → 100644
View file @
225e7a6a
package
log
import
(
"encoding/json"
"errors"
"log/syslog"
)
type
SyslogWriter
struct
{
syslog
*
syslog
.
Writer
Network
string
`json:"network"`
Address
string
`json:"address"`
Facility
string
`json:"facility"`
Tag
string
`json:"tag"`
}
func
NewSyslog
()
LoggerInterface
{
return
new
(
SyslogWriter
)
}
func
(
sw
*
SyslogWriter
)
Init
(
config
string
)
error
{
if
err
:=
json
.
Unmarshal
([]
byte
(
config
),
sw
);
err
!=
nil
{
return
err
}
prio
,
err
:=
parseFacility
(
sw
.
Facility
)
if
err
!=
nil
{
return
err
}
w
,
err
:=
syslog
.
Dial
(
sw
.
Network
,
sw
.
Address
,
prio
,
sw
.
Tag
)
if
err
!=
nil
{
return
err
}
sw
.
syslog
=
w
return
nil
}
func
(
sw
*
SyslogWriter
)
WriteMsg
(
msg
string
,
skip
,
level
int
)
error
{
var
err
error
switch
level
{
case
TRACE
,
DEBUG
:
err
=
sw
.
syslog
.
Debug
(
msg
)
case
INFO
:
err
=
sw
.
syslog
.
Info
(
msg
)
case
WARN
:
err
=
sw
.
syslog
.
Warning
(
msg
)
case
ERROR
:
err
=
sw
.
syslog
.
Err
(
msg
)
case
CRITICAL
:
err
=
sw
.
syslog
.
Crit
(
msg
)
case
FATAL
:
err
=
sw
.
syslog
.
Alert
(
msg
)
default
:
err
=
errors
.
New
(
"invalid syslog level"
)
}
return
err
}
func
(
sw
*
SyslogWriter
)
Destroy
()
{
sw
.
syslog
.
Close
()
}
func
(
sw
*
SyslogWriter
)
Flush
()
{}
var
facilities
=
map
[
string
]
syslog
.
Priority
{
"user"
:
syslog
.
LOG_USER
,
"daemon"
:
syslog
.
LOG_DAEMON
,
"local0"
:
syslog
.
LOG_LOCAL0
,
"local1"
:
syslog
.
LOG_LOCAL1
,
"local2"
:
syslog
.
LOG_LOCAL2
,
"local3"
:
syslog
.
LOG_LOCAL3
,
"local4"
:
syslog
.
LOG_LOCAL4
,
"local5"
:
syslog
.
LOG_LOCAL5
,
"local6"
:
syslog
.
LOG_LOCAL6
,
"local7"
:
syslog
.
LOG_LOCAL7
,
}
func
parseFacility
(
facility
string
)
(
syslog
.
Priority
,
error
)
{
prio
,
ok
:=
facilities
[
facility
]
if
!
ok
{
return
syslog
.
LOG_LOCAL0
,
errors
.
New
(
"invalid syslog facility"
)
}
return
prio
,
nil
}
func
init
()
{
Register
(
"syslog"
,
NewSyslog
)
}
pkg/setting/setting.go
View file @
225e7a6a
...
...
@@ -573,6 +573,14 @@ func initLogging(args *CommandLineArgs) {
"driver"
:
sec
.
Key
(
"driver"
)
.
String
(),
"conn"
:
sec
.
Key
(
"conn"
)
.
String
(),
}
case
"syslog"
:
LogConfigs
[
i
]
=
util
.
DynMap
{
"level"
:
level
,
"network"
:
sec
.
Key
(
"network"
)
.
MustString
(
""
),
"address"
:
sec
.
Key
(
"address"
)
.
MustString
(
""
),
"facility"
:
sec
.
Key
(
"facility"
)
.
MustString
(
"local7"
),
"tag"
:
sec
.
Key
(
"tag"
)
.
MustString
(
""
),
}
}
cfgJsonBytes
,
_
:=
json
.
Marshal
(
LogConfigs
[
i
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment