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 authored and mskwon committed Jun 14, 2023
1 parent 50bce08 commit c20eeb0
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 c20eeb0

Please sign in to comment.