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
This commit is contained in:
46
internal/elog/init.go
Normal file
46
internal/elog/init.go
Normal file
@@ -0,0 +1,46 @@
|
||||
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: */
|
||||
Reference in New Issue
Block a user