>_
QuickLogger v1.0
v1.0 Release — Incredibly Simple Setup

Real-Time Logging.
Zero Overhead.

A lightweight logging system with an incredibly simple configuration. Stream your application logs instantly with an automatic 24-hour retention buffer.

Easy Integration

Any Language

Send logs easily from any application. It's simple and blazing fast.

// --- .env ---
// QUICK_LOGGER_TOKEN=demo_token
// ------------

package logger

import (
	"bytes"
	"encoding/json"
	"net/http"
	"os"
	"sync"
	"time"

	"github.com/joho/godotenv"
)

var (
	apiUrl        string
	logBuffer     []map[string]string
	mutex         sync.Mutex
	flushInterval = 5 * time.Second
)

func init() {
	_ = godotenv.Load()
	apiUrl = "https://universallogger.fly.dev/api/v1/logs/batch?token=" + os.Getenv("QUICK_LOGGER_TOKEN")

	// Start a background worker to periodically send logs
	go startBackgroundFlusher()
}

// startBackgroundFlusher runs infinitely and flushes logs at regular intervals.
func startBackgroundFlusher() {
	for {
		time.Sleep(flushInterval)
		flushLogs()
	}
}

// flushLogs securely reads the current buffer, clears it, and sends the batch via HTTP.
func flushLogs() {
	mutex.Lock()
	if len(logBuffer) == 0 {
		mutex.Unlock()
		return
	}
	// Copy the buffer and clear the original
	batch := logBuffer
	logBuffer = nil
	mutex.Unlock()

	// Send the batch to the QuickLogger API asynchronously
	body, _ := json.Marshal(batch)
	go http.Post(apiUrl, "application/json", bytes.NewBuffer(body))
}

// sendLog is a thread-safe helper to append a single log to the buffer.
func sendLog(level, message string) {
	mutex.Lock()
	defer mutex.Unlock()
	
	logBuffer = append(logBuffer, map[string]string{
		"level":   level,
		"message": message,
	})
}

// Public API methods for logging
func LogInfo(message string) { sendLog("INFO", message) }
func LogWarning(message string) { sendLog("WARN", message) }
func LogError(message string) { sendLog("ERROR", message) }

Live Demo

Live Stream

Watch the logs stream in real-time below, powered by WebSockets.

demo-terminal
[SYSTEM] Establishing handshake over secure proxy...
[SYSTEM] Connected to demo project.
[SYSTEM] Listening for incoming events...