< prev index next >

src/share/vm/logging/logFileOutput.hpp

Print this page
rev 8933 : 8046148.01


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 #ifndef SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP
  25 #define SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP

  26 #include "logging/logFileStreamOutput.hpp"
  27 #include "utilities/globalDefinitions.hpp"
  28 #include "runtime/mutex.hpp"

  29 
  30 class LogDecorations;
  31 
  32 // The log file output, with support for file rotation based on a target size.
  33 class LogFileOutput : public LogFileStreamOutput {
  34  private:
  35   static const char*  FileOpenMode;
  36   static const char*  FileCountOptionKey;
  37   static const char*  FileSizeOptionKey;
  38   static const char*  PidFilenamePlaceholder;
  39   static const char*  TimestampFilenamePlaceholder;
  40   static const char*  TimestampFormat;
  41   static const size_t StartTimeBufferSize = 20;
  42   static const size_t PidBufferSize       = 21;
  43   static char         _pid_str[PidBufferSize];
  44   static char         _vm_start_time_str[StartTimeBufferSize];
  45 
  46   Mutex _rotation_lock;
  47   const char* _name;
  48   char* _file_name;


  61   bool configure_rotation(const char* options);
  62   char *make_file_name(const char* file_name, const char* pid_string, const char* timestamp_string);
  63   static size_t parse_value(const char* value_str);
  64 
  65   bool should_rotate() const {
  66     return _file_count > 0 && _rotate_size > 0 && _current_size >= _rotate_size;
  67   }
  68 
  69  public:
  70   LogFileOutput(const char *name);
  71   virtual ~LogFileOutput();
  72   virtual bool initialize(const char* options);
  73   virtual int write(const LogDecorations& decorations, const char* msg);
  74 
  75   virtual const char* name() const {
  76     return _name;
  77   }
  78 
  79   static void set_file_name_parameters(jlong start_time);
  80 };
  81 #endif



   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 #ifndef SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP
  25 #define SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP
  26 
  27 #include "logging/logFileStreamOutput.hpp"

  28 #include "runtime/mutex.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 StartTimeBufferSize = 20;
  43   static const size_t PidBufferSize       = 21;
  44   static char         _pid_str[PidBufferSize];
  45   static char         _vm_start_time_str[StartTimeBufferSize];
  46 
  47   Mutex _rotation_lock;
  48   const char* _name;
  49   char* _file_name;


  62   bool configure_rotation(const char* options);
  63   char *make_file_name(const char* file_name, const char* pid_string, const char* timestamp_string);
  64   static size_t parse_value(const char* value_str);
  65 
  66   bool should_rotate() const {
  67     return _file_count > 0 && _rotate_size > 0 && _current_size >= _rotate_size;
  68   }
  69 
  70  public:
  71   LogFileOutput(const char *name);
  72   virtual ~LogFileOutput();
  73   virtual bool initialize(const char* options);
  74   virtual int write(const LogDecorations& decorations, const char* msg);
  75 
  76   virtual const char* name() const {
  77     return _name;
  78   }
  79 
  80   static void set_file_name_parameters(jlong start_time);
  81 };
  82 
  83 #endif // SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP
< prev index next >