Skip to content

Commit

Permalink
fix thread-safe zerolog usage, details rs/zerolog#242 and https://git…
Browse files Browse the repository at this point in the history
  • Loading branch information
Slach committed Jun 13, 2023
1 parent e1ca361 commit 8b96079
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,10 +909,12 @@ func (ch *ClickHouse) SelectSingleRowNoCtx(dest interface{}, query string, args

func (ch *ClickHouse) LogQuery(query string, args ...interface{}) string {
var logF *zerolog.Event
// zerolog is not thread-safe https://github.com/rs/zerolog/issues/242 ;(
logger := ch.Logger.With().Logger()
if !ch.Config.LogSQLQueries {
logF = ch.Logger.Debug()
logF = logger.Debug()
} else {
logF = ch.Logger.Info()
logF = logger.Info()
}
if len(args) > 0 {
logF.Msg(strings.NewReplacer("\n", " ", "\r", " ", "\t", " ").Replace(fmt.Sprintf("%s with args %v", query, args)))
Expand Down

0 comments on commit 8b96079

Please sign in to comment.