OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 package org.chromium.distiller; | 5 package org.chromium.distiller; |
6 | 6 |
7 import org.chromium.distiller.proto.DomDistillerProtos; | |
8 import org.chromium.distiller.proto.DomDistillerProtos.TimingEntry; | 7 import org.chromium.distiller.proto.DomDistillerProtos.TimingEntry; |
9 import org.chromium.distiller.proto.DomDistillerProtos.TimingInfo; | 8 import org.chromium.distiller.proto.DomDistillerProtos.TimingInfo; |
10 | 9 |
11 public class LogUtil { | 10 public class LogUtil { |
12 // All statically initialized fields in this class should be primitives or S
trings. Otherwise, a | 11 // All statically initialized fields in this class should be primitives or S
trings. Otherwise, a |
13 // costly (because it is called many, many times) static initializer method
will be created. | 12 // costly (because it is called many, many times) static initializer method
will be created. |
14 public static final int DEBUG_LEVEL_NONE = 0; | 13 public static final int DEBUG_LEVEL_NONE = 0; |
15 public static final int DEBUG_LEVEL_BOILER_PIPE_PHASES = 1; | 14 public static final int DEBUG_LEVEL_BOILER_PIPE_PHASES = 1; |
16 public static final int DEBUG_LEVEL_VISIBILITY_INFO = 2; | 15 public static final int DEBUG_LEVEL_VISIBILITY_INFO = 2; |
17 public static final int DEBUG_LEVEL_PAGING_INFO = 3; | 16 public static final int DEBUG_LEVEL_PAGING_INFO = 3; |
(...skipping 27 matching lines...) Expand all Loading... |
45 | 44 |
46 private static String sLogBuilder = ""; | 45 private static String sLogBuilder = ""; |
47 | 46 |
48 /** | 47 /** |
49 * Debug level requested by the client for logging to include while distilli
ng. | 48 * Debug level requested by the client for logging to include while distilli
ng. |
50 */ | 49 */ |
51 private static int sDebugLevel = DEBUG_LEVEL_NONE; | 50 private static int sDebugLevel = DEBUG_LEVEL_NONE; |
52 | 51 |
53 /** | 52 /** |
54 * Whether the log should be included in | 53 * Whether the log should be included in |
55 * {@link DomDistillerProtos.DomDistillerResult}. | 54 * {@link org.chromium.distiller.proto.DomDistillerProtos.DomDistillerResult
}. |
56 */ | 55 */ |
57 private static boolean sIncludeLog = false; | 56 private static boolean sIncludeLog = false; |
58 | 57 |
59 /** | 58 /** |
60 * Whether the log should be suppressed. If this flag is true, there will be
no output to | 59 * Whether the log should be suppressed. If this flag is true, there will be
no output to |
61 * the JS console. This is used when running the JS Tests in Chromium, where
the log is | 60 * the JS console. This is used when running the JS Tests in Chromium, where
the log is |
62 * retreived using {@link #getAndClearLog} instead. | 61 * retrieved using {@link #getAndClearLog} instead. |
63 */ | 62 */ |
64 private static boolean sSuppressConsoleOutput; | 63 private static boolean sSuppressConsoleOutput; |
65 | 64 |
66 public static boolean isLoggable(int level) { | 65 public static boolean isLoggable(int level) { |
67 return sDebugLevel >= level; | 66 return sDebugLevel >= level; |
68 } | 67 } |
69 | 68 |
70 /** | 69 /** |
71 * Log a string to console unless {@link #sSuppressLogOutput} is true. The l
og string is always | 70 * Log a string to console unless {@link #sSuppressConsoleOutput} is true. T
he log string is |
72 * added to the log builder. | 71 * always added to the log builder. |
73 */ | 72 */ |
74 public static void logToConsole(String str) { | 73 public static void logToConsole(String str) { |
75 if (str == null) { | 74 if (str == null) { |
76 str = ""; | 75 str = ""; |
77 } | 76 } |
78 | 77 |
79 if (str.contains("[0;") || str.contains("[1;")) { | 78 if (str.contains("[0;") || str.contains("[1;")) { |
80 str += kReset; | 79 str += kReset; |
81 } | 80 } |
82 | 81 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 }-*/; | 116 }-*/; |
118 | 117 |
119 public static void addTimingInfo(double startTime, TimingInfo timinginfo, St
ring name) { | 118 public static void addTimingInfo(double startTime, TimingInfo timinginfo, St
ring name) { |
120 if (timinginfo != null) { | 119 if (timinginfo != null) { |
121 TimingEntry entry = timinginfo.addOtherTimes(); | 120 TimingEntry entry = timinginfo.addOtherTimes(); |
122 entry.setName(name); | 121 entry.setName(name); |
123 entry.setTime(DomUtil.getTime() - startTime); | 122 entry.setTime(DomUtil.getTime() - startTime); |
124 } | 123 } |
125 } | 124 } |
126 } | 125 } |
OLD | NEW |