This is an automated email from the ASF dual-hosted git repository.

rrm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 25ec31c  Move logging config under toplevel YAML tag 'logging'
25ec31c is described below

commit 25ec31ce829cd6c5c408708aeea6f08871c5bee2
Author: Randall Meyer <[email protected]>
AuthorDate: Fri May 17 10:36:21 2019 -0700

    Move logging config under toplevel YAML tag 'logging'
    
    This is for the work in issue #5245
---
 configs/logging.yaml.default                 |  1 +
 doc/admin-guide/logging/examples.en.rst      | 27 ++++++++++++++-------------
 proxy/logging/YamlLogConfig.cc               |  7 +++++++
 tests/gold_tests/h2/httpbin.test.py          | 17 +++++++++--------
 tests/gold_tests/logging/all_headers.test.py | 13 +++++++------
 tests/gold_tests/logging/ccid_ctid.test.py   | 13 +++++++------
 tests/gold_tests/logging/custom-log.test.py  | 13 +++++++------
 tests/gold_tests/logging/log-field.test.py   | 14 +++++++-------
 tests/gold_tests/tls/tls_keepalive.test.py   | 20 ++++++++++++--------
 9 files changed, 71 insertions(+), 54 deletions(-)

diff --git a/configs/logging.yaml.default b/configs/logging.yaml.default
index da116d6..2d6da55 100644
--- a/configs/logging.yaml.default
+++ b/configs/logging.yaml.default
@@ -11,6 +11,7 @@
 
 
 formats:
+  logging:
     # WebTrends Enhanced Log Format.
     #
     # The following is compatible with the WebTrends Enhanced Log Format.
diff --git a/doc/admin-guide/logging/examples.en.rst 
b/doc/admin-guide/logging/examples.en.rst
index df4d957..59234f8 100644
--- a/doc/admin-guide/logging/examples.en.rst
+++ b/doc/admin-guide/logging/examples.en.rst
@@ -310,18 +310,19 @@ the request to clients during that hour.
 
 .. code:: yaml
 
-   formats:
-   - name: originrepformat
-     format: '%<FIRST(cqtq)> %<COUNT(*)> %<AVERAGE(ttms)>'
-     interval: 3600
-
-   filters:
-   - name: originfilter
-     reject: crc CONTAINS "HIT"
+   logging:
+     formats:
+     - name: originrepformat
+       format: '%<FIRST(cqtq)> %<COUNT(*)> %<AVERAGE(ttms)>'
+       interval: 3600
 
-   logs:
-   - mode: ascii
-     format: originrepformat
      filters:
-     - originfilter
-     filename: origin_access_summary
+     - name: originfilter
+       reject: crc CONTAINS "HIT"
+
+     logs:
+     - mode: ascii
+       format: originrepformat
+       filters:
+       - originfilter
+       filename: origin_access_summary
diff --git a/proxy/logging/YamlLogConfig.cc b/proxy/logging/YamlLogConfig.cc
index aecb9d3..2db694b 100644
--- a/proxy/logging/YamlLogConfig.cc
+++ b/proxy/logging/YamlLogConfig.cc
@@ -58,6 +58,13 @@ YamlLogConfig::loadLogConfig(const char *cfgFilename)
     return false;
   }
 
