< prev index next >

src/hotspot/share/logging/logFileOutput.cpp

Print this page
rev 52870 : 8214944: replace strerror by os::strerror


 231                           "%s is not a regular file",
 232                           _file_name, _file_name);
 233       return false;
 234     }
 235     _current_file = next_file_number(_file_name,
 236                                      _file_count_max_digits,
 237                                      _file_count,
 238                                      errstream);
 239     if (_current_file == UINT_MAX) {
 240       return false;
 241     }
 242     log_trace(logging)("Existing log file found, saving it as '%s.%0*u'",
 243                        _file_name, _file_count_max_digits, _current_file);
 244     archive();
 245     increment_file_count();
 246   }
 247 
 248   _stream = os::fopen(_file_name, FileOpenMode);
 249   if (_stream == NULL) {
 250     errstream->print_cr("Error opening log file '%s': %s",
 251                         _file_name, strerror(errno));
 252     return false;
 253   }
 254 
 255   if (_file_count == 0 && is_regular_file(_file_name)) {
 256     log_trace(logging)("Truncating log file");
 257     os::ftruncate(os::get_fileno(_stream), 0);
 258   }
 259 
 260   return true;
 261 }
 262 
 263 int LogFileOutput::write(const LogDecorations& decorations, const char* msg) {
 264   if (_stream == NULL) {
 265     // An error has occurred with this output, avoid writing to it.
 266     return 0;
 267   }
 268 
 269   _rotation_semaphore.wait();
 270   int written = LogFileStreamOutput::write(decorations, msg);
 271   _current_size += written;




 231                           "%s is not a regular file",
 232                           _file_name, _file_name);
 233       return false;
 234     }
 235     _current_file = next_file_number(_file_name,
 236                                      _file_count_max_digits,
 237                                      _file_count,
 238                                      errstream);
 239     if (_current_file == UINT_MAX) {
 240       return false;
 241     }
 242     log_trace(logging)("Existing log file found, saving it as '%s.%0*u'",
 243                        _file_name, _file_count_max_digits, _current_file);
 244     archive();
 245     increment_file_count();
 246   }
 247 
 248   _stream = os::fopen(_file_name, FileOpenMode);
 249   if (_stream == NULL) {
 250     errstream->print_cr("Error opening log file '%s': %s",
 251                         _file_name, os::strerror(errno));
 252     return false;
 253   }
 254 
 255   if (_file_count == 0 && is_regular_file(_file_name)) {
 256     log_trace(logging)("Truncating log file");
 257     os::ftruncate(os::get_fileno(_stream), 0);
 258   }
 259 
 260   return true;
 261 }
 262 
 263 int LogFileOutput::write(const LogDecorations& decorations, const char* msg) {
 264   if (_stream == NULL) {
 265     // An error has occurred with this output, avoid writing to it.
 266     return 0;
 267   }
 268 
 269   _rotation_semaphore.wait();
 270   int written = LogFileStreamOutput::write(decorations, msg);
 271   _current_size += written;


< prev index next >