fix(ax): align test names and usage comments
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
08b2a70fc5
commit
9eef0bab6e
3 changed files with 23 additions and 17 deletions
|
|
@ -328,18 +328,18 @@ func TestStackTrace_Good(t *testing.T) {
|
|||
assert.Equal(t, "op3 -> op2 -> op1", formatted)
|
||||
}
|
||||
|
||||
func TestStackTrace_PlainError(t *testing.T) {
|
||||
func TestStackTrace_Bad_PlainError(t *testing.T) {
|
||||
err := errors.New("plain error")
|
||||
assert.Empty(t, StackTrace(err))
|
||||
assert.Empty(t, FormatStackTrace(err))
|
||||
}
|
||||
|
||||
func TestStackTrace_Nil(t *testing.T) {
|
||||
func TestStackTrace_Bad_Nil(t *testing.T) {
|
||||
assert.Empty(t, StackTrace(nil))
|
||||
assert.Empty(t, FormatStackTrace(nil))
|
||||
}
|
||||
|
||||
func TestStackTrace_NoOp(t *testing.T) {
|
||||
func TestStackTrace_Bad_NoOp(t *testing.T) {
|
||||
err := &Err{Msg: "no op"}
|
||||
assert.Empty(t, StackTrace(err))
|
||||
assert.Empty(t, FormatStackTrace(err))
|
||||
|
|
|
|||
18
log.go
18
log.go
|
|
@ -59,13 +59,18 @@ type Logger struct {
|
|||
// RedactKeys is a list of keys whose values should be masked in logs.
|
||||
redactKeys []string
|
||||
|
||||
// Style functions for formatting (can be overridden)
|
||||
// StyleTimestamp formats the rendered timestamp prefix.
|
||||
StyleTimestamp func(string) string
|
||||
StyleDebug func(string) string
|
||||
StyleInfo func(string) string
|
||||
StyleWarn func(string) string
|
||||
StyleError func(string) string
|
||||
StyleSecurity func(string) string
|
||||
// StyleDebug formats the debug level prefix.
|
||||
StyleDebug func(string) string
|
||||
// StyleInfo formats the info level prefix.
|
||||
StyleInfo func(string) string
|
||||
// StyleWarn formats the warning level prefix.
|
||||
StyleWarn func(string) string
|
||||
// StyleError formats the error level prefix.
|
||||
StyleError func(string) string
|
||||
// StyleSecurity formats the security event prefix.
|
||||
StyleSecurity func(string) string
|
||||
}
|
||||
|
||||
// RotationOptions defines the log rotation and retention policy.
|
||||
|
|
@ -93,6 +98,7 @@ type RotationOptions struct {
|
|||
|
||||
// Options configures a Logger.
|
||||
type Options struct {
|
||||
// Level controls which messages are emitted.
|
||||
Level Level
|
||||
// Output is the destination for log messages. If Rotation is provided,
|
||||
// Output is ignored and logs are written to the rotating file instead.
|
||||
|
|
|
|||
16
log_test.go
16
log_test.go
|
|
@ -12,7 +12,7 @@ type nopWriteCloser struct{ goio.Writer }
|
|||
|
||||
func (nopWriteCloser) Close() error { return nil }
|
||||
|
||||
func TestLogger_Levels(t *testing.T) {
|
||||
func TestLogger_Levels_Good(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
level Level
|
||||
|
|
@ -62,7 +62,7 @@ func TestLogger_Levels(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLogger_KeyValues(t *testing.T) {
|
||||
func TestLogger_KeyValues_Good(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
l := New(Options{Level: LevelDebug, Output: &buf})
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ func TestLogger_KeyValues(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLogger_ErrorContext(t *testing.T) {
|
||||
func TestLogger_ErrorContext_Good(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
l := New(Options{Output: &buf, Level: LevelInfo})
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ func TestLogger_ErrorContext(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLogger_Redaction(t *testing.T) {
|
||||
func TestLogger_Redaction_Good(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
l := New(Options{
|
||||
Level: LevelInfo,
|
||||
|
|
@ -120,7 +120,7 @@ func TestLogger_Redaction(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLogger_InjectionPrevention(t *testing.T) {
|
||||
func TestLogger_InjectionPrevention_Good(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
l := New(Options{Level: LevelInfo, Output: &buf})
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ func TestLogger_InjectionPrevention(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLogger_SetLevel(t *testing.T) {
|
||||
func TestLogger_SetLevel_Good(t *testing.T) {
|
||||
l := New(Options{Level: LevelInfo})
|
||||
|
||||
if l.Level() != LevelInfo {
|
||||
|
|
@ -150,7 +150,7 @@ func TestLogger_SetLevel(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLevel_String(t *testing.T) {
|
||||
func TestLevel_String_Good(t *testing.T) {
|
||||
tests := []struct {
|
||||
level Level
|
||||
expected string
|
||||
|
|
@ -172,7 +172,7 @@ func TestLevel_String(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLogger_Security(t *testing.T) {
|
||||
func TestLogger_Security_Good(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
l := New(Options{Level: LevelError, Output: &buf})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue