Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
eth-log-alerting
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Server Tools
eth-log-alerting
Commits
8b5dfdb9
Commit
8b5dfdb9
authored
7 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Add search
parent
07269710
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
eth-log-alerting.go
+17
-7
17 additions, 7 deletions
eth-log-alerting.go
with
17 additions
and
7 deletions
eth-log-alerting.go
+
17
−
7
View file @
8b5dfdb9
...
...
@@ -7,6 +7,7 @@ import (
"os"
"os/signal"
"path/filepath"
"regexp"
"syscall"
"github.com/asaskevich/govalidator"
...
...
@@ -14,12 +15,13 @@ import (
)
var
(
logPath
string
webhookURL
string
username
string
channel
string
color
string
iconURL
string
logPath
string
webhookURL
string
username
string
channel
string
color
string
iconURL
string
searchRegex
string
logger
*
log
.
Logger
debugDest
string
...
...
@@ -35,6 +37,7 @@ func init() {
flag
.
StringVar
(
&
channel
,
"channel"
,
""
,
"Channel to post log entries to"
)
flag
.
StringVar
(
&
color
,
"color"
,
"default"
,
"Color for entry, either named or hex with `#`"
)
flag
.
StringVar
(
&
iconURL
,
"icon-url"
,
""
,
"URL of icon to use for bot"
)
flag
.
StringVar
(
&
searchRegex
,
"search"
,
""
,
"Search term or regex to match"
)
flag
.
StringVar
(
&
debugDest
,
"debug-dest"
,
"os.Stdout"
,
"Destination for debug and other messages, omit to log to Stdout"
)
flag
.
BoolVar
(
&
debug
,
"debug"
,
false
,
"Include additional log data for debugging"
)
flag
.
Parse
()
...
...
@@ -72,7 +75,14 @@ func tailLog() {
}
for
line
:=
range
t
.
Lines
{
sendLine
(
line
)
if
len
(
searchRegex
)
==
0
{
go
sendLine
(
line
)
}
else
{
matched
,
_
:=
regexp
.
MatchString
(
searchRegex
,
line
.
Text
)
if
matched
{
go
sendLine
(
line
)
}
}
}
}
...
...
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