added colors to the logs
This commit is contained in:
@@ -4,5 +4,6 @@ var color map[string]string = map[string]string{
|
|||||||
"red": "#FF6B6B",
|
"red": "#FF6B6B",
|
||||||
"yellow": "#FFD93D",
|
"yellow": "#FFD93D",
|
||||||
"green": "#6BCB77",
|
"green": "#6BCB77",
|
||||||
|
"blue": "#008DDA",
|
||||||
"primary": "#211951",
|
"primary": "#211951",
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -24,6 +23,7 @@ type Message struct {
|
|||||||
type Embed struct {
|
type Embed struct {
|
||||||
Author Author `json:"author"`
|
Author Author `json:"author"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
|
Color string `json:"color"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Footer Footer `json:"footer"`
|
Footer Footer `json:"footer"`
|
||||||
Timestamp string `json:"timestamp"`
|
Timestamp string `json:"timestamp"`
|
||||||
@@ -50,6 +50,10 @@ func webhook(p []byte) {
|
|||||||
}
|
}
|
||||||
var logJson Log
|
var logJson Log
|
||||||
json.Unmarshal(p, &logJson)
|
json.Unmarshal(p, &logJson)
|
||||||
|
var color string = "36314"
|
||||||
|
if logJson.Level == "Error" {
|
||||||
|
color = "16739179"
|
||||||
|
}
|
||||||
m := Message{
|
m := Message{
|
||||||
Embeds: []Embed{
|
Embeds: []Embed{
|
||||||
{
|
{
|
||||||
@@ -57,6 +61,7 @@ func webhook(p []byte) {
|
|||||||
Name: logJson.File,
|
Name: logJson.File,
|
||||||
},
|
},
|
||||||
Title: logJson.Function,
|
Title: logJson.Function,
|
||||||
|
Color: color,
|
||||||
Description: logJson.Message,
|
Description: logJson.Message,
|
||||||
Footer: Footer{
|
Footer: Footer{
|
||||||
Text: logJson.Level,
|
Text: logJson.Level,
|
||||||
@@ -81,7 +86,5 @@ func webhook(p []byte) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
body, _ := io.ReadAll(resp.Body)
|
|
||||||
fmt.Println(string(body))
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user