trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [01/17] git commit: TS-2302: move predefined logging formats to a separate file
Date Thu, 31 Oct 2013 15:18:20 GMT
Updated Branches:
  refs/heads/master c2452f5fb -> 7845084ea


TS-2302: move predefined logging formats to a separate file


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/1228c650
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/1228c650
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/1228c650

Branch: refs/heads/master
Commit: 1228c6507fabc41d222b46c669b13fecb2e7729f
Parents: e37f749
Author: James Peach <jpeach@apache.org>
Authored: Thu Sep 26 21:02:57 2013 -0700
Committer: James Peach <jpeach@apache.org>
Committed: Thu Oct 31 08:16:27 2013 -0700

----------------------------------------------------------------------
 proxy/logging/LogPredefined.cc | 93 +++++++++++++++++++++++++++++++++++++
 proxy/logging/LogPredefined.h  | 58 +++++++++++++++++++++++
 proxy/logging/Makefile.am      | 14 +++---
 3 files changed, 159 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1228c650/proxy/logging/LogPredefined.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogPredefined.cc b/proxy/logging/LogPredefined.cc
new file mode 100644
index 0000000..3e8569b
--- /dev/null
+++ b/proxy/logging/LogPredefined.cc
@@ -0,0 +1,93 @@
+/** @file
+
+  This file implements predefined log formats
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#include "LogPredefined.h"
+#include "LogObject.h"
+#include "LogConfig.h"
+#include "LogFormat.h"
+
+// predefined formats
+static const char squid_format[] =
+  "%<cqtq> %<ttms> %<chi> %<crc>/%<pssc> %<psql> %<cqhm>
%<cquc> %<caun> %<phr>/%<pqsn> %<psct> %<xid>";
+
+static const char common_format[] = "%<chi> - %<caun> [%<cqtn>] \"%<cqtx>\"
%<pssc> %<pscl>";
+
+static const char extended_format[] =
+  "%<chi> - %<caun> [%<cqtn>] \"%<cqtx>\" %<pssc> %<pscl>
"
+  "%<sssc> %<sscl> %<cqbl> %<pqbl> %<cqhl> %<pshl> %<pqhl>
%<sshl> %<tts>";
+
+static const char extended2_format[] = "%<chi> - %<caun> [%<cqtn>] \"%<cqtx>\"
%<pssc> %<pscl> "
+  "%<sssc> %<sscl> %<cqbl> %<pqbl> %<cqhl> %<pshl> %<pqhl>
%<sshl> %<tts> %<phr> %<cfsc> %<pfsc> %<crc>";
+
+PreDefinedFormatList::PreDefinedFormatList()
+{
+}
+
+PreDefinedFormatList::~PreDefinedFormatList()
+{
+  PreDefinedFormatInfo * info;
+  while (!this->list.empty()) {
+    info = this->list.pop();
+    delete info;
+  }
+}
+
+void
+PreDefinedFormatList::init(LogConfig * config)
+{
+  LogFormat *fmt;
+
+  fmt = NEW(new LogFormat("squid", squid_format));
+  config->global_format_list.add(fmt, false);
+  Debug("log", "squid format added to the global format list");
+
+  if (config->squid_log_enabled) {
+    this->list.enqueue(NEW(new PreDefinedFormatInfo(fmt, config->squid_log_name, config->squid_log_is_ascii,
config->squid_log_header)));
+  }
+
+  fmt = NEW(new LogFormat("common", common_format));
+  config->global_format_list.add(fmt, false);
+  Debug("log", "common format added to the global format list");
+
+  if (config->common_log_enabled) {
+    this->list.enqueue(NEW(new PreDefinedFormatInfo(fmt, config->common_log_name, config->common_log_is_ascii,
config->common_log_header)));
+  }
+
+  fmt = NEW(new LogFormat("extended", extended_format));
+  config->global_format_list.add(fmt, false);
+  Debug("log", "extended format added to the global format list");
+
+  if (config->extended_log_enabled) {
+    this->list.enqueue(NEW(new PreDefinedFormatInfo(fmt, config->extended_log_name,
config->extended_log_is_ascii, config->extended_log_header)));
+  }
+
+  fmt = NEW(new LogFormat("extended2", extended2_format));
+  config->global_format_list.add(fmt, false);
+  Debug("log", "extended2 format added to the global format list");
+
+  if (config->extended2_log_enabled) {
+    this->list.enqueue(NEW(new PreDefinedFormatInfo(fmt, config->extended2_log_name,
config->extended2_log_is_ascii, config->extended2_log_header)));
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1228c650/proxy/logging/LogPredefined.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogPredefined.h b/proxy/logging/LogPredefined.h
new file mode 100644
index 0000000..4a8f52e
--- /dev/null
+++ b/proxy/logging/LogPredefined.h
@@ -0,0 +1,58 @@
+/** @file
+
+  A brief file description
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#ifndef LOG_PREDEFINED_H
+#define LOG_PREDEFINED_H
+
+#include "libts.h"
+
+class LogFormat;
+class LogConfig;
+
+// Collects all the necesary info to build a pre-defined object.
+struct PreDefinedFormatInfo
+{
+  LogFormat *   format;
+  const char *  filename;
+  bool          is_ascii;
+  const char *  header;
+  LINK(PreDefinedFormatInfo, link);
+
+  PreDefinedFormatInfo(LogFormat * fmt, const char * fname, bool ascii, const char * hdr)
+    :format(fmt), filename(fname), is_ascii(ascii), header(hdr)
+  { }
+};
+
+struct PreDefinedFormatList
+{
+  PreDefinedFormatList();
+  ~PreDefinedFormatList();
+
+  // Initialize the predefined format list from the given LogConfig. This has the side-effect
of
+  // adding the predefined LogFormats to the LogConfig global_format_list.
+  void init(LogConfig * config);
+
+  Queue<PreDefinedFormatInfo> list;
+};
+
+#endif /* LOG_PREDEFINED_H */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1228c650/proxy/logging/Makefile.am
----------------------------------------------------------------------
diff --git a/proxy/logging/Makefile.am b/proxy/logging/Makefile.am
index d2f67b0..b56d38e 100644
--- a/proxy/logging/Makefile.am
+++ b/proxy/logging/Makefile.am
@@ -36,6 +36,8 @@ EXTRA_DIST = LogStandalone.cc
 noinst_LIBRARIES = liblogging.a liblogcollation.a
 
 liblogging_a_SOURCES = \
+  Log.cc \
+  Log.h \
   LogAccess.cc \
   LogAccess.h \
   LogAccessHttp.cc \
@@ -45,14 +47,12 @@ liblogging_a_SOURCES = \
   LogBuffer.cc \
   LogBuffer.h \
   LogBufferSink.h \
-  Log.cc \
-  Log.h \
   LogConfig.cc \
   LogConfig.h \
-  LogFieldAliasMap.cc \
-  LogFieldAliasMap.h \
   LogField.cc \
   LogField.h \
+  LogFieldAliasMap.cc \
+  LogFieldAliasMap.h \
   LogFile.cc \
   LogFile.h \
   LogFilter.cc \
@@ -60,13 +60,15 @@ liblogging_a_SOURCES = \
   LogFormat.cc \
   LogFormat.h \
   LogFormatType.h \
+  LogHost.cc \
+  LogHost.h \
   LogLimits.h \
   LogObject.cc \
   LogObject.h \
+  LogPredefined.cc \
+  LogPredefined.h \
   LogSock.cc \
   LogSock.h \
-  LogHost.cc \
-  LogHost.h \
   LogUtils.cc \
   LogUtils.h
 


Mime
View raw message