logger: add Fatal finalizers
All checks were successful
coverage / build (push) Successful in 2m37s
test / test (push) Successful in 4m49s

* closes #222

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2025-10-10 15:28:10 +03:00
parent 4a944274f4
commit 4d6d469d40
2 changed files with 17 additions and 4 deletions

View File

@@ -4,14 +4,12 @@ import (
"context"
"io"
"log/slog"
"os"
"reflect"
"regexp"
"runtime"
"strconv"
"sync"
"sync/atomic"
"time"
"go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/semconv"
@@ -234,8 +232,9 @@ func (s *slogLogger) Fatal(ctx context.Context, msg string, attrs ...interface{}
if closer, ok := s.opts.Out.(io.Closer); ok {
closer.Close()
}
time.Sleep(1 * time.Second)
os.Exit(1)
for _, fn := range s.opts.FatalFinalizers {
fn(ctx)
}
}
func (s *slogLogger) Warn(ctx context.Context, msg string, attrs ...interface{}) {