-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfacility.go
More file actions
37 lines (30 loc) · 724 Bytes
/
facility.go
File metadata and controls
37 lines (30 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package graylog
import (
"os"
"path/filepath"
"runtime/debug"
)
// SetFacility set Facility log filed used when generating a log message in
// GELF format. By default, it is filled in during initialization using the
// path to the main module of the application.
//
// If you want to change this value, then this must be done before
// initializing the log.
func SetFacility(s string) {
facility = s
}
var facility = initFacility()
func initFacility() string {
var name string
if buildInfo, ok := debug.ReadBuildInfo(); ok {
name = buildInfo.Main.Path
}
if name == "" {
name = filepath.Base(os.Args[0])
name = name[:len(name)-len(filepath.Ext(name))]
}
if name == "." {
name = ""
}
return name
}