package auditlog

import (
	"database/sql"
	"log"
	"sync"
)

var (
	logQueue chan ActivityLog
	dbConn   *sql.DB
	once     sync.Once
)

// Init → main.go içinden çağrılacak (tek sefer)
func Init(db *sql.DB, bufferSize int) {
	log.Println("🟢 auditlog Init called, buffer:", bufferSize)

	dbConn = db
	logQueue = make(chan ActivityLog, bufferSize)

	go logWorker()
}

// Optional: app kapanırken flush/stop istersen
func Close() {
	if logQueue != nil {
		close(logQueue)
	}
}
