< prev index next >

src/share/vm/logging/logFileOutput.hpp

Print this page




  23  */
  24 #ifndef SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP
  25 #define SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP
  26 
  27 #include "logging/logFileStreamOutput.hpp"
  28 #include "runtime/semaphore.hpp"
  29 #include "utilities/globalDefinitions.hpp"
  30 
  31 class LogDecorations;
  32 
  33 // The log file output, with support for file rotation based on a target size.
  34 class LogFileOutput : public LogFileStreamOutput {
  35  private:
  36   static const char*  FileOpenMode;
  37   static const char*  FileCountOptionKey;
  38   static const char*  FileSizeOptionKey;
  39   static const char*  PidFilenamePlaceholder;
  40   static const char*  TimestampFilenamePlaceholder;
  41   static const char*  TimestampFormat;
  42   static const size_t DefaultFileCount = 5;
  43   static const size_t DefaultFileSize = 20 * M;
  44   static const size_t StartTimeBufferSize = 20;
  45   static const size_t PidBufferSize = 21;
  46   static const uint   MaxRotationFileCount = 1000;
  47   static char         _pid_str[PidBufferSize];
  48   static char         _vm_start_time_str[StartTimeBufferSize];
  49 
  50   const char* _name;
  51   char* _file_name;
  52   char* _archive_name;
  53 
  54   uint  _current_file;
  55   uint  _file_count;
  56   uint  _file_count_max_digits;
  57 
  58   size_t  _archive_name_len;
  59   size_t  _rotate_size;
  60   size_t  _current_size;
  61 
  62   // Semaphore used for synchronizing file rotations and writes
  63   Semaphore _rotation_semaphore;
  64 
  65   void archive();
  66   void rotate();
  67   bool parse_options(const char* options, outputStream* errstream);
  68   char *make_file_name(const char* file_name, const char* pid_string, const char* timestamp_string);
  69 
  70   bool should_rotate() {
  71     return _file_count > 0 && _rotate_size > 0 && _current_size >= _rotate_size;
  72   }
  73 
  74   void increment_file_count() {
  75     _current_file++;
  76     if (_current_file == _file_count) {
  77       _current_file = 0;
  78     }
  79   }
  80 


  23  */
  24 #ifndef SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP
  25 #define SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP
  26 
  27 #include "logging/logFileStreamOutput.hpp"
  28 #include "runtime/semaphore.hpp"
  29 #include "utilities/globalDefinitions.hpp"
  30 
  31 class LogDecorations;
  32 
  33 // The log file output, with support for file rotation based on a target size.
  34 class LogFileOutput : public LogFileStreamOutput {
  35  private:
  36   static const char*  FileOpenMode;
  37   static const char*  FileCountOptionKey;
  38   static const char*  FileSizeOptionKey;
  39   static const char*  PidFilenamePlaceholder;
  40   static const char*  TimestampFilenamePlaceholder;
  41   static const char*  TimestampFormat;
  42   static const size_t DefaultFileCount = 5;
  43   static const julong DefaultFileSize = 20 * M;
  44   static const size_t StartTimeBufferSize = 20;
  45   static const size_t PidBufferSize = 21;
  46   static const uint   MaxRotationFileCount = 1000;
  47   static char         _pid_str[PidBufferSize];
  48   static char         _vm_start_time_str[StartTimeBufferSize];
  49 
  50   const char* _name;
  51   char* _file_name;
  52   char* _archive_name;
  53 
  54   uint  _current_file;
  55   uint  _file_count;
  56   uint  _file_count_max_digits;
  57 
  58   size_t  _archive_name_len;
  59   julong  _rotate_size;
  60   julong  _current_size;
  61 
  62   // Semaphore used for synchronizing file rotations and writes
  63   Semaphore _rotation_semaphore;
  64 
  65   void archive();
  66   void rotate();
  67   bool parse_options(const char* options, outputStream* errstream);
  68   char *make_file_name(const char* file_name, const char* pid_string, const char* timestamp_string);
  69 
  70   bool should_rotate() {
  71     return _file_count > 0 && _rotate_size > 0 && _current_size >= _rotate_size;
  72   }
  73 
  74   void increment_file_count() {
  75     _current_file++;
  76     if (_current_file == _file_count) {
  77       _current_file = 0;
  78     }
  79   }
  80 
< prev index next >