Toggle navigation
Toggle navigation
This project
Loading...
Sign in
UKKO
/
error_reports_go
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Iker Narvaez
2017-05-22 23:32:37 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
97b881347e972671f636a0745db00a5b57e40930
97b88134
1 parent
b2a6afa2
Refactor package & improve error logging
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
47 deletions
error_reporter.go
error_reporter.go
deleted
100644 → 0
View file @
b2a6afa
package
error_reporter
import
(
"time"
"log"
"os"
"git.ukko.mx/ukko/influx_client_go.git"
)
var
(
defaultUsername
=
os
.
Getenv
(
"INFLUX_USERNAME"
)
defaultPassword
=
os
.
Getenv
(
"INFLUX_PASSWORD"
)
defaultDbAddress
=
os
.
Getenv
(
"INFLUX_DB_ADDRESS"
)
defaultSeries
=
"errors"
influxClient
*
influx_client
.
InfluxClient
series
string
)
func
InitReporting
(
db
string
,
username
string
,
password
string
,
dbAddress
string
)
{
influxClient
=
influx_client
.
CreateClient
(
db
,
username
,
password
,
dbAddress
)
series
=
defaultSeries
}
func
InitDefaultReporting
(
db
string
)
{
influxClient
=
influx_client
.
CreateClient
(
db
,
defaultUsername
,
defaultPassword
,
defaultDbAddress
)
series
=
defaultSeries
}
func
Report
(
who
string
,
message
string
,
err
error
)
{
log
.
Fatalf
(
"%s: %s"
,
message
,
err
)
tags
:=
errorSystemTags
(
who
,
message
,
err
)
fields
:=
map
[
string
]
interface
{}{
"value"
:
1
,
}
stamp
:=
time
.
Now
()
influxClient
.
CreatePoint
(
series
,
tags
,
fields
,
stamp
)
}
func
errorSystemTags
(
who
string
,
message
string
,
err
error
)
map
[
string
]
string
{
host
,
_
:=
os
.
Hostname
()
return
map
[
string
]
string
{
"hostname"
:
host
,
"process"
:
who
,
"message"
:
message
,
"exception"
:
err
.
Error
(),
}
}
Please
register
or
login
to post a comment