| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.base; | 5 package org.chromium.base; |
| 6 | 6 |
| 7 import android.text.TextUtils; | 7 import android.text.TextUtils; |
| 8 | 8 |
| 9 import org.chromium.base.annotations.NoSideEffects; | 9 import org.chromium.base.annotations.NoSideEffects; |
| 10 | 10 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 /** | 229 /** |
| 230 * Sends an {@link android.util.Log#INFO} log message. | 230 * Sends an {@link android.util.Log#INFO} log message. |
| 231 * | 231 * |
| 232 * @param tag Used to identify the source of a log message. | 232 * @param tag Used to identify the source of a log message. |
| 233 * @param messageTemplate The message you would like logged. It is to be spe
cified as a format | 233 * @param messageTemplate The message you would like logged. It is to be spe
cified as a format |
| 234 * string. | 234 * string. |
| 235 * @param args Arguments referenced by the format specifiers in the format s
tring. If the last | 235 * @param args Arguments referenced by the format specifiers in the format s
tring. If the last |
| 236 * one is a {@link Throwable}, its trace will be printed. | 236 * one is a {@link Throwable}, its trace will be printed. |
| 237 */ | 237 */ |
| 238 @VisibleForTesting |
| 238 public static void i(String tag, String messageTemplate, Object... args) { | 239 public static void i(String tag, String messageTemplate, Object... args) { |
| 239 if (Log.isLoggable(tag, Log.INFO)) { | 240 if (Log.isLoggable(tag, Log.INFO)) { |
| 240 String message = formatLog(messageTemplate, args); | 241 String message = formatLog(messageTemplate, args); |
| 241 Throwable tr = getThrowableToLog(args); | 242 Throwable tr = getThrowableToLog(args); |
| 242 if (tr != null) { | 243 if (tr != null) { |
| 243 android.util.Log.i(tag, message, tr); | 244 android.util.Log.i(tag, message, tr); |
| 244 } else { | 245 } else { |
| 245 android.util.Log.i(tag, message); | 246 android.util.Log.i(tag, message); |
| 246 } | 247 } |
| 247 } | 248 } |
| 248 } | 249 } |
| 249 | 250 |
| 250 /** | 251 /** |
| 251 * Sends a {@link android.util.Log#WARN} log message. | 252 * Sends a {@link android.util.Log#WARN} log message. |
| 252 * | 253 * |
| 253 * @param tag Used to identify the source of a log message. | 254 * @param tag Used to identify the source of a log message. |
| 254 * @param messageTemplate The message you would like logged. It is to be spe
cified as a format | 255 * @param messageTemplate The message you would like logged. It is to be spe
cified as a format |
| 255 * string. | 256 * string. |
| 256 * @param args Arguments referenced by the format specifiers in the format s
tring. If the last | 257 * @param args Arguments referenced by the format specifiers in the format s
tring. If the last |
| 257 * one is a {@link Throwable}, its trace will be printed. | 258 * one is a {@link Throwable}, its trace will be printed. |
| 258 */ | 259 */ |
| 260 @VisibleForTesting |
| 259 public static void w(String tag, String messageTemplate, Object... args) { | 261 public static void w(String tag, String messageTemplate, Object... args) { |
| 260 if (Log.isLoggable(tag, Log.WARN)) { | 262 if (Log.isLoggable(tag, Log.WARN)) { |
| 261 String message = formatLog(messageTemplate, args); | 263 String message = formatLog(messageTemplate, args); |
| 262 Throwable tr = getThrowableToLog(args); | 264 Throwable tr = getThrowableToLog(args); |
| 263 if (tr != null) { | 265 if (tr != null) { |
| 264 android.util.Log.w(tag, message, tr); | 266 android.util.Log.w(tag, message, tr); |
| 265 } else { | 267 } else { |
| 266 android.util.Log.w(tag, message); | 268 android.util.Log.w(tag, message); |
| 267 } | 269 } |
| 268 } | 270 } |
| 269 } | 271 } |
| 270 | 272 |
| 271 /** | 273 /** |
| 272 * Sends an {@link android.util.Log#ERROR} log message. | 274 * Sends an {@link android.util.Log#ERROR} log message. |
| 273 * | 275 * |
| 274 * @param tag Used to identify the source of a log message. | 276 * @param tag Used to identify the source of a log message. |
| 275 * @param messageTemplate The message you would like logged. It is to be spe
cified as a format | 277 * @param messageTemplate The message you would like logged. It is to be spe
cified as a format |
| 276 * string. | 278 * string. |
| 277 * @param args Arguments referenced by the format specifiers in the format s
tring. If the last | 279 * @param args Arguments referenced by the format specifiers in the format s
tring. If the last |
| 278 * one is a {@link Throwable}, its trace will be printed. | 280 * one is a {@link Throwable}, its trace will be printed. |
| 279 */ | 281 */ |
| 282 @VisibleForTesting |
| 280 public static void e(String tag, String messageTemplate, Object... args) { | 283 public static void e(String tag, String messageTemplate, Object... args) { |
| 281 if (Log.isLoggable(tag, Log.ERROR)) { | 284 if (Log.isLoggable(tag, Log.ERROR)) { |
| 282 String message = formatLog(messageTemplate, args); | 285 String message = formatLog(messageTemplate, args); |
| 283 Throwable tr = getThrowableToLog(args); | 286 Throwable tr = getThrowableToLog(args); |
| 284 if (tr != null) { | 287 if (tr != null) { |
| 285 android.util.Log.e(tag, message, tr); | 288 android.util.Log.e(tag, message, tr); |
| 286 } else { | 289 } else { |
| 287 android.util.Log.e(tag, message); | 290 android.util.Log.e(tag, message); |
| 288 } | 291 } |
| 289 } | 292 } |
| 290 } | 293 } |
| 291 | 294 |
| 292 /** | 295 /** |
| 293 * What a Terrible Failure: Used for conditions that should never happen, an
d logged at | 296 * What a Terrible Failure: Used for conditions that should never happen, an
d logged at |
| 294 * the {@link android.util.Log#ASSERT} level. Depending on the configuration
, it might | 297 * the {@link android.util.Log#ASSERT} level. Depending on the configuration
, it might |
| 295 * terminate the process. | 298 * terminate the process. |
| 296 * | 299 * |
| 297 * @see android.util.Log#wtf(String, String, Throwable) | 300 * @see android.util.Log#wtf(String, String, Throwable) |
| 298 * | 301 * |
| 299 * @param tag Used to identify the source of a log message. | 302 * @param tag Used to identify the source of a log message. |
| 300 * @param messageTemplate The message you would like logged. It is to be spe
cified as a format | 303 * @param messageTemplate The message you would like logged. It is to be spe
cified as a format |
| 301 * string. | 304 * string. |
| 302 * @param args Arguments referenced by the format specifiers in the format s
tring. If the last | 305 * @param args Arguments referenced by the format specifiers in the format s
tring. If the last |
| 303 * one is a {@link Throwable}, its trace will be printed. | 306 * one is a {@link Throwable}, its trace will be printed. |
| 304 */ | 307 */ |
| 308 @VisibleForTesting |
| 305 public static void wtf(String tag, String messageTemplate, Object... args) { | 309 public static void wtf(String tag, String messageTemplate, Object... args) { |
| 306 if (Log.isLoggable(tag, Log.ASSERT)) { | 310 if (Log.isLoggable(tag, Log.ASSERT)) { |
| 307 String message = formatLog(messageTemplate, args); | 311 String message = formatLog(messageTemplate, args); |
| 308 Throwable tr = getThrowableToLog(args); | 312 Throwable tr = getThrowableToLog(args); |
| 309 if (tr != null) { | 313 if (tr != null) { |
| 310 android.util.Log.wtf(tag, message, tr); | 314 android.util.Log.wtf(tag, message, tr); |
| 311 } else { | 315 } else { |
| 312 android.util.Log.wtf(tag, message); | 316 android.util.Log.wtf(tag, message); |
| 313 } | 317 } |
| 314 } | 318 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 340 for (callerStackIndex = 0; callerStackIndex < st.length; callerStackInde
x++) { | 344 for (callerStackIndex = 0; callerStackIndex < st.length; callerStackInde
x++) { |
| 341 if (st[callerStackIndex].getClassName().equals(logClassName)) { | 345 if (st[callerStackIndex].getClassName().equals(logClassName)) { |
| 342 callerStackIndex += 4; | 346 callerStackIndex += 4; |
| 343 break; | 347 break; |
| 344 } | 348 } |
| 345 } | 349 } |
| 346 | 350 |
| 347 return st[callerStackIndex].getFileName() + ":" + st[callerStackIndex].g
etLineNumber(); | 351 return st[callerStackIndex].getFileName() + ":" + st[callerStackIndex].g
etLineNumber(); |
| 348 } | 352 } |
| 349 } | 353 } |
| OLD | NEW |