OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/log.h" | 5 #include "src/log.h" |
6 | 6 |
7 #include <cstdarg> | 7 #include <cstdarg> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/v8.h" | 10 #include "src/v8.h" |
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 | 1760 |
1761 | 1761 |
1762 static void AddIsolateIdIfNeeded(std::ostream& os, // NOLINT | 1762 static void AddIsolateIdIfNeeded(std::ostream& os, // NOLINT |
1763 Isolate* isolate) { | 1763 Isolate* isolate) { |
1764 if (FLAG_logfile_per_isolate) os << "isolate-" << isolate << "-"; | 1764 if (FLAG_logfile_per_isolate) os << "isolate-" << isolate << "-"; |
1765 } | 1765 } |
1766 | 1766 |
1767 | 1767 |
1768 static void PrepareLogFileName(std::ostream& os, // NOLINT | 1768 static void PrepareLogFileName(std::ostream& os, // NOLINT |
1769 Isolate* isolate, const char* file_name) { | 1769 Isolate* isolate, const char* file_name) { |
1770 AddIsolateIdIfNeeded(os, isolate); | 1770 int dir_separator_count = 0; |
1771 for (const char* p = file_name; *p; p++) { | 1771 for (const char* p = file_name; *p; p++) { |
| 1772 if (base::OS::isDirectorySeparator(*p)) dir_separator_count++; |
| 1773 } |
| 1774 |
| 1775 for (const char* p = file_name; *p; p++) { |
| 1776 if (dir_separator_count == 0) { |
| 1777 AddIsolateIdIfNeeded(os, isolate); |
| 1778 dir_separator_count--; |
| 1779 } |
1772 if (*p == '%') { | 1780 if (*p == '%') { |
1773 p++; | 1781 p++; |
1774 switch (*p) { | 1782 switch (*p) { |
1775 case '\0': | 1783 case '\0': |
1776 // If there's a % at the end of the string we back up | 1784 // If there's a % at the end of the string we back up |
1777 // one character so we can escape the loop properly. | 1785 // one character so we can escape the loop properly. |
1778 p--; | 1786 p--; |
1779 break; | 1787 break; |
1780 case 'p': | 1788 case 'p': |
1781 os << base::OS::GetCurrentProcessId(); | 1789 os << base::OS::GetCurrentProcessId(); |
1782 break; | 1790 break; |
1783 case 't': | 1791 case 't': |
1784 // %t expands to the current time in milliseconds. | 1792 // %t expands to the current time in milliseconds. |
1785 os << static_cast<int64_t>(base::OS::TimeCurrentMillis()); | 1793 os << static_cast<int64_t>(base::OS::TimeCurrentMillis()); |
1786 break; | 1794 break; |
1787 case '%': | 1795 case '%': |
1788 // %% expands (contracts really) to %. | 1796 // %% expands (contracts really) to %. |
1789 os << '%'; | 1797 os << '%'; |
1790 break; | 1798 break; |
1791 default: | 1799 default: |
1792 // All other %'s expand to themselves. | 1800 // All other %'s expand to themselves. |
1793 os << '%' << *p; | 1801 os << '%' << *p; |
1794 break; | 1802 break; |
1795 } | 1803 } |
1796 } else { | 1804 } else { |
| 1805 if (base::OS::isDirectorySeparator(*p)) dir_separator_count--; |
1797 os << *p; | 1806 os << *p; |
1798 } | 1807 } |
1799 } | 1808 } |
1800 } | 1809 } |
1801 | 1810 |
1802 | 1811 |
1803 bool Logger::SetUp(Isolate* isolate) { | 1812 bool Logger::SetUp(Isolate* isolate) { |
1804 // Tests and EnsureInitialize() can call this twice in a row. It's harmless. | 1813 // Tests and EnsureInitialize() can call this twice in a row. It's harmless. |
1805 if (is_initialized_) return true; | 1814 if (is_initialized_) return true; |
1806 is_initialized_ = true; | 1815 is_initialized_ = true; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1908 if (jit_logger_) { | 1917 if (jit_logger_) { |
1909 removeCodeEventListener(jit_logger_); | 1918 removeCodeEventListener(jit_logger_); |
1910 delete jit_logger_; | 1919 delete jit_logger_; |
1911 jit_logger_ = NULL; | 1920 jit_logger_ = NULL; |
1912 } | 1921 } |
1913 | 1922 |
1914 return log_->Close(); | 1923 return log_->Close(); |
1915 } | 1924 } |
1916 | 1925 |
1917 } } // namespace v8::internal | 1926 } } // namespace v8::internal |
OLD | NEW |