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

Custom log eval error loop #659

Merged
merged 4 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Unreleased changes are available as `avenga/couper:edge` container.
* Improved the way an SPA `bootstrap_file` gets cached and served in combination with `bootstrap_data` ([#656](https://github.com/avenga/couper/pull/656))
* Harmonized and improved logged error information for references to undefined blocks ([#651](https://github.com/avenga/couper/pull/651))

* **Fixed**
* Loop with evaluation error in [`custom_log_fields`](https://docs.couper.io/observation/logging#custom-logging) if log level is `"debug"` ([#659](https://github.com/avenga/couper/pull/659))

---

## [1.11.1](https://github.com/avenga/couper/releases/tag/v1.11.1)
Expand Down
8 changes: 7 additions & 1 deletion logging/hooks/custom_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ func init() {
}

func (c *CustomLogs) Levels() []logrus.Level {
return logrus.AllLevels
return []logrus.Level{
logrus.PanicLevel, // reasonable?
logrus.FatalLevel, // reasonable?
logrus.ErrorLevel,
logrus.WarnLevel, // not used?
logrus.InfoLevel,
}
}

func (c *CustomLogs) Fire(entry *logrus.Entry) error {
Expand Down
15 changes: 15 additions & 0 deletions server/http_custom_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,18 @@ func TestCustomLogs_Merge(t *testing.T) {
t.Errorf("expected\n%#v\ngot\n%#v", exp, got)
}
}

func TestCustomLogs_EvalError(t *testing.T) {
client := newClient()
helper := test.New(t)

shutdown, hook := newCouper("testdata/integration/logs/04_couper.hcl", test.New(t))
defer shutdown()

req, err := http.NewRequest(http.MethodGet, "http://localhost:8080/", nil)
helper.Must(err)

hook.Reset()
_, err = client.Do(req)
helper.Must(err)
}
1 change: 1 addition & 0 deletions server/http_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func newCouperWithConfig(couperConfig *config.Couper, helper *test.Helper) (func
defer testServerMu.Unlock()

log, hook := test.NewLogger()
log.Level, _ = logrus.ParseLevel(couperConfig.Settings.LogLevel)

ctx, cancelFn := context.WithCancel(context.Background())
shutdownFn := func() {
Expand Down
14 changes: 14 additions & 0 deletions server/testdata/integration/logs/04_couper.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server {
api {
endpoint "/**" {
custom_log_fields = foo() # error!
response {
status = 204
}
}
}
}

settings {
log_level = "debug"
}