Skip to content

Commit f536b51

Browse files
author
Dean Karn
authored
fix unhashable value during dedupe process (#48)
1 parent 76f472c commit f536b51

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [8.0.1] - 2022-06-23
10+
### Fixed
11+
- Handling un-hashable tag values during dedupe process.
12+
913
## [8.0.0] - 2022-06-07
1014
### Added
1115
- Automatic file, line and package addition to error log when using `WithError`.
@@ -26,5 +30,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2630
- Removed ability to remove individual log levels externally; RemoveHandler+AddHandler can do the same.
2731

2832

29-
[Unreleased]: https://github.com/go-playground/log/compare/v8.0.0...HEAD
33+
[Unreleased]: https://github.com/go-playground/log/compare/v8.0.1...HEAD
34+
[8.0.1]: https://github.com/go-playground/log/compare/v8.0.0...v8.0.1
3035
[8.0.0]: https://github.com/go-playground/log/compare/v7.0.2...v8.0.0

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## log
2-
<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)
2+
<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)
33
[![Test](https://github.com/go-playground/log/actions/workflows/go.yml/badge.svg)](https://github.com/go-playground/log/actions/workflows/go.yml)
44
[![Coverage Status](https://coveralls.io/repos/github/go-playground/log/badge.svg?branch=master)](https://coveralls.io/github/go-playground/log?branch=master)
55
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/log)](https://goreportcard.com/report/github.com/go-playground/log)

errors.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package log
22

33
import (
4+
"fmt"
45
"strconv"
56
"strings"
67

@@ -15,20 +16,20 @@ func errorsWithError(e Entry, err error) Entry {
1516
case errors.Chain:
1617
types := make([]byte, 0, 32)
1718
tags := make([]Field, 0, len(t))
18-
dedupeTags := make(map[Field]bool)
19+
dedupeTags := make(map[string]bool)
1920
dedupeType := make(map[string]bool)
2021
errorBuff := BytePool().Get()
2122
for _, e := range t {
2223
errorBuff.B = formatLink(e, errorBuff.B)
2324
errorBuff.B = append(errorBuff.B, ' ')
2425

2526
for _, tag := range e.Tags {
26-
field := Field{Key: tag.Key, Value: tag.Value}
27-
if dedupeTags[field] {
27+
key := fmt.Sprintf("%s-%v", tag.Key, tag.Value)
28+
if dedupeTags[key] {
2829
continue
2930
}
30-
dedupeTags[field] = true
31-
tags = append(tags, field)
31+
dedupeTags[key] = true
32+
tags = append(tags, Field{Key: tag.Key, Value: tag.Value})
3233
}
3334
for _, typ := range e.Types {
3435
if dedupeType[typ] {

0 commit comments

Comments
 (0)