Flutter Engine
The Flutter Engine
Log.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package io.flutter;
6
7import androidx.annotation.NonNull;
8import androidx.annotation.Nullable;
9
10/**
11 * Port of {@link android.util.Log} that only logs in {@value io.flutter.BuildConfig#DEBUG} mode and
12 * internally filters logs based on a {@link #logLevel}.
13 */
14public class Log {
15 private static int logLevel = android.util.Log.DEBUG;
16
17 public static int ASSERT = android.util.Log.ASSERT;
18 public static int DEBUG = android.util.Log.DEBUG;
19 public static int ERROR = android.util.Log.ERROR;
20 public static int INFO = android.util.Log.INFO;
21 public static int VERBOSE = android.util.Log.VERBOSE;
22 public static int WARN = android.util.Log.WARN;
23
24 /**
25 * Sets a log cutoff such that a log level of lower priority than {@code logLevel} is filtered
26 * out.
27 *
28 * <p>See {@link android.util.Log} for log level constants.
29 */
30 public static void setLogLevel(int logLevel) {
31 Log.logLevel = logLevel;
32 }
33
34 public static void println(@NonNull int level, @NonNull String tag, @NonNull String message) {
35 if (BuildConfig.DEBUG && logLevel <= level) {
36 android.util.Log.println(level, tag, message);
37 }
38 }
39
40 public static void v(@NonNull String tag, @NonNull String message) {
41 if (BuildConfig.DEBUG && logLevel <= android.util.Log.VERBOSE) {
42 android.util.Log.v(tag, message);
43 }
44 }
45
46 public static void v(@NonNull String tag, @NonNull String message, @NonNull Throwable tr) {
47 if (BuildConfig.DEBUG && logLevel <= android.util.Log.VERBOSE) {
48 android.util.Log.v(tag, message, tr);
49 }
50 }
51
52 public static void i(@NonNull String tag, @NonNull String message) {
53 if (BuildConfig.DEBUG && logLevel <= android.util.Log.INFO) {
54 android.util.Log.i(tag, message);
55 }
56 }
57
58 public static void i(@NonNull String tag, @NonNull String message, @NonNull Throwable tr) {
59 if (BuildConfig.DEBUG && logLevel <= android.util.Log.INFO) {
60 android.util.Log.i(tag, message, tr);
61 }
62 }
63
64 public static void d(@NonNull String tag, @NonNull String message) {
65 if (BuildConfig.DEBUG && logLevel <= android.util.Log.DEBUG) {
66 android.util.Log.d(tag, message);
67 }
68 }
69
70 public static void d(@NonNull String tag, @NonNull String message, @NonNull Throwable tr) {
71 if (BuildConfig.DEBUG && logLevel <= android.util.Log.DEBUG) {
72 android.util.Log.d(tag, message, tr);
73 }
74 }
75
76 public static void w(@NonNull String tag, @NonNull String message) {
77 android.util.Log.w(tag, message);
78 }
79
80 public static void w(@NonNull String tag, @NonNull String message, @NonNull Throwable tr) {
81 android.util.Log.w(tag, message, tr);
82 }
83
84 public static void e(@NonNull String tag, @NonNull String message) {
85 android.util.Log.e(tag, message);
86 }
87
88 public static void e(@NonNull String tag, @NonNull String message, @NonNull Throwable tr) {
89 android.util.Log.e(tag, message, tr);
90 }
91
92 public static void wtf(@NonNull String tag, @NonNull String message) {
93 android.util.Log.wtf(tag, message);
94 }
95
96 public static void wtf(@NonNull String tag, @NonNull String message, @NonNull Throwable tr) {
97 android.util.Log.wtf(tag, message, tr);
98 }
99
100 @NonNull
101 public static String getStackTraceString(@Nullable Throwable tr) {
102 return android.util.Log.getStackTraceString(tr);
103 }
104}
static final boolean DEBUG
static String getStackTraceString(@Nullable Throwable tr)
Definition: Log.java:101
static int WARN
Definition: Log.java:22
static void w(@NonNull String tag, @NonNull String message, @NonNull Throwable tr)
Definition: Log.java:80
static void d(@NonNull String tag, @NonNull String message)
Definition: Log.java:64
static void v(@NonNull String tag, @NonNull String message)
Definition: Log.java:40
static void e(@NonNull String tag, @NonNull String message)
Definition: Log.java:84
static void wtf(@NonNull String tag, @NonNull String message, @NonNull Throwable tr)
Definition: Log.java:96
static void i(@NonNull String tag, @NonNull String message)
Definition: Log.java:52
static int INFO
Definition: Log.java:20
static int ERROR
Definition: Log.java:19
static void v(@NonNull String tag, @NonNull String message, @NonNull Throwable tr)
Definition: Log.java:46
static int DEBUG
Definition: Log.java:18
static int VERBOSE
Definition: Log.java:21
static void println(@NonNull int level, @NonNull String tag, @NonNull String message)
Definition: Log.java:34
static int ASSERT
Definition: Log.java:17
static void e(@NonNull String tag, @NonNull String message, @NonNull Throwable tr)
Definition: Log.java:88
static void w(@NonNull String tag, @NonNull String message)
Definition: Log.java:76
static void d(@NonNull String tag, @NonNull String message, @NonNull Throwable tr)
Definition: Log.java:70
static void wtf(@NonNull String tag, @NonNull String message)
Definition: Log.java:92
static void i(@NonNull String tag, @NonNull String message, @NonNull Throwable tr)
Definition: Log.java:58
static void setLogLevel(int logLevel)
Definition: Log.java:30
Win32Message message