Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
18d305f4
Commit
18d305f4
authored
Mar 07, 2019
by
Ruslan Drozhdzh
Committed by
Miek Gieben
Mar 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin/errors: remove cLogger and eLogger (#2657)
parent
89a4b9bd
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
161 deletions
+92
-161
plugin/errors/errors.go
plugin/errors/errors.go
+4
-13
plugin/errors/errors_test.go
plugin/errors/errors_test.go
+88
-148
No files found.
plugin/errors/errors.go
View file @
18d305f4
...
...
@@ -35,28 +35,19 @@ func (p *pattern) setTimer(t *time.Timer) {
// errorHandler handles DNS errors (and errors from other plugin).
type
errorHandler
struct
{
patterns
[]
*
pattern
eLogger
func
(
int
,
string
,
string
,
string
)
cLogger
func
(
uint32
,
string
,
time
.
Duration
)
stopFlag
uint32
Next
plugin
.
Handler
}
func
newErrorHandler
()
*
errorHandler
{
return
&
errorHandler
{
eLogger
:
errorLogger
,
cLogger
:
consLogger
}
}
func
errorLogger
(
code
int
,
qName
,
qType
,
err
string
)
{
log
.
Errorf
(
"%d %s %s: %s"
,
code
,
qName
,
qType
,
err
)
}
func
consLogger
(
cnt
uint32
,
pattern
string
,
p
time
.
Duration
)
{
log
.
Errorf
(
"%d errors like '%s' occurred in last %s"
,
cnt
,
pattern
,
p
)
return
&
errorHandler
{}
}
func
(
h
*
errorHandler
)
logPattern
(
i
int
)
{
cnt
:=
atomic
.
SwapUint32
(
&
h
.
patterns
[
i
]
.
count
,
0
)
if
cnt
>
0
{
h
.
cLogger
(
cnt
,
h
.
patterns
[
i
]
.
pattern
.
String
(),
h
.
patterns
[
i
]
.
period
)
log
.
Errorf
(
"%d errors like '%s' occurred in last %s"
,
cnt
,
h
.
patterns
[
i
]
.
pattern
.
String
(),
h
.
patterns
[
i
]
.
period
)
}
}
...
...
@@ -102,7 +93,7 @@ func (h *errorHandler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dn
}
}
state
:=
request
.
Request
{
W
:
w
,
Req
:
r
}
h
.
eLogger
(
rcode
,
state
.
Name
(),
state
.
Type
(),
strErr
)
log
.
Errorf
(
"%d %s %s: %s"
,
rcode
,
state
.
Name
(),
state
.
Type
(),
strErr
)
}
return
rcode
,
err
...
...
plugin/errors/errors_test.go
View file @
18d305f4
This diff is collapsed.
Click to expand it.
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