diff --git a/diamond.go b/diamond.go index 2ed14d7..6b5017a 100644 --- a/diamond.go +++ b/diamond.go @@ -20,7 +20,7 @@ const defaultKey = "default" type Config struct { DryRun bool // when true, queries will not run on the underlying database LogLevel slog.Level // controls the level of information logged; defaults to slog.LevelInfo if not set - LogTo io.Writer // where to write log output to; defaults to os.Stdout + LogTo io.Writer // where to write log output to; defaults to os.Stdout } type Engine struct { @@ -121,6 +121,9 @@ func (e *Engine) logSql(msg, sql string) { // Disconnect - closes and disposes of this Engine's connection pool. func (e *Engine) Disconnect() { e.conn.Close() + if asFile, ok := e.cfg.LogTo.(*os.File); ok { + _ = asFile.Close() + } } // Open - creates a new connection according to `connString`