Files
bunny-bot/internal/elog/init.go
eleksir 0c34b6e781 Global code ovehaul - remove CAS and other, add 15 minute greet check
- Remove CAS, as it no longer works for us
- Remove other checks
- Implement 15 minute greet timeout check
- Fix chat logos
- Ditch thirdparty logger, use stdlib log facility wrapper for logging
2026-10-20 12:20:16 +03:00

47 lines
1.0 KiB
Go

package elog
import (
"fmt"
"os"
)
// Init switches chat logging on.
//
// An empty root disables it, and every Log* call becomes a no-op — chat logging
// is optional. A non-empty root must already exist: a path that does not is a
// typo, and silently logging nowhere is the worst possible response to one, so
// this returns an error and moon.ParseConfig treats it as fatal.
func Init(rootDir string) error {
if rootDir == "" {
setRoot("")
return nil
}
info, err := os.Stat(rootDir)
if err != nil {
return fmt.Errorf("chat_logs directory %s is not usable: %w", rootDir, err)
}
if !info.IsDir() {
return fmt.Errorf("%w: %s", errNotDirectory, rootDir)
}
setRoot(rootDir)
return nil
}
// Close disables chat logging.
//
// Nothing is held open between lines, so there are no handles to close; this
// exists so shutdown has a symmetric counterpart to Init and so a misbehaving
// caller can stop writing.
func Close() error {
setRoot("")
return nil
}
/* vim: set ft=go noet ai ts=4 sw=4 sts=4: */