added colors to the logs

This commit is contained in:
2024-03-17 12:18:30 +01:00
parent cc745d177d
commit c978386ca8
2 changed files with 7 additions and 3 deletions

View File

@@ -4,5 +4,6 @@ var color map[string]string = map[string]string{
"red": "#FF6B6B",
"yellow": "#FFD93D",
"green": "#6BCB77",
"blue": "#008DDA",
"primary": "#211951",
}

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"strings"
@@ -24,6 +23,7 @@ type Message struct {
type Embed struct {
Author Author `json:"author"`
Title string `json:"title"`
Color string `json:"color"`
Description string `json:"description"`
Footer Footer `json:"footer"`
Timestamp string `json:"timestamp"`
@@ -50,6 +50,10 @@ func webhook(p []byte) {
}
var logJson Log
json.Unmarshal(p, &logJson)
var color string = "36314"
if logJson.Level == "Error" {
color = "16739179"
}
m := Message{
Embeds: []Embed{
{
@@ -57,6 +61,7 @@ func webhook(p []byte) {
Name: logJson.File,
},
Title: logJson.Function,
Color: color,
Description: logJson.Message,
Footer: Footer{
Text: logJson.Level,
@@ -81,7 +86,5 @@ func webhook(p []byte) {
if err != nil {
fmt.Println(err)
}
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
defer resp.Body.Close()
}