< prev index next >

src/share/vm/logging/logFileOutput.cpp

Print this page




 120       if (value == SIZE_MAX || value > SIZE_MAX / K) {
 121         success = false;
 122         break;
 123       }
 124       _rotate_size = value * K;
 125     } else {
 126       success = false;
 127       break;
 128     }
 129     pos = comma_pos + 1;
 130   } while (comma_pos != NULL);
 131 
 132   os::free(opts);
 133   return success;
 134 }
 135 
 136 bool LogFileOutput::initialize(const char* options) {
 137   if (!configure_rotation(options)) {
 138     return false;
 139   }

 140   _stream = fopen(_file_name, FileOpenMode);
 141   if (_stream == NULL) {
 142     log_error(logging)("Could not open log file '%s' (%s).\n", _file_name, os::strerror(errno));
 143     return false;
 144   }
 145   return true;
 146 }
 147 
 148 int LogFileOutput::write(const LogDecorations& decorations, const char* msg) {
 149   if (_stream == NULL) {
 150     // An error has occurred with this output, avoid writing to it.
 151     return 0;
 152   }
 153 
 154   _rotation_semaphore.wait();
 155   int written = LogFileStreamOutput::write(decorations, msg);
 156   _current_size += written;
 157 
 158   if (should_rotate()) {
 159     rotate();




 120       if (value == SIZE_MAX || value > SIZE_MAX / K) {
 121         success = false;
 122         break;
 123       }
 124       _rotate_size = value * K;
 125     } else {
 126       success = false;
 127       break;
 128     }
 129     pos = comma_pos + 1;
 130   } while (comma_pos != NULL);
 131 
 132   os::free(opts);
 133   return success;
 134 }
 135 
 136 bool LogFileOutput::initialize(const char* options) {
 137   if (!configure_rotation(options)) {
 138     return false;
 139   }
 140   set_option_string(options);
 141   _stream = fopen(_file_name, FileOpenMode);
 142   if (_stream == NULL) {
 143     log_error(logging)("Could not open log file '%s' (%s).\n", _file_name, os::strerror(errno));
 144     return false;
 145   }
 146   return true;
 147 }
 148 
 149 int LogFileOutput::write(const LogDecorations& decorations, const char* msg) {
 150   if (_stream == NULL) {
 151     // An error has occurred with this output, avoid writing to it.
 152     return 0;
 153   }
 154 
 155   _rotation_semaphore.wait();
 156   int written = LogFileStreamOutput::write(decorations, msg);
 157   _current_size += written;
 158 
 159   if (should_rotate()) {
 160     rotate();


< prev index next >