Skip to content

Commit

Permalink
Merge pull request #3 from appwrite/fix-webhooks-push
Browse files Browse the repository at this point in the history
fix: incident creation and resolution logic
  • Loading branch information
christyjacob4 authored Dec 20, 2024
2 parents 96779c4 + 7788758 commit ae2ed78
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 170 deletions.
9 changes: 4 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
version: '3.8'

services:
monitoring:
build:
context: .
dockerfile: Dockerfile
hostname: monitoring-local
command:
- monitoring
- "--url=${BETTER_STACK_URL}"
- "--interval=10"
- "--cpu-limit=90"
- "--memory-limit=80"
- "--interval=5"
- "--cpu-limit=5"
- "--memory-limit=10"
- "--disk-limit=85"
volumes:
- /:/host:ro
Expand Down
69 changes: 69 additions & 0 deletions logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package main

import (
"fmt"
"log"
"os"
"time"
)

const (
colorReset = "\033[0m"
colorRed = "\033[31m"
colorGreen = "\033[32m"
colorYellow = "\033[33m"
colorBlue = "\033[34m"
colorPurple = "\033[35m"
colorCyan = "\033[36m"
)

type Logger struct {
logger *log.Logger
}

func New() *Logger {
return &Logger{
logger: log.New(os.Stdout, "", 0),
}
}

func (l *Logger) formatMessage(level, format string, args ...interface{}) string {
timestamp := time.Now().Format("2006-01-02 15:04:05")
message := fmt.Sprintf(format, args...)
return fmt.Sprintf("%s [%s] %s", timestamp, level, message)
}

func (l *Logger) Log(format string, args ...interface{}) {
msg := l.formatMessage("LOG", format, args...)
l.logger.Printf("%s", msg)
}

func (l *Logger) Success(format string, args ...interface{}) {
msg := l.formatMessage("SUCCESS", format, args...)
l.logger.Printf("%s%s%s", colorGreen, msg, colorReset)
}

func (l *Logger) Warn(format string, args ...interface{}) {
msg := l.formatMessage("WARNING", format, args...)
l.logger.Printf("%s%s%s", colorYellow, msg, colorReset)
}

func (l *Logger) Error(format string, args ...interface{}) {
msg := l.formatMessage("ERROR", format, args...)
l.logger.Printf("%s%s%s", colorRed, msg, colorReset)
}

func (l *Logger) Info(format string, args ...interface{}) {
msg := l.formatMessage("INFO", format, args...)
l.logger.Printf("%s%s%s", colorBlue, msg, colorReset)
}

func (l *Logger) Debug(format string, args ...interface{}) {
msg := l.formatMessage("DEBUG", format, args...)
l.logger.Printf("%s%s%s", colorCyan, msg, colorReset)
}

func (l *Logger) Fatal(format string, args ...interface{}) {
msg := l.formatMessage("FATAL", format, args...)
l.logger.Fatalf("%s%s%s", colorPurple, msg, colorReset)
}
Loading

0 comments on commit ae2ed78

Please sign in to comment.