trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [14/17] git commit: TS-2302: rename log format and file type constants for clarity
Date Thu, 31 Oct 2013 15:18:33 GMT
TS-2302: rename log format and file type constants for clarity


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

Branch: refs/heads/master
Commit: 48b61b338c2410f5c802a79c0562615db89ab2c0
Parents: b95d1e8
Author: James Peach <jpeach@apache.org>
Authored: Fri Sep 27 09:39:26 2013 -0700
Committer: James Peach <jpeach@apache.org>
Committed: Thu Oct 31 08:16:28 2013 -0700

----------------------------------------------------------------------
 proxy/logcat.cc            |  8 ++++----
 proxy/logging/Log.cc       | 12 ++++++------
 proxy/logging/Log.h        |  6 +++---
 proxy/logging/LogBuffer.cc |  4 ++--
 proxy/logging/LogConfig.cc | 10 +++++-----
 proxy/logging/LogFile.cc   | 12 ++++++------
 proxy/logging/LogFile.h    |  4 ++--
 proxy/logging/LogFormat.cc | 18 +++++++++---------
 proxy/logging/LogFormat.h  | 10 +++++-----
 proxy/logging/LogHost.cc   |  2 +-
 proxy/logging/LogObject.cc | 20 ++++++++++----------
 proxy/logging/LogObject.h  |  6 +++---
 12 files changed, 56 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logcat.cc
