Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in log with empty header #51

Merged
merged 1 commit into from Jun 14, 2022
Merged

Fix panic in log with empty header #51

merged 1 commit into from Jun 14, 2022

Commits on Jun 14, 2022

  1. Fix panic in log with empty header

    Previously using `l.SetHeader("")` would panic with:
    
    	--- FAIL: TestEmptyHeader (0.00s)
    	panic: runtime error: index out of range [-1] [recovered]
    		panic: runtime error: index out of range [-1]
    
    	goroutine 18 [running]:
    	github.com/labstack/gommon/log.(*Logger).log(0xc00014e990, 0x1, {0x5fb505, 0xd}, {0x0, 0x0, 0x0})
    		/home/martin/src/gommon/log/log.go:394 +0x615
    	github.com/labstack/gommon/log.(*Logger).Debugf(...)
    		/home/martin/src/gommon/log/log.go:158
    	github.com/labstack/gommon/log.TestEmptyHeader(0xc000129860?)
    		/home/martin/src/gommon/log/log_test.go:128 +0xb1
    
    This adds a check for that. It also checks if there is any content
    before writing a space in the "Text header" else branch so you don't end
    up with " my message".
    arp242 committed Jun 14, 2022
    Copy the full SHA
    f718471 View commit details
    Browse the repository at this point in the history