aboutsummaryrefslogtreecommitdiffhomepage
path: root/caddytest
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2023-08-02 03:13:46 -0400
committerGitHub <[email protected]>2023-08-02 03:13:46 -0400
commit5c51c1db2ce450a3fa003834097ad010b3844673 (patch)
tree230cf40973b5b0d1edbcad0088914281296adcdf /caddytest
parentda23501457e90024814fe0149aaa57dd4384227a (diff)
downloadcaddy-5c51c1db2ce450a3fa003834097ad010b3844673.tar.gz
caddy-5c51c1db2ce450a3fa003834097ad010b3844673.zip
httpcaddyfile: Allow `hostnames` & logger name overrides for log directive (#5643)
* httpcaddyfile: Allow `hostnames` override for log directive * Implement access logger name overrides * Fix panic & default logger clobbering edgecase
Diffstat (limited to 'caddytest')
-rw-r--r--caddytest/integration/caddyfile_adapt/log_override_hostname.txt71
-rw-r--r--caddytest/integration/caddyfile_adapt/log_override_name_multiaccess.txt86
-rw-r--r--caddytest/integration/caddyfile_adapt/log_override_name_multiaccess_debug.txt91
3 files changed, 248 insertions, 0 deletions
diff --git a/caddytest/integration/caddyfile_adapt/log_override_hostname.txt b/caddytest/integration/caddyfile_adapt/log_override_hostname.txt
new file mode 100644
index 000000000..4511fd494
--- /dev/null
+++ b/caddytest/integration/caddyfile_adapt/log_override_hostname.txt
@@ -0,0 +1,71 @@
+*.example.com {
+ log {
+ hostnames foo.example.com bar.example.com
+ output file /foo-bar.txt
+ }
+ log {
+ hostnames baz.example.com
+ output file /baz.txt
+ }
+}
+----------
+{
+ "logging": {
+ "logs": {
+ "default": {
+ "exclude": [
+ "http.log.access.log0",
+ "http.log.access.log1"
+ ]
+ },
+ "log0": {
+ "writer": {
+ "filename": "/foo-bar.txt",
+ "output": "file"
+ },
+ "include": [
+ "http.log.access.log0"
+ ]
+ },
+ "log1": {
+ "writer": {
+ "filename": "/baz.txt",
+ "output": "file"
+ },
+ "include": [
+ "http.log.access.log1"
+ ]
+ }
+ }
+ },
+ "apps": {
+ "http": {
+ "servers": {
+ "srv0": {
+ "listen": [
+ ":443"
+ ],
+ "routes": [
+ {
+ "match": [
+ {
+ "host": [
+ "*.example.com"
+ ]
+ }
+ ],
+ "terminal": true
+ }
+ ],
+ "logs": {
+ "logger_names": {
+ "bar.example.com": "log0",
+ "baz.example.com": "log1",
+ "foo.example.com": "log0"
+ }
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/caddytest/integration/caddyfile_adapt/log_override_name_multiaccess.txt b/caddytest/integration/caddyfile_adapt/log_override_name_multiaccess.txt
new file mode 100644
index 000000000..a3b0cec63
--- /dev/null
+++ b/caddytest/integration/caddyfile_adapt/log_override_name_multiaccess.txt
@@ -0,0 +1,86 @@
+{
+ log access-console {
+ include http.log.access.foo
+ output file access-localhost.log
+ format console
+ }
+
+ log access-json {
+ include http.log.access.foo
+ output file access-localhost.json
+ format json
+ }
+}
+
+http://localhost:8881 {
+ log foo
+}
+----------
+{
+ "logging": {
+ "logs": {
+ "access-console": {
+ "writer": {
+ "filename": "access-localhost.log",
+ "output": "file"
+ },
+ "encoder": {
+ "format": "console"
+ },
+ "include": [
+ "http.log.access.foo"
+ ]
+ },
+ "access-json": {
+ "writer": {
+ "filename": "access-localhost.json",
+ "output": "file"
+ },
+ "encoder": {
+ "format": "json"
+ },
+ "include": [
+ "http.log.access.foo"
+ ]
+ },
+ "default": {
+ "exclude": [
+ "http.log.access.foo"
+ ]
+ }
+ }
+ },
+ "apps": {
+ "http": {
+ "servers": {
+ "srv0": {
+ "listen": [
+ ":8881"
+ ],
+ "routes": [
+ {
+ "match": [
+ {
+ "host": [
+ "localhost"
+ ]
+ }
+ ],
+ "terminal": true
+ }
+ ],
+ "automatic_https": {
+ "skip": [
+ "localhost"
+ ]
+ },
+ "logs": {
+ "logger_names": {
+ "localhost:8881": "foo"
+ }
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/caddytest/integration/caddyfile_adapt/log_override_name_multiaccess_debug.txt b/caddytest/integration/caddyfile_adapt/log_override_name_multiaccess_debug.txt
new file mode 100644
index 000000000..e6698e4fb
--- /dev/null
+++ b/caddytest/integration/caddyfile_adapt/log_override_name_multiaccess_debug.txt
@@ -0,0 +1,91 @@
+{
+ debug
+
+ log access-console {
+ include http.log.access.foo
+ output file access-localhost.log
+ format console
+ }
+
+ log access-json {
+ include http.log.access.foo
+ output file access-localhost.json
+ format json
+ }
+}
+
+http://localhost:8881 {
+ log foo
+}
+----------
+{
+ "logging": {
+ "logs": {
+ "access-console": {
+ "writer": {
+ "filename": "access-localhost.log",
+ "output": "file"
+ },
+ "encoder": {
+ "format": "console"
+ },
+ "level": "DEBUG",
+ "include": [
+ "http.log.access.foo"
+ ]
+ },
+ "access-json": {
+ "writer": {
+ "filename": "access-localhost.json",
+ "output": "file"
+ },
+ "encoder": {
+ "format": "json"
+ },
+ "level": "DEBUG",
+ "include": [
+ "http.log.access.foo"
+ ]
+ },
+ "default": {
+ "level": "DEBUG",
+ "exclude": [
+ "http.log.access.foo"
+ ]
+ }
+ }
+ },
+ "apps": {
+ "http": {
+ "servers": {
+ "srv0": {
+ "listen": [
+ ":8881"
+ ],
+ "routes": [
+ {
+ "match": [
+ {
+ "host": [
+ "localhost"
+ ]
+ }
+ ],
+ "terminal": true
+ }
+ ],
+ "automatic_https": {
+ "skip": [
+ "localhost"
+ ]
+ },
+ "logs": {
+ "logger_names": {
+ "localhost:8881": "foo"
+ }
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file