575 if (force_directory != NULL) {
576 strcat(buf, force_directory);
577 strcat(buf, os::file_separator());
578 nametail = basename; // completely skip directory prefix
579 }
580
581 if (star_pos >= 0) {
582 // convert foo*bar.log or foo%pbar.log to foo123bar.log
583 int buf_pos = (int) strlen(buf);
584 strncpy(&buf[buf_pos], nametail, star_pos);
585 strcpy(&buf[buf_pos + star_pos], pid);
586 nametail += star_pos + skip; // skip prefix and pid format
587 }
588
589 strcat(buf, nametail); // append rest of name, or all of name
590 return buf;
591 }
592
593 void defaultStream::init_log() {
594 // %%% Need a MutexLocker?
595 const char* log_name = LogFile != NULL ? LogFile : "hotspot.log";
596 const char* try_name = make_log_name(log_name, NULL);
597 fileStream* file = new(ResourceObj::C_HEAP, mtInternal) fileStream(try_name);
598 if (!file->is_open()) {
599 // Try again to open the file.
600 char warnbuf[O_BUFLEN*2];
601 jio_snprintf(warnbuf, sizeof(warnbuf),
602 "Warning: Cannot open log file: %s\n", try_name);
603 // Note: This feature is for maintainer use only. No need for L10N.
604 jio_print(warnbuf);
605 FREE_C_HEAP_ARRAY(char, try_name, mtInternal);
606 try_name = make_log_name("hs_pid%p.log", os::get_temp_directory());
607 jio_snprintf(warnbuf, sizeof(warnbuf),
608 "Warning: Forcing option -XX:LogFile=%s\n", try_name);
609 jio_print(warnbuf);
610 delete file;
611 file = new(ResourceObj::C_HEAP, mtInternal) fileStream(try_name);
612 FREE_C_HEAP_ARRAY(char, try_name, mtInternal);
613 }
614 if (file->is_open()) {
615 _log_file = file;
616 xmlStream* xs = new(ResourceObj::C_HEAP, mtInternal) xmlStream(file);
617 _outer_xmlStream = xs;
618 if (this == tty) xtty = xs;
619 // Write XML header.
620 xs->print_cr("<?xml version='1.0' encoding='UTF-8'?>");
621 // (For now, don't bother to issue a DTD for this private format.)
622 jlong time_ms = os::javaTimeMillis() - tty->time_stamp().milliseconds();
623 // %%% Should be: jlong time_ms = os::start_time_milliseconds(), if
624 // we ever get round to introduce that method on the os class
625 xs->head("hotspot_log version='%d %d'"
626 " process='%d' time_ms='"INT64_FORMAT"'",
627 LOG_MAJOR_VERSION, LOG_MINOR_VERSION,
628 os::current_process_id(), time_ms);
629 // Write VM version header immediately.
630 xs->head("vm_version");
631 xs->head("name"); xs->text("%s", VM_Version::vm_name()); xs->cr();
632 xs->tail("name");
633 xs->head("release"); xs->text("%s", VM_Version::vm_release()); xs->cr();
|
575 if (force_directory != NULL) {
576 strcat(buf, force_directory);
577 strcat(buf, os::file_separator());
578 nametail = basename; // completely skip directory prefix
579 }
580
581 if (star_pos >= 0) {
582 // convert foo*bar.log or foo%pbar.log to foo123bar.log
583 int buf_pos = (int) strlen(buf);
584 strncpy(&buf[buf_pos], nametail, star_pos);
585 strcpy(&buf[buf_pos + star_pos], pid);
586 nametail += star_pos + skip; // skip prefix and pid format
587 }
588
589 strcat(buf, nametail); // append rest of name, or all of name
590 return buf;
591 }
592
593 void defaultStream::init_log() {
594 // %%% Need a MutexLocker?
595 const char* log_name = LogFile != NULL ? LogFile : "hotspot_pid%p.log";
596 const char* try_name = make_log_name(log_name, NULL);
597 fileStream* file = new(ResourceObj::C_HEAP, mtInternal) fileStream(try_name);
598 if (!file->is_open()) {
599 // Try again to open the file.
600 char warnbuf[O_BUFLEN*2];
601 jio_snprintf(warnbuf, sizeof(warnbuf),
602 "Warning: Cannot open log file: %s\n", try_name);
603 // Note: This feature is for maintainer use only. No need for L10N.
604 jio_print(warnbuf);
605 FREE_C_HEAP_ARRAY(char, try_name, mtInternal);
606 try_name = make_log_name(log_name, os::get_temp_directory());
607 jio_snprintf(warnbuf, sizeof(warnbuf),
608 "Warning: Forcing option -XX:LogFile=%s\n", try_name);
609 jio_print(warnbuf);
610 delete file;
611 file = new(ResourceObj::C_HEAP, mtInternal) fileStream(try_name);
612 FREE_C_HEAP_ARRAY(char, try_name, mtInternal);
613 } else {
614 FREE_C_HEAP_ARRAY(char, try_name, mtInternal);
615 }
616
617 if (file->is_open()) {
618 _log_file = file;
619 xmlStream* xs = new(ResourceObj::C_HEAP, mtInternal) xmlStream(file);
620 _outer_xmlStream = xs;
621 if (this == tty) xtty = xs;
622 // Write XML header.
623 xs->print_cr("<?xml version='1.0' encoding='UTF-8'?>");
624 // (For now, don't bother to issue a DTD for this private format.)
625 jlong time_ms = os::javaTimeMillis() - tty->time_stamp().milliseconds();
626 // %%% Should be: jlong time_ms = os::start_time_milliseconds(), if
627 // we ever get round to introduce that method on the os class
628 xs->head("hotspot_log version='%d %d'"
629 " process='%d' time_ms='"INT64_FORMAT"'",
630 LOG_MAJOR_VERSION, LOG_MINOR_VERSION,
631 os::current_process_id(), time_ms);
632 // Write VM version header immediately.
633 xs->head("vm_version");
634 xs->head("name"); xs->text("%s", VM_Version::vm_name()); xs->cr();
635 xs->tail("name");
636 xs->head("release"); xs->text("%s", VM_Version::vm_release()); xs->cr();
|