ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
LogUtil
public
class
LogUtil
extends Object
java.lang.Object
|
↳ |
com.android.tradefed.log.LogUtil
|
คลาสยูทิลิตีการบันทึก มีประโยชน์สำหรับโค้ดที่ต้องลบล้างเมธอดแบบคงที่จาก Log
สรุป
ชั้นเรียนที่ซ้อนกัน |
class |
LogUtil.CLog
คลาสชิมสำหรับ Log ที่ใช้ชื่อคลาสแบบง่ายของผู้เรียกโดยอัตโนมัติเป็นแท็กบันทึก
|
เมธอดสาธารณะ |
static
String
|
getLogFormatString(Log.LogLevel logLevel, String tag, String message)
สร้างสตริงรูปแบบที่คล้ายกับรูปแบบบันทึก "threadtime" ในอุปกรณ์
|
static
void
|
printLog(Log.LogLevel logLevel, String tag, String message)
ส่งเมื่อต้องพิมพ์ข้อความบันทึก
|
เมธอดสาธารณะ
public static String getLogFormatString (Log.LogLevel logLevel,
String tag,
String message)
สร้างสตริงรูปแบบที่คล้ายกับรูปแบบบันทึก "threadtime" ในอุปกรณ์ ซึ่งมีประโยชน์อย่างยิ่งเนื่องจากระบุวันและเดือน (เพื่อแยกแยะเวลาสำหรับอินสแตนซ์ TF ที่ทำงานอยู่นาน) และใช้เวลาแบบ 24 ชั่วโมงเพื่อแยกแยะระหว่างเช้ากับเย็น
พารามิเตอร์ |
logLevel |
Log.LogLevel |
tag |
String |
message |
String |
printLog
public static void printLog (Log.LogLevel logLevel,
String tag,
String message)
ส่งเมื่อต้องพิมพ์ข้อความบันทึก การใช้งานนี้จะพิมพ์ข้อความไปยัง stdout ในทุกกรณี
พารามิเตอร์ |
logLevel |
Log.LogLevel : อาร์เรย์ค่าคงที่ LogLevel ที่แสดงลําดับความสําคัญของข้อความ |
tag |
String : แท็กที่เชื่อมโยงกับข้อความ |
message |
String : ข้อความที่จะแสดง |
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# LogUtil\n=======\n\n\n`\npublic\n\n\nclass\nLogUtil\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\n`\n\n|---|----------------------------------|\n| java.lang.Object ||\n| ↳ | com.android.tradefed.log.LogUtil |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA logging utility class. Useful for code that needs to override static methods from [Log](../../../../../../reference/tradefed/com/android/tradefed/log/Log.html)\n\nSummary\n-------\n\n| ### Nested classes ||\n|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` class` | [LogUtil.CLog](../../../../../../reference/tradefed/com/android/tradefed/log/LogUtil.CLog.html) A shim class for [Log](../../../../../../reference/tradefed/com/android/tradefed/log/Log.html) that automatically uses the simple classname of the caller as the log tag |\n\n| ### Public methods ||\n|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` static String` | ` `[getLogFormatString](../../../../../../reference/tradefed/com/android/tradefed/log/LogUtil.html#getLogFormatString(com.android.ddmlib.Log.LogLevel,%20java.lang.String,%20java.lang.String))`(Log.LogLevel logLevel, String tag, String message) ` Creates a format string that is similar to the \"threadtime\" log format on the device. |\n| ` static void` | ` `[printLog](../../../../../../reference/tradefed/com/android/tradefed/log/LogUtil.html#printLog(com.android.ddmlib.Log.LogLevel,%20java.lang.String,%20java.lang.String))`(Log.LogLevel logLevel, String tag, String message) ` Sent when a log message needs to be printed. |\n\nPublic methods\n--------------\n\n### getLogFormatString\n\n```\npublic static String getLogFormatString (Log.LogLevel logLevel, \n String tag, \n String message)\n```\n\nCreates a format string that is similar to the \"threadtime\" log format on the device. This\nis specifically useful because it includes the day and month (to differentiate times for\nlong-running TF instances), and also uses 24-hour time to disambiguate morning from evening.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|-----------------------|\n| `logLevel` | `Log.LogLevel` \u003cbr /\u003e |\n| `tag` | `String` \u003cbr /\u003e |\n| `message` | `String` \u003cbr /\u003e |\n\n| Returns ||\n|----------|--------|\n| `String` | \u003cbr /\u003e |\n\n**See also:**\n\n- [Log.getLogFormatString(LogLevel, String, String)](../../../../../../reference/tradefed/com/android/tradefed/log/Log.html#getLogFormatString(com.android.tradefed.log.Log.LogLevel,%20java.lang.String,%20java.lang.String)) \n\n### printLog\n\n```\npublic static void printLog (Log.LogLevel logLevel, \n String tag, \n String message)\n```\n\nSent when a log message needs to be printed. This implementation prints the message to\nstdout in all cases.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `logLevel` | `Log.LogLevel`: The [LogLevel](../../../../../../reference/tradefed/com/android/ddmlib/Log.LogLevel.html) enum representing the priority of the message. \u003cbr /\u003e |\n| `tag` | `String`: The tag associated with the message. \u003cbr /\u003e |\n| `message` | `String`: The message to display. \u003cbr /\u003e |"]]