----------------------------------------------------------------------
diff --git a/proxy/logcat.cc b/proxy/logcat.cc
index e2faea8..4351787 100644
--- a/proxy/logcat.cc
+++ b/proxy/logcat.cc
@@ -283,8 +283,8 @@ main(int /* argc ATS_UNUSED */, char *argv[])
   int error = NO_ERROR;
 
   if (n_file_arguments) {
-    int bin_ext_len = strlen(BINARY_LOG_OBJECT_FILENAME_EXTENSION);
-    int ascii_ext_len = strlen(ASCII_LOG_OBJECT_FILENAME_EXTENSION);
+    int bin_ext_len = strlen(LOG_FILE_BINARY_OBJECT_FILENAME_EXTENSION);
+    int ascii_ext_len = strlen(LOG_FILE_ASCII_OBJECT_FILENAME_EXTENSION);
 
     for (unsigned i = 0; i < n_file_arguments; ++i) {
       int in_fd = open(file_arguments[i], O_RDONLY);
@@ -301,13 +301,13 @@ main(int /* argc ATS_UNUSED */, char *argv[])
           //
           int n = strlen(file_arguments[i]);
           int copy_len = (n >= bin_ext_len ? (strcmp(&file_arguments[i][n - bin_ext_len],
-                                                     BINARY_LOG_OBJECT_FILENAME_EXTENSION)
==
+                                                     LOG_FILE_BINARY_OBJECT_FILENAME_EXTENSION)
==
                                               0 ? n - bin_ext_len : n) : n);
 
           char *out_filename = (char *)ats_malloc(copy_len + ascii_ext_len + 1);
 
           memcpy(out_filename, file_arguments[i], copy_len);
-          memcpy(&out_filename[copy_len], ASCII_LOG_OBJECT_FILENAME_EXTENSION, ascii_ext_len);
+          memcpy(&out_filename[copy_len], LOG_FILE_ASCII_OBJECT_FILENAME_EXTENSION, ascii_ext_len);
           out_filename[copy_len + ascii_ext_len] = 0;
 
           out_fd = open_output_file(out_filename);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logging/Log.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index a263944..a43b0a0 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -1016,7 +1016,7 @@ Log::init_when_enabled()
       NEW(new LogObject(global_scrap_format,
                         Log::config->logfile_dir,
                         "scrapfile.log",
-                        BINARY_LOG, NULL,
+                        LOG_FILE_BINARY, NULL,
                         Log::config->rolling_enabled,
                         Log::config->collation_preproc_threads,
                         Log::config->rolling_interval_sec,
@@ -1277,7 +1277,7 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */)
       bytes_written = 0;
       logfile = fdata->m_logfile;
 
-      if (logfile->m_file_format == BINARY_LOG) {
+      if (logfile->m_file_format == LOG_FILE_BINARY) {
 
         logbuffer = (LogBuffer *)fdata->m_data;
         LogBufferHeader *buffer_header = logbuffer->header();
@@ -1285,8 +1285,8 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */)
         buf = (char *)buffer_header;
         total_bytes = buffer_header->byte_count;
 
-      } else if (logfile->m_file_format == ASCII_LOG
-                 || logfile->m_file_format == ASCII_PIPE){
+      } else if (logfile->m_file_format == LOG_FILE_ASCII
+                 || logfile->m_file_format == LOG_FILE_PIPE){
 
         buf = (char *)fdata->m_data;
         total_bytes = fdata->m_len;
@@ -1505,8 +1505,8 @@ Log::match_logobject(LogBufferHeader * header)
     LogFormat *fmt = NEW(new LogFormat("__collation_format__", header->fmt_fieldlist(),
header->fmt_printf()));
 
     if (fmt->valid()) {
-      LogFileFormat file_format = header->log_object_flags & LogObject::BINARY ? BINARY_LOG
:
-        (header->log_object_flags & LogObject::WRITES_TO_PIPE ? ASCII_PIPE : ASCII_LOG);
+      LogFileFormat file_format = header->log_object_flags & LogObject::BINARY ? LOG_FILE_BINARY
:
+        (header->log_object_flags & LogObject::WRITES_TO_PIPE ? LOG_FILE_PIPE : LOG_FILE_ASCII);
 
       obj = NEW(new LogObject(fmt, Log::config->logfile_dir,
                               header->log_filename(), file_format, NULL,

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logging/Log.h
----------------------------------------------------------------------
diff --git a/proxy/logging/Log.h b/proxy/logging/Log.h
index 8f2292f..883567f 100644
--- a/proxy/logging/Log.h
+++ b/proxy/logging/Log.h
@@ -329,12 +329,12 @@ public:
   ~LogFlushData()
   {
     switch (m_logfile->m_file_format) {
-    case BINARY_LOG:
+    case LOG_FILE_BINARY:
       logbuffer = (LogBuffer *)m_data;
       LogBuffer::destroy(logbuffer);
       break;
-    case ASCII_LOG:
-    case ASCII_PIPE:
+    case LOG_FILE_ASCII:
+    case LOG_FILE_PIPE:
       free(m_data);
       break;
     case N_LOGFILE_TYPES:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logging/LogBuffer.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogBuffer.cc b/proxy/logging/LogBuffer.cc
index 45452ee..d110bd2 100644
--- a/proxy/logging/LogBuffer.cc
+++ b/proxy/logging/LogBuffer.cc
@@ -629,7 +629,7 @@ LogBuffer::to_ascii(LogEntryHeader * entry, LogFormatType type,
                     unsigned buffer_version, const char *alt_format)
 {
   ink_assert(entry != NULL);
-  ink_assert(type == CUSTOM_LOG || type == TEXT_LOG);
+  ink_assert(type == LOG_FORMAT_CUSTOM || type == LOG_FORMAT_TEXT);
   ink_assert(buf != NULL);
 
   char *read_from;              // keeps track of where we're reading from entry
@@ -638,7 +638,7 @@ LogBuffer::to_ascii(LogEntryHeader * entry, LogFormatType type,
   read_from = (char *) entry + sizeof(LogEntryHeader);
   write_to = buf;
 
-  if (type == TEXT_LOG) {
+  if (type == LOG_FORMAT_TEXT) {
     //
     // text log entries are just strings, so simply move it into the
     // format buffer.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logging/LogConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogConfig.cc b/proxy/logging/LogConfig.cc
index 02c254c..44a2d6c 100644
--- a/proxy/logging/LogConfig.cc
+++ b/proxy/logging/LogConfig.cc
@@ -839,14 +839,14 @@ LogConfig::create_pre_defined_objects_with_filter(const PreDefinedFormatList
& p
     if (force_extension) {
       ink_string_append(obj_filt_fname,
                         (char *) (pdi->is_ascii ?
-                                  ASCII_LOG_OBJECT_FILENAME_EXTENSION :
-                                  BINARY_LOG_OBJECT_FILENAME_EXTENSION), PATH_NAME_MAX);
+                                  LOG_FILE_ASCII_OBJECT_FILENAME_EXTENSION :
+                                  LOG_FILE_BINARY_OBJECT_FILENAME_EXTENSION), PATH_NAME_MAX);
     }
     // create object with filters
     //
     LogObject *obj;
     obj = NEW(new LogObject(pdi->format, logfile_dir, obj_fname,
-                            pdi->is_ascii ? ASCII_LOG : BINARY_LOG,
+                            pdi->is_ascii ? LOG_FILE_ASCII : LOG_FILE_BINARY,
                             pdi->header, rolling_enabled,
                             collation_preproc_threads, rolling_interval_sec,
                             rolling_offset_hr, rolling_size_mb));
@@ -2061,12 +2061,12 @@ LogConfig::read_xml_log_config(int from_memory)
       }
       // file format
       //
-      LogFileFormat file_type = ASCII_LOG;      // default value
+      LogFileFormat file_type = LOG_FILE_ASCII;      // default value
       if (mode.count()) {
         char *mode_str = mode.dequeue();
         file_type = (strncasecmp(mode_str, "bin", 3) == 0 ||
                      (mode_str[0] == 'b' && mode_str[1] == 0) ?
-                     BINARY_LOG : (strcasecmp(mode_str, "ascii_pipe") == 0 ? ASCII_PIPE :
ASCII_LOG));
+                     LOG_FILE_BINARY : (strcasecmp(mode_str, "ascii_pipe") == 0 ? LOG_FILE_PIPE
: LOG_FILE_ASCII));
       }
       // rolling
       //

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logging/LogFile.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogFile.cc b/proxy/logging/LogFile.cc
index 13083a9..501cf29 100644
--- a/proxy/logging/LogFile.cc
+++ b/proxy/logging/LogFile.cc
@@ -219,7 +219,7 @@ LogFile::open_file()
 
   int flags, perms;
 
-  if (m_file_format == ASCII_PIPE) {
+  if (m_file_format == LOG_FILE_PIPE) {
     if (mkfifo(m_name, S_IRUSR | S_IWUSR) < 0) {
       if (errno != EEXIST) {
         Error("Could not create named pipe %s for logging: %s", m_name, strerror(errno));
@@ -268,7 +268,7 @@ LogFile::open_file()
   // file.
   //
   if (!file_exists) {
-    if (m_file_format != BINARY_LOG && m_header != NULL) {
+    if (m_file_format != LOG_FILE_BINARY && m_header != NULL) {
       Debug("log-file", "writing header to LogFile %s", m_name);
       writeln(m_header, strlen(m_header), m_fd, m_name);
     }
@@ -501,7 +501,7 @@ LogFile::preproc_and_try_delete(LogBuffer * lb)
     m_start_time = buffer_header->low_timestamp;
   m_end_time = buffer_header->high_timestamp;
 
-  if (m_file_format == BINARY_LOG) {
+  if (m_file_format == LOG_FILE_BINARY) {
     //
     // Ok, now we need to write the binary buffer to the file, and we
     // can do so in one swift write.  The question is, do we write the
@@ -529,7 +529,7 @@ LogFile::preproc_and_try_delete(LogBuffer * lb)
     //
     return 0;
   }
-  else if (m_file_format == ASCII_LOG || m_file_format == ASCII_PIPE) {
+  else if (m_file_format == LOG_FILE_ASCII || m_file_format == LOG_FILE_PIPE) {
     write_ascii_logbuffer3(buffer_header);
     ret = 0;
   }
@@ -652,7 +652,7 @@ LogFile::write_ascii_logbuffer3(LogBufferHeader * buffer_header, const
char *alt
     fmt_entry_count = 0;
     fmt_buf_bytes = 0;
 
-    if (m_file_format == ASCII_PIPE)
+    if (m_file_format == LOG_FILE_PIPE)
       ascii_buffer = (char *)malloc(m_max_line_size);
     else
       ascii_buffer = (char *)malloc(m_ascii_buffer_size);
@@ -693,7 +693,7 @@ LogFile::write_ascii_logbuffer3(LogBufferHeader * buffer_header, const
char *alt
       // record to avoid as much as possible overflowing the
       // pipe buffer
       //
-      if (m_file_format == ASCII_PIPE)
+      if (m_file_format == LOG_FILE_PIPE)
         break;
 
       if (m_ascii_buffer_size - fmt_buf_bytes < m_max_line_size)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logging/LogFile.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogFile.h b/proxy/logging/LogFile.h
index 68a334b..fa33f6d 100644
--- a/proxy/logging/LogFile.h
+++ b/proxy/logging/LogFile.h
@@ -151,7 +151,7 @@ public:
 
   LogFileFormat get_format() const { return m_file_format; }
   const char *get_format_name() const {
-    return (m_file_format == BINARY_LOG ? "binary" : (m_file_format == ASCII_PIPE ? "ascii_pipe"
: "ascii"));
+    return (m_file_format == LOG_FILE_BINARY ? "binary" : (m_file_format == LOG_FILE_PIPE
? "ascii_pipe" : "ascii"));
   }
 
   static int write_ascii_logbuffer(LogBufferHeader * buffer_header, int fd, const char *path,
const char *alt_format = NULL);
@@ -162,7 +162,7 @@ public:
   void display(FILE * fd = stdout);
   int open_file();
 
-  off_t get_size_bytes() const { return m_file_format != ASCII_PIPE? m_bytes_written : 0;
};
+  off_t get_size_bytes() const { return m_file_format != LOG_FILE_PIPE? m_bytes_written :
0; };
   int do_filesystem_checks() { return 0; }; // TODO: this need to be tidy up when to redo
the file checking
 
 public:

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logging/LogFormat.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogFormat.cc b/proxy/logging/LogFormat.cc
index eab34ee..753779f 100644
--- a/proxy/logging/LogFormat.cc
+++ b/proxy/logging/LogFormat.cc
@@ -196,9 +196,9 @@ LogFormat::LogFormat(const char *name, const char *format_str, unsigned
interval
 {
   setup(name, format_str, interval_sec);
 
-  // A TEXT_LOG is a log without a format string, everything else is a CUSTOM_LOG. It's possible
that we could get
-  // rid of log types altogether, but LogFile currently tests whether a format is a TEXT_LOG
format ...
-  m_format_type = format_str ? CUSTOM_LOG : TEXT_LOG;
+  // A LOG_FORMAT_TEXT is a log without a format string, everything else is a LOG_FORMAT_CUSTOM.
It's possible that we could get
+  // rid of log types altogether, but LogFile currently tests whether a format is a LOG_FORMAT_TEXT
format ...
+  m_format_type = format_str ? LOG_FORMAT_CUSTOM : LOG_FORMAT_TEXT;
 }
 
 //-----------------------------------------------------------------------------
@@ -224,7 +224,7 @@ LogFormat::LogFormat(const char *name, const char *fieldlist_str, const
char *pr
     m_format_str(NULL)
 {
   init_variables(name, fieldlist_str, printf_str, interval_sec);
-  m_format_type = CUSTOM_LOG;
+  m_format_type = LOG_FORMAT_CUSTOM;
 }
 
 /*-------------------------------------------------------------------------
@@ -249,7 +249,7 @@ LogFormat::LogFormat(const LogFormat & rhs)
     m_format_type(rhs.m_format_type)
 {
   if (m_valid) {
-    if (m_format_type == TEXT_LOG) {
+    if (m_format_type == LOG_FORMAT_TEXT) {
       m_name_str = ats_strdup(rhs.m_name_str);
     } else {
       m_format_str = rhs.m_format_str ? ats_strdup(rhs.m_format_str) : 0;
@@ -387,9 +387,9 @@ LogFormat::format_from_specification(char *spec, char **file_name, char
**file_h
     return NULL;
   }
   if (!strcasecmp(token, "ASCII")) {
-    *file_type = ASCII_LOG;
+    *file_type = LOG_FILE_ASCII;
   } else if (!strcasecmp(token, "BINARY")) {
-    *file_type = BINARY_LOG;
+    *file_type = LOG_FILE_BINARY;
   } else {
     Debug("log-format", "%s is not a valid file format (ASCII or BINARY)", token);
     return NULL;
@@ -654,8 +654,8 @@ LogFormat::display(FILE * fd)
     "COMMON_LOG",
     "EXTENDED_LOG",
     "EXTENDED2_LOG",
-    "CUSTOM_LOG",
-    "TEXT_LOG"
+    "LOG_FORMAT_CUSTOM",
+    "LOG_FORMAT_TEXT"
   };
 
   fprintf(fd, "--------------------------------------------------------\n");

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logging/LogFormat.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogFormat.h b/proxy/logging/LogFormat.h
index b632b42..da32018 100644
--- a/proxy/logging/LogFormat.h
+++ b/proxy/logging/LogFormat.h
@@ -34,15 +34,15 @@ enum LogFormatType
 {
   // We start the numbering at 4 to compatibility with Traffic Server 4.x, which used
   // to have the predefined log formats enumerated above ...
-  CUSTOM_LOG = 4,
-  TEXT_LOG = 5
+  LOG_FORMAT_CUSTOM = 4,
+  LOG_FORMAT_TEXT = 5
 };
 
 enum LogFileFormat
 {
-  BINARY_LOG,
-  ASCII_LOG,
-  ASCII_PIPE,
+  LOG_FILE_BINARY,
+  LOG_FILE_ASCII,
+  LOG_FILE_PIPE, // ie. ASCII pipe
   N_LOGFILE_TYPES
 };
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logging/LogHost.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogHost.cc b/proxy/logging/LogHost.cc
index 3fd8c87..a448340 100644
--- a/proxy/logging/LogHost.cc
+++ b/proxy/logging/LogHost.cc
@@ -241,7 +241,7 @@ LogHost::create_orphan_LogFile_object()
 
   // should check for conflicts with orphan filename
   //
-  m_orphan_file = NEW(new LogFile(name_buf, NULL, ASCII_LOG, m_object_signature));
+  m_orphan_file = NEW(new LogFile(name_buf, NULL, LOG_FILE_ASCII, m_object_signature));
   ink_assert(m_orphan_file != NULL);
   ats_free(name_buf);
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logging/LogObject.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogObject.cc b/proxy/logging/LogObject.cc
index d2b09b1..eb773b9 100644
--- a/proxy/logging/LogObject.cc
+++ b/proxy/logging/LogObject.cc
@@ -97,9 +97,9 @@ LogObject::LogObject(LogFormat *format, const char *log_dir,
     m_format = new LogFormat(*format);
     m_buffer_manager = new LogBufferManager[m_flush_threads];
 
-    if (file_format == BINARY_LOG) {
+    if (file_format == LOG_FILE_BINARY) {
         m_flags |= BINARY;
-    } else if (file_format == ASCII_PIPE) {
+    } else if (file_format == LOG_FILE_PIPE) {
         m_flags |= WRITES_TO_PIPE;
     }
 
@@ -226,16 +226,16 @@ LogObject::generate_filenames(const char *log_dir, const char *basename,
LogFile
   int ext_len = 0;
   if (i < 0) {                  // no extension, add one
     switch (file_format) {
-    case ASCII_LOG:
-      ext = ASCII_LOG_OBJECT_FILENAME_EXTENSION;
+    case LOG_FILE_ASCII:
+      ext = LOG_FILE_ASCII_OBJECT_FILENAME_EXTENSION;
       ext_len = 4;
       break;
-    case BINARY_LOG:
-      ext = BINARY_LOG_OBJECT_FILENAME_EXTENSION;
+    case LOG_FILE_BINARY:
+      ext = LOG_FILE_BINARY_OBJECT_FILENAME_EXTENSION;
       ext_len = 5;
       break;
-    case ASCII_PIPE:
-      ext = ASCII_PIPE_OBJECT_FILENAME_EXTENSION;
+    case LOG_FILE_PIPE:
+      ext = LOG_FILE_PIPE_OBJECT_FILENAME_EXTENSION;
       ext_len = 5;
       break;
     default:
@@ -831,7 +831,7 @@ TextLogObject::TextLogObject(const char *name, const char *log_dir,
                              int rolling_enabled, int flush_threads,
                              int rolling_interval_sec, int rolling_offset_hr,
                              int rolling_size_mb)
-  : LogObject(MakeTextLogFormat(), log_dir, name, ASCII_LOG, header,
+  : LogObject(MakeTextLogFormat(), log_dir, name, LOG_FILE_ASCII, header,
               rolling_enabled, flush_threads, rolling_interval_sec,
               rolling_offset_hr, rolling_size_mb)
 {
@@ -1064,7 +1064,7 @@ LogObjectManager::_solve_filename_conflicts(LogObject * log_object,
int maxConfl
         if (roll_file) {
           Warning("File %s will be rolled because a LogObject with "
                   "different format is requesting the same " "filename", filename);
-          LogFile logfile(filename, NULL, ASCII_LOG, 0);
+          LogFile logfile(filename, NULL, LOG_FILE_ASCII, 0);
           long time_now = LogUtils::timestamp();
 
           if (logfile.roll(time_now - log_object->get_rolling_interval(), time_now) ==
0) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/48b61b33/proxy/logging/LogObject.h
----------------------------------------------------------------------
diff --git a/proxy/logging/LogObject.h b/proxy/logging/LogObject.h
index 72037f2..d8dab73 100644
--- a/proxy/logging/LogObject.h
+++ b/proxy/logging/LogObject.h
@@ -48,9 +48,9 @@
   consist of a list of LogObjects.
   -------------------------------------------------------------------------*/
 
-#define ASCII_LOG_OBJECT_FILENAME_EXTENSION ".log"
-#define BINARY_LOG_OBJECT_FILENAME_EXTENSION ".blog"
-#define ASCII_PIPE_OBJECT_FILENAME_EXTENSION ".pipe"
+#define LOG_FILE_ASCII_OBJECT_FILENAME_EXTENSION ".log"
+#define LOG_FILE_BINARY_OBJECT_FILENAME_EXTENSION ".blog"
+#define LOG_FILE_PIPE_OBJECT_FILENAME_EXTENSION ".pipe"
 
 #define FLUSH_ARRAY_SIZE (512*4)
 


Mime
View raw message