Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
3b87db2e
Commit
3b87db2e
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
EXPERIMENTAL: log a message about discarded email notifications.
Refers to
#4
parent
497e0b3b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ATxCommon/NLog/RateLimitWrapper.cs
+7
-0
7 additions, 0 deletions
ATxCommon/NLog/RateLimitWrapper.cs
with
7 additions
and
0 deletions
ATxCommon/NLog/RateLimitWrapper.cs
+
7
−
0
View file @
3b87db2e
using
System
;
using
System.ComponentModel
;
using
NLog
;
using
NLog.Common
;
using
NLog.Targets
;
using
NLog.Targets.Wrappers
;
...
...
@@ -18,6 +19,7 @@ namespace ATxCommon.NLog
public
class
RateLimitWrapper
:
WrapperTargetBase
{
private
DateTime
_lastLogEvent
=
DateTime
.
MinValue
;
private
static
readonly
Logger
Log
=
LogManager
.
GetCurrentClassLogger
();
protected
override
void
Write
(
AsyncLogEventInfo
logEvent
)
{
if
((
DateTime
.
Now
-
_lastLogEvent
).
TotalMinutes
>=
MinLogInterval
)
{
...
...
@@ -25,6 +27,11 @@ namespace ATxCommon.NLog
WrappedTarget
.
WriteAsyncLogEvent
(
logEvent
);
}
else
{
logEvent
.
Continuation
(
null
);
// EXPERIMENTAL: check if the level of the log event is higher than "WARN" (3) and
// log a debug message about keeping back the email message:
if
(
logEvent
.
LogEvent
.
Level
.
Ordinal
>
3
)
{
Log
.
Debug
(
"RateLimitWrapper: not sending email, frequency too high!"
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment