Major Logging Overhaul

in this commit:

- centralize logging output handler.
- set global Info/Debug/Error log levels based on config file or flags.
- remove per-plugin debug arg handling.
- add a I!, D!, or E! to every log message.
- add configuration option to specify where to send logs.

closes #1786
This commit is contained in:
Cameron Sparr
2016-09-30 22:37:56 +01:00
parent 78ced6bc30
commit c7834209d2
52 changed files with 363 additions and 269 deletions

View File

@@ -19,7 +19,7 @@ type FilestackWebhook struct {
func (fs *FilestackWebhook) Register(router *mux.Router, acc telegraf.Accumulator) {
router.HandleFunc(fs.Path, fs.eventHandler).Methods("POST")
log.Printf("Started the webhooks_filestack on %s\n", fs.Path)
log.Printf("I! Started the webhooks_filestack on %s\n", fs.Path)
fs.acc = acc
}

View File

@@ -17,7 +17,7 @@ type GithubWebhook struct {
func (gh *GithubWebhook) Register(router *mux.Router, acc telegraf.Accumulator) {
router.HandleFunc(gh.Path, gh.eventHandler).Methods("POST")
log.Printf("Started the webhooks_github on %s\n", gh.Path)
log.Printf("I! Started the webhooks_github on %s\n", gh.Path)
gh.acc = acc
}
@@ -58,7 +58,7 @@ func (e *newEventError) Error() string {
}
func NewEvent(data []byte, name string) (Event, error) {
log.Printf("New %v event received", name)
log.Printf("D! New %v event received", name)
switch name {
case "commit_comment":
return generateEvent(data, &CommitCommentEvent{})

View File

@@ -21,7 +21,7 @@ func (md *MandrillWebhook) Register(router *mux.Router, acc telegraf.Accumulator
router.HandleFunc(md.Path, md.returnOK).Methods("HEAD")
router.HandleFunc(md.Path, md.eventHandler).Methods("POST")
log.Printf("Started the webhooks_mandrill on %s\n", md.Path)
log.Printf("I! Started the webhooks_mandrill on %s\n", md.Path)
md.acc = acc
}

View File

@@ -19,7 +19,7 @@ type RollbarWebhook struct {
func (rb *RollbarWebhook) Register(router *mux.Router, acc telegraf.Accumulator) {
router.HandleFunc(rb.Path, rb.eventHandler).Methods("POST")
log.Printf("Started the webhooks_rollbar on %s\n", rb.Path)
log.Printf("I! Started the webhooks_rollbar on %s\n", rb.Path)
rb.acc = acc
}

View File

@@ -73,7 +73,7 @@ func (wb *Webhooks) Listen(acc telegraf.Accumulator) {
err := http.ListenAndServe(fmt.Sprintf("%s", wb.ServiceAddress), r)
if err != nil {
log.Printf("Error starting server: %v", err)
log.Printf("E! Error starting server: %v", err)
}
}
@@ -100,10 +100,10 @@ func (wb *Webhooks) AvailableWebhooks() []Webhook {
func (wb *Webhooks) Start(acc telegraf.Accumulator) error {
go wb.Listen(acc)
log.Printf("Started the webhooks service on %s\n", wb.ServiceAddress)
log.Printf("I! Started the webhooks service on %s\n", wb.ServiceAddress)
return nil
}
func (rb *Webhooks) Stop() {
log.Println("Stopping the Webhooks service")
log.Println("I! Stopping the Webhooks service")
}