logd作為native service,系統(tǒng)啟動過程通過讀取rc文件來啟動,相關(guān)的屬性定義在如下logd.rc文件中。
2.2.1 logd啟動過程
logd啟動后會存在三個用來服務(wù)日志系統(tǒng)的socket:分別是
/dev/socket/logd、/dev/socket/logdr、/dev/socket/logdw。
2.2.2 日志打印buffer緩沖區(qū)
如下代碼中的參數(shù)LOG_ID_MAIN:代表buffer緩沖區(qū),DEBUG:代表日志級別。java層調(diào)用和native層調(diào)用存在輕微差異,很容易進行辨別。native的級別和buffer比較全面,大家可以通過源碼參考下。具體的日志buffer緩沖區(qū)及日志等級,見下圖所示。
/XXX/frameworks/base/core/java/android/util/Log.java
/**
- Send a {@link #DEBUG} log message.
- @param tag Used to identify the source of a log message. It usually identifies
the class or activity where the log call occurs.
- @param msg The message you would like logged.
- @return A positive value if the message was loggable (see {@link #isLoggable}).
*/
public static int d(@Nullable String tag, @NonNull String msg) {
return println_native(LOG_ID_MAIN, DEBUG, tag, msg);
}
-
Android
+關(guān)注
關(guān)注
12文章
3945瀏覽量
127991 -
代碼
+關(guān)注
關(guān)注
30文章
4830瀏覽量
69110 -
日志
+關(guān)注
關(guān)注
0文章
139瀏覽量
10684
發(fā)布評論請先 登錄
相關(guān)推薦
評論