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
bf943ddb
Commit
bf943ddb
authored
Feb 01, 2016
by
Dieter Plaetinck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
actually make use of the LogLevel type
why else would it be defined? and this is sane anyway.
parent
3f5b33b0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
12 deletions
+13
-12
pkg/log/console.go
+4
-4
pkg/log/file.go
+2
-2
pkg/log/log.go
+6
-5
pkg/log/syslog.go
+1
-1
No files found.
pkg/log/console.go
View file @
bf943ddb
...
...
@@ -46,7 +46,7 @@ var (
// ConsoleWriter implements LoggerInterface and writes messages to terminal.
type
ConsoleWriter
struct
{
lg
*
log
.
Logger
Level
int
`json:"level"`
Level
LogLevel
`json:"level"`
Formatting
bool
`json:"formatting"`
}
...
...
@@ -63,7 +63,7 @@ func (cw *ConsoleWriter) Init(config string) error {
return
json
.
Unmarshal
([]
byte
(
config
),
cw
)
}
func
(
cw
*
ConsoleWriter
)
WriteMsg
(
msg
string
,
skip
,
level
int
)
error
{
func
(
cw
*
ConsoleWriter
)
WriteMsg
(
msg
string
,
skip
int
,
level
LogLevel
)
error
{
if
cw
.
Level
>
level
{
return
nil
}
...
...
@@ -82,11 +82,11 @@ func (_ *ConsoleWriter) Flush() {
func
(
_
*
ConsoleWriter
)
Destroy
()
{
}
func
printConsole
(
level
int
,
msg
string
)
{
func
printConsole
(
level
LogLevel
,
msg
string
)
{
consoleWriter
.
WriteMsg
(
msg
,
0
,
level
)
}
func
printfConsole
(
level
int
,
format
string
,
v
...
interface
{})
{
func
printfConsole
(
level
LogLevel
,
format
string
,
v
...
interface
{})
{
consoleWriter
.
WriteMsg
(
fmt
.
Sprintf
(
format
,
v
...
),
0
,
level
)
}
...
...
pkg/log/file.go
View file @
bf943ddb
...
...
@@ -41,7 +41,7 @@ type FileLogWriter struct {
startLock
sync
.
Mutex
// Only one log can write to the file
Level
int
`json:"level"`
Level
LogLevel
`json:"level"`
}
// an *os.File writer with locker.
...
...
@@ -132,7 +132,7 @@ func (w *FileLogWriter) docheck(size int) {
}
// write logger message into file.
func
(
w
*
FileLogWriter
)
WriteMsg
(
msg
string
,
skip
,
level
int
)
error
{
func
(
w
*
FileLogWriter
)
WriteMsg
(
msg
string
,
skip
int
,
level
LogLevel
)
error
{
if
level
<
w
.
Level
{
return
nil
}
...
...
pkg/log/log.go
View file @
bf943ddb
...
...
@@ -99,7 +99,7 @@ func Close() {
type
LogLevel
int
const
(
TRACE
=
iota
TRACE
LogLevel
=
iota
DEBUG
INFO
WARN
...
...
@@ -111,7 +111,7 @@ const (
// LoggerInterface represents behaviors of a logger provider.
type
LoggerInterface
interface
{
Init
(
config
string
)
error
WriteMsg
(
msg
string
,
skip
,
level
int
)
error
WriteMsg
(
msg
string
,
skip
int
,
level
LogLevel
)
error
Destroy
()
Flush
()
}
...
...
@@ -132,7 +132,8 @@ func Register(name string, log loggerType) {
}
type
logMsg
struct
{
skip
,
level
int
skip
int
level
LogLevel
msg
string
}
...
...
@@ -141,7 +142,7 @@ type logMsg struct {
type
Logger
struct
{
adapter
string
lock
sync
.
Mutex
level
int
level
LogLevel
msg
chan
*
logMsg
outputs
map
[
string
]
LoggerInterface
quit
chan
bool
...
...
@@ -188,7 +189,7 @@ func (l *Logger) DelLogger(adapter string) error {
return
nil
}
func
(
l
*
Logger
)
writerMsg
(
skip
,
level
int
,
msg
string
)
error
{
func
(
l
*
Logger
)
writerMsg
(
skip
int
,
level
LogLevel
,
msg
string
)
error
{
if
l
.
level
>
level
{
return
nil
}
...
...
pkg/log/syslog.go
View file @
bf943ddb
...
...
@@ -39,7 +39,7 @@ func (sw *SyslogWriter) Init(config string) error {
return
nil
}
func
(
sw
*
SyslogWriter
)
WriteMsg
(
msg
string
,
skip
,
level
int
)
error
{
func
(
sw
*
SyslogWriter
)
WriteMsg
(
msg
string
,
skip
int
,
level
LogLevel
)
error
{
var
err
error
switch
level
{
...
...
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