Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: src/log.cc

Issue 7403: Timestamps in log file names (Closed)
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdarg.h> 28 #include <stdarg.h>
29 29
30 #include "v8.h" 30 #include "v8.h"
31 31
32 #include "log.h" 32 #include "log.h"
33 #include "platform.h" 33 #include "platform.h"
34 #include "string-stream.h"
34 35
35 namespace v8 { namespace internal { 36 namespace v8 { namespace internal {
36 37
37 #ifdef ENABLE_LOGGING_AND_PROFILING 38 #ifdef ENABLE_LOGGING_AND_PROFILING
38 39
39 // 40 //
40 // Sliding state window. Updates counters to keep track of the last 41 // Sliding state window. Updates counters to keep track of the last
41 // window of kBufferSize states. This is useful to track where we 42 // window of kBufferSize states. This is useful to track where we
42 // spent our time. 43 // spent our time.
43 // 44 //
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 if (FLAG_prof) FLAG_log_code = true; 680 if (FLAG_prof) FLAG_log_code = true;
680 681
681 bool open_log_file = FLAG_log || FLAG_log_api || FLAG_log_code 682 bool open_log_file = FLAG_log || FLAG_log_api || FLAG_log_code
682 || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect 683 || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect
683 || FLAG_log_regexp; 684 || FLAG_log_regexp;
684 685
685 // If we're logging anything, we need to open the log file. 686 // If we're logging anything, we need to open the log file.
686 if (open_log_file) { 687 if (open_log_file) {
687 if (strcmp(FLAG_logfile, "-") == 0) { 688 if (strcmp(FLAG_logfile, "-") == 0) {
688 logfile_ = stdout; 689 logfile_ = stdout;
690 } else if (strchr(FLAG_logfile, '%') != NULL) {
691 // If there's a '%' in the log file name we have to expand
692 // placeholders.
693 HeapStringAllocator allocator;
694 StringStream stream(&allocator);
695 for (const char* p = FLAG_logfile; *p; p++) {
696 if (*p == '%') {
697 p++;
698 switch (*p) {
699 case '\0':
700 // If there's a % at the end of the string we back up
701 // one character so we can escape the loop properly.
702 p--;
703 break;
704 case 't': {
705 // %t expands to the current time in milliseconds.
706 uint32_t time = static_cast<uint32_t>(OS::TimeCurrentMillis());
707 stream.Add("%u", time);
708 break;
709 }
710 default:
711 // All other %'s expand to themselves.
Erik Corry 2008/10/15 08:36:01 IMHO they should expand to % followed by themselve
Christian Plesner Hansen 2008/10/15 08:46:32 Sure, I'll change it -- I don't really care. I di
712 stream.Put(*p);
713 break;
714 }
715 } else {
716 stream.Put(*p);
717 }
718 }
719 SmartPointer<char> expanded = stream.ToCString();
720 logfile_ = OS::FOpen(*expanded, "w");
689 } else { 721 } else {
690 logfile_ = OS::FOpen(FLAG_logfile, "w"); 722 logfile_ = OS::FOpen(FLAG_logfile, "w");
691 } 723 }
692 mutex_ = OS::CreateMutex(); 724 mutex_ = OS::CreateMutex();
693 } 725 }
694 726
695 current_state_ = new VMState(OTHER); 727 current_state_ = new VMState(OTHER);
696 728
697 ticker_ = new Ticker(10); 729 ticker_ = new Ticker(10);
698 730
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 if (FLAG_log_state_changes) { 829 if (FLAG_log_state_changes) {
798 LOG(StringEvent("Leaving", StateToString(state_))); 830 LOG(StringEvent("Leaving", StateToString(state_)));
799 if (previous_) { 831 if (previous_) {
800 LOG(StringEvent("To", StateToString(previous_->state_))); 832 LOG(StringEvent("To", StateToString(previous_->state_)));
801 } 833 }
802 } 834 }
803 } 835 }
804 #endif 836 #endif
805 837
806 } } // namespace v8::internal 838 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698