package main

import (
	"encoding/json"
	"fmt"
	"time"
)

func logJSON(level, message string) {
	entry := LogEntry{
		Level:     level,
		Message:   message,
		Timestamp: time.Now().Format("15:04:05"),
	}

	data, err := json.Marshal(entry)
	if err != nil {
		fmt.Printf(`{"level":"error","message":%q,"timestamp":"%s"}`+"\n", err.Error(), time.Now().Format("15:04:05"))
		return
	}

	fmt.Println(string(data))
}

func logInfo(message string) {
	logJSON("info", message)
}

func logThink(message string) {
	logJSON("think", message)
}

func logWarning(message string) {
	logJSON("warning", message)
}

func logError(message string) {
	logJSON("error", message)
}

func logTask(message string) {
	logJSON("task", message)
}