+  if (config["logging"]) {
+    config = config["logging"];
+  } else {
+    Error("malformed logging.yaml file; expected a toplevel 'logging' node");
+    return false;
+  }
+
   auto formats = config["formats"];
   for (auto const &node : formats) {
     auto fmt = node.as<std::unique_ptr<LogFormat>>().release();
diff --git a/tests/gold_tests/h2/httpbin.test.py 
b/tests/gold_tests/h2/httpbin.test.py
index 467c2d3..ed3b52d 100644
--- a/tests/gold_tests/h2/httpbin.test.py
+++ b/tests/gold_tests/h2/httpbin.test.py
@@ -66,16 +66,17 @@ ts.Disk.records_config.update({
 })
 ts.Disk.logging_yaml.AddLines(
     '''
-formats:
-  # Extended Log Format.
-  - name: access
-    format: |-
+logging:
+  formats:
+    # Extended Log Format.
+    - name: access
+      format: |-
 [%<cqtn>] %<cqtx> %<cqpv> %<cqssv> %<cqssc> %<crc> %<pssc> %<pscl>
 
-logs:
-  - filename: access
-    format: access
-}
+  logs:
+    - filename: access
+      format: access
+  }
 '''.split("\n")
 )
 
diff --git a/tests/gold_tests/logging/all_headers.test.py 
b/tests/gold_tests/logging/all_headers.test.py
index e16f6e8..6ae73d7 100644
--- a/tests/gold_tests/logging/all_headers.test.py
+++ b/tests/gold_tests/logging/all_headers.test.py
@@ -52,12 +52,13 @@ ts.Disk.remap_config.AddLine(
 #
 ts.Disk.logging_yaml.AddLines(
     '''
-formats:
-  - name: custom
-    format: "%<cqah> ___FS___ %<pssc> ___FS___ %<psah> ___FS___ %<ssah> 
___FS___ %<pqah> ___FS___ %<cssah> ___FS___ END_TXN"
-logs:
-  - filename: test_all_headers
-    format: custom
+logging:
+  formats:
+    - name: custom
+      format: "%<cqah> ___FS___ %<pssc> ___FS___ %<psah> ___FS___ %<ssah> 
___FS___ %<pqah> ___FS___ %<cssah> ___FS___ END_TXN"
+  logs:
+    - filename: test_all_headers
+      format: custom
 '''.split("\n")
 )
 
diff --git a/tests/gold_tests/logging/ccid_ctid.test.py 
b/tests/gold_tests/logging/ccid_ctid.test.py
index 90826fe..16d60f1 100644
--- a/tests/gold_tests/logging/ccid_ctid.test.py
+++ b/tests/gold_tests/logging/ccid_ctid.test.py
@@ -56,12 +56,13 @@ ts.Disk.ssl_multicert_config.AddLine(
 
 ts.Disk.logging_yaml.AddLines(
     '''
-formats:
-  - name: custom
-    format: "%<ccid> %<ctid>"
-logs:
-  - filename: test_ccid_ctid
-    format: custom
+logging:
+  formats:
+    - name: custom
+      format: "%<ccid> %<ctid>"
+  logs:
+    - filename: test_ccid_ctid
+      format: custom
 '''.split("\n")
 )
 
diff --git a/tests/gold_tests/logging/custom-log.test.py 
b/tests/gold_tests/logging/custom-log.test.py
index 1c09a03..6dd132b 100644
--- a/tests/gold_tests/logging/custom-log.test.py
+++ b/tests/gold_tests/logging/custom-log.test.py
@@ -36,12 +36,13 @@ ts.Disk.remap_config.AddLine(
 
 ts.Disk.logging_yaml.AddLines(
     '''
-formats:
-  - name: custom
-    format: "%<hii> %<hiih>"
-logs:
-  - filename: test_log_field
-    format: custom
+logging:
+  formats:
+    - name: custom
+      format: "%<hii> %<hiih>"
+  logs:
+    - filename: test_log_field
+      format: custom
 '''.split("\n")
 )
 
diff --git a/tests/gold_tests/logging/log-field.test.py 
b/tests/gold_tests/logging/log-field.test.py
index 34b882b..b9997c7 100644
--- a/tests/gold_tests/logging/log-field.test.py
+++ b/tests/gold_tests/logging/log-field.test.py
@@ -55,13 +55,13 @@ ts.Disk.remap_config.AddLine(
 
 ts.Disk.logging_yaml.AddLines(
     '''
-formats:
-  - name: custom
-    format: '%<{Content-Type}essh>'
-
-logs:
-  - filename: field-test
-    format: custom
+logging:
+  formats:
+    - name: custom
+      format: '%<{Content-Type}essh>'
+  logs:
+    - filename: field-test
+      format: custom
 '''.split("\n")
 )
 
diff --git a/tests/gold_tests/tls/tls_keepalive.test.py 
b/tests/gold_tests/tls/tls_keepalive.test.py
index 5a78502..0d92411 100644
--- a/tests/gold_tests/tls/tls_keepalive.test.py
+++ b/tests/gold_tests/tls/tls_keepalive.test.py
@@ -58,14 +58,18 @@ ts.Disk.remap_config.AddLine(
     'map https://example.com:4443 
http://127.0.0.1:{0}'.format(server.Variables.Port)
 )
 
-ts.Disk.logging_yaml.AddLines([
-    'formats:',
-    '- name: testformat',
-    "  format: '%<cqssl> %<cqtr>'",
-    "logs:",
-    "- mode: ascii",
-    "  format: testformat",
-    "  filename: squid" ])
+ts.Disk.logging_yaml.AddLines(
+'''
+logging:
+  formats:
+    - name: testformat
+      format: '%<cqssl> %<cqtr>'
+  logs:
+    - mode: ascii
+      format: testformat
+      filename: squid
+'''.split("\n")
+)
 
 Test.PreparePlugin(os.path.join(Test.Variables.AtsTestToolsDir, 'plugins', 
'ssl_hook_test.cc'), ts, '-preaccept=1')
 

Reply via email to