// LogError logs the given error to the default logger and any configured services.
LogError logs the given error to the default logger and any configured services.
// LogError logs the given error to the default logger and any configured services .
func LogError(desc string, err error) {
	buf := make([]byte, 1<<16)
	stackSize := runtime.Stack(buf, false)
	stackTrace := string(buf[0:stackSize])
	log.Println("======================================")
	log.Printf("Error occurred while '%s'!", desc)
	errDesc := ""
	if err != nil {
		errDesc = err.Error()
	} else {
		errDesc = "(err == nil)"
	}
	log.Println(errDesc)
	log.Println(stackTrace)
	log.Println("======================================")
	if config.GetCurrent().ErrorLog.SlackEnabled {
		title := fmt.Sprintf("An error occurred - %s", desc)
		err = slack.Post(config.GetCurrent().ErrorLog.SlackURL, slack.WebhookMessage{
			Attachments: []slack.WebhookAttachment{
				{
					Fallback: title,
					Color:    "danger",
					Title:    title,
					Text:     "```" + stackTrace + "```",
					Fields: []slack.WebhookField{
						{
							Title: "Host",
							Value: config.GetCurrent().Server.HostName,
							Short: true,
						},
						{
							Title: "Message",
							Value: errDesc,
							Short: true,
						},
					},
					MarkdownIn: []string{
						"fields",
					},
				},
			},
		})
		if err != nil {
			log.Println("An error occurred while reporting the previous error to Slack")
			log.Println(err)
		}
	}
}
func LogError ( desc string , err error ) { buf := make ( [ ] byte , 1 << 16 ) stackSize := runtime . Stack ( buf , false ) stackTrace := string ( buf [ 0 : stackSize ] ) log . Println ( " " ) log . Printf ( " " , desc ) errDesc := " " if err != nil { errDesc = err . Error ( ) } else { errDesc = " " } log . Println ( errDesc ) log . Println ( stackTrace ) log . Println ( " " ) if config . GetCurrent ( ) . ErrorLog . SlackEnabled { title := fmt . Sprintf ( " " , desc ) err = slack . Post ( config . GetCurrent ( ) . ErrorLog . SlackURL , slack . WebhookMessage { Attachments : [ ] slack . WebhookAttachment { { Fallback : title , Color : " " , Title : title , Text : " " + stackTrace + " " , Fields : [ ] slack . WebhookField { { Title : " " , Value : config . GetCurrent ( ) . Server . HostName , Short : true , } , { Title : " " , Value : errDesc , Short : true , } , } , MarkdownIn : [ ] string { " " , } , } , } , } ) if err != nil { log . Println ( " " ) log . Println ( err ) } } }
LogError logs the given error to the default logger and any configured services.
LogError logs the given error to the default logger and any configured services .