ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
จัดการไฟล์บันทึกจากโปรแกรมรายงานผล
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ในบางกรณี การเข้าถึงเฉพาะผลการทดสอบอาจไม่เพียงพอ คุณต้องมีไฟล์บันทึกเพื่อให้ได้ผลลัพธ์โดยรวมที่สมบูรณ์
อินเทอร์เฟซบันทึก
ผู้รายงานผลลัพธ์หรือเหตุการณ์ทดสอบสามารถเข้าถึงบันทึกได้โดยการใช้ ILogSaverListener
ซึ่งจะช่วยให้ผู้รายงานได้รับบันทึกผ่านการเรียกกลับแบบต่างๆ ดังนี้
testLogSaved
: เรียกใช้ทันทีเมื่อมีบันทึกไฟล์ ซึ่งจะแจ้งว่ามีบันทึกไฟล์ใหม่ ซึ่งเรียกว่า "ได้ทุกเมื่อ"
logAssociation
: เรียกตามลําดับกับเหตุการณ์ทดสอบ วิธีนี้ช่วยให้มั่นใจได้ว่าไฟล์ที่บันทึกไว้จะเชื่อมโยงกับเหตุการณ์ที่กำลังดำเนินอยู่อย่างแน่นหนา
การใช้อินเทอร์เฟซนี้จะช่วยให้ผู้รายงานผลลัพธ์มีสิทธิ์เข้าถึงและใช้งานข้อมูลอ้างอิงไฟล์ที่บันทึกไว้ได้
กรณีที่ควรใช้ logAssociation
logAssociation
เป็นเหตุการณ์ที่ซับซ้อนกว่าเล็กน้อยเนื่องจากต้องอาศัยบริบทของเหตุการณ์เพื่อตีความอย่างถูกต้อง ตัวอย่างเช่น หากมีการเรียกใช้ testStart
บันทึกจาก logAssociation
จะเป็นของกรณีทดสอบที่อยู่ระหว่างดำเนินการ
การเชื่อมโยงที่แน่นแฟ้นนี้ช่วยให้วางบันทึกได้อย่างถูกต้อง
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา 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,["# Handle log files from a result reporter\n\nIn some cases, having access to only the test results isn't enough; having\nthe log files is necessary to complete the overall results.\n\nLog interface\n-------------\n\nAny result reporter or [test event](/docs/core/tests/tradefed/architecture/result-reporter#core_interface)\ncan have access to the logs by implementing\n[`ILogSaverListener`](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/invocation_interfaces/com/android/tradefed/result/ILogSaverListener.java),\nwhich lets a reporter receive the logs through different callbacks:\n\n- `testLogSaved`: Called right away when a file is logged. This notifies a new file has been logged. This is called at any time.\n- `logAssociation`: Called in order with the test events. This ensures a strong association between the file being logged and the events in progress.\n\nBy implementing this interface, the result reporter can have access to the\nlogged file references and use them.\n\nWhen to use logAssociation\n--------------------------\n\n`logAssociation` is a slightly more complicated event as it relies on the\ncontext of the events to be properly interpreted. For example, if the\n`testStart` has been called, the log from `logAssociation` belongs to the test\ncase in progress.\n\nThis strong association allows for correct placement of logs."]]