• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

LogPredefined.cc

Go to the documentation of this file.
00001 /** @file
00002 
00003   This file implements predefined log formats
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #include "LogObject.h"
00025 #include "LogConfig.h"
00026 #include "LogFormat.h"
00027 #include "LogPredefined.h"
00028 
00029 // predefined formats
00030 const char * const PreDefinedFormatInfo::squid =
00031   "%<cqtq> %<ttms> %<chi> %<crc>/%<pssc> %<psql> %<cqhm> %<cquc> %<caun> %<phr>/%<pqsn> %<psct>";
00032 
00033 const char * const PreDefinedFormatInfo::common =
00034   "%<chi> - %<caun> [%<cqtn>] \"%<cqtx>\" %<pssc> %<pscl>";
00035 
00036 const char * const PreDefinedFormatInfo::extended =
00037   "%<chi> - %<caun> [%<cqtn>] \"%<cqtx>\" %<pssc> %<pscl> "
00038   "%<sssc> %<sscl> %<cqbl> %<pqbl> %<cqhl> %<pshl> %<pqhl> %<sshl> %<tts>";
00039 
00040 const char * const PreDefinedFormatInfo::extended2 =
00041   "%<chi> - %<caun> [%<cqtn>] \"%<cqtx>\" %<pssc> %<pscl> "
00042   "%<sssc> %<sscl> %<cqbl> %<pqbl> %<cqhl> %<pshl> %<pqhl> %<sshl> %<tts> %<phr> %<cfsc> %<pfsc> %<crc>";
00043 
00044 PreDefinedFormatInfo *
00045 MakePredefinedErrorLog(LogConfig * config)
00046 {
00047   LogFormat * fmt;
00048 
00049   fmt = MakeTextLogFormat("error");
00050   config->global_format_list.add(fmt, false);
00051 
00052   // The error log is always ASCII, and currently does not work correctly with log collation.
00053   return new PreDefinedFormatInfo(fmt, "error.log", NULL /* no log header */, LOG_FILE_ASCII, false);
00054 }
00055 
00056 PreDefinedFormatList::PreDefinedFormatList()
00057 {
00058 }
00059 
00060 PreDefinedFormatList::~PreDefinedFormatList()
00061 {
00062   PreDefinedFormatInfo * info;
00063   while (!this->formats.empty()) {
00064     info = this->formats.pop();
00065     delete info;
00066   }
00067 }
00068 
00069 void
00070 PreDefinedFormatList::init(LogConfig * config)
00071 {
00072   LogFormat * fmt;
00073 
00074   // All these predefined formats work with log collation. They are optionally binary or ASCII, each
00075   // with a different config option.
00076 #define make_format(is_ascii)  ((is_ascii) ? LOG_FILE_ASCII : LOG_FILE_BINARY )
00077 
00078   fmt = new LogFormat("squid", PreDefinedFormatInfo::squid);
00079   config->global_format_list.add(fmt, false);
00080   Debug("log", "squid format added to the global format list");
00081 
00082   if (config->squid_log_enabled) {
00083     this->formats.enqueue(new PreDefinedFormatInfo(fmt, config->squid_log_name, config->squid_log_header, make_format(config->squid_log_is_ascii), true));
00084   }
00085 
00086   fmt = new LogFormat("common", PreDefinedFormatInfo::common);
00087   config->global_format_list.add(fmt, false);
00088   Debug("log", "common format added to the global format list");
00089 
00090   if (config->common_log_enabled) {
00091     this->formats.enqueue(new PreDefinedFormatInfo(fmt, config->common_log_name, config->common_log_header, make_format(config->common_log_is_ascii), true));
00092   }
00093 
00094   fmt = new LogFormat("extended", PreDefinedFormatInfo::extended);
00095   config->global_format_list.add(fmt, false);
00096   Debug("log", "extended format added to the global format list");
00097 
00098   if (config->extended_log_enabled) {
00099     this->formats.enqueue(new PreDefinedFormatInfo(fmt, config->extended_log_name, config->extended_log_header, make_format(config->extended_log_is_ascii), true));
00100   }
00101 
00102   fmt = new LogFormat("extended2", PreDefinedFormatInfo::extended2);
00103   config->global_format_list.add(fmt, false);
00104   Debug("log", "extended2 format added to the global format list");
00105 
00106   if (config->extended2_log_enabled) {
00107     this->formats.enqueue(new PreDefinedFormatInfo(fmt, config->extended2_log_name, config->extended2_log_header, make_format(config->extended2_log_is_ascii), true));
00108   }
00109 
00110 #undef make_format
00111 }
00112 

Generated by  doxygen 1.7.1