Skip to content

Commit

Permalink
fix unhashable value during dedupe process (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
deankarn committed Jun 23, 2022
1 parent 76f472c commit f536b51
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [8.0.1] - 2022-06-23
### Fixed
- Handling un-hashable tag values during dedupe process.

## [8.0.0] - 2022-06-07
### Added
- Automatic file, line and package addition to error log when using `WithError`.
Expand All @@ -26,5 +30,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed ability to remove individual log levels externally; RemoveHandler+AddHandler can do the same.


[Unreleased]: https://github.com/go-playground/log/compare/v8.0.0...HEAD
[Unreleased]: https://github.com/go-playground/log/compare/v8.0.1...HEAD
[8.0.1]: https://github.com/go-playground/log/compare/v8.0.0...v8.0.1
[8.0.0]: https://github.com/go-playground/log/compare/v7.0.2...v8.0.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## log
<img align="center" src="https://raw.githubusercontent.com/go-playground/log/master/logo.png">![Project status](https://img.shields.io/badge/version-8.0.0-green.svg)
<img align="center" src="https://raw.githubusercontent.com/go-playground/log/master/logo.png">![Project status](https://img.shields.io/badge/version-8.0.1-green.svg)
[![Test](https://github.com/go-playground/log/actions/workflows/go.yml/badge.svg)](https://github.com/go-playground/log/actions/workflows/go.yml)
[![Coverage Status](https://coveralls.io/repos/github/go-playground/log/badge.svg?branch=master)](https://coveralls.io/github/go-playground/log?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/log)](https://goreportcard.com/report/github.com/go-playground/log)
Expand Down
11 changes: 6 additions & 5 deletions errors.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package log

import (
"fmt"
"strconv"
"strings"

Expand All @@ -15,20 +16,20 @@ func errorsWithError(e Entry, err error) Entry {
case errors.Chain:
types := make([]byte, 0, 32)
tags := make([]Field, 0, len(t))
dedupeTags := make(map[Field]bool)
dedupeTags := make(map[string]bool)
dedupeType := make(map[string]bool)
errorBuff := BytePool().Get()
for _, e := range t {
errorBuff.B = formatLink(e, errorBuff.B)
errorBuff.B = append(errorBuff.B, ' ')

for _, tag := range e.Tags {
field := Field{Key: tag.Key, Value: tag.Value}
if dedupeTags[field] {
key := fmt.Sprintf("%s-%v", tag.Key, tag.Value)
if dedupeTags[key] {
continue
}
dedupeTags[field] = true
tags = append(tags, field)
dedupeTags[key] = true
tags = append(tags, Field{Key: tag.Key, Value: tag.Value})
}
for _, typ := range e.Types {
if dedupeType[typ] {
Expand Down

0 comments on commit f536b51

Please sign in to comment.