简体   繁体   English

Android Studio LogCat 不会总是在循环中输出字段

[英]Android Studio LogCat won't always output fields within a loop

I am logging the output of various parts of the route set by a Navigation app Using exactly the same route each time, 10 instruction objects are generated I log various aspects of each instruction我正在记录导航应用程序设置的路线的各个部分的输出每次使用完全相同的路线,生成 10 个指令对象我记录了每个指令的各个方面

However, if I choose log one field, that is generally empty, it sometimes leaves out certain iterations of the loop但是,如果我选择记录一个字段,通常是空的,它有时会遗漏循环的某些迭代

here is my code for log 1这是我的日志 1 代码

Log.d("qw", "NUMBER OF INSTRUCTIONS " + resp.getInstructions().size());
for (Instruction i:resp.getInstructions()) {
    Log.d("qw", "extra " + i.getExtraInfoJSON());
}

This should log the 'extra' field 10 x it doesn't , it logs it only 6x这应该记录“额外”字段 10 x 它没有记录它只记录它 6x

2020-02-19 00:48:04.045 17624-17624/com.graphhopper.android D/qw: NUMBER OF INSTRUCTIONS 10
2020-02-19 00:48:04.045 17624-17624/com.graphhopper.android D/qw: extra {heading=251.34}
2020-02-19 00:48:04.045 17624-17624/com.graphhopper.android D/qw: extra {}
2020-02-19 00:48:04.045 17624-17624/com.graphhopper.android D/qw: extra {}
2020-02-19 00:48:04.045 17624-17624/com.graphhopper.android D/qw: extra {exit_number=1, exited=true, turn_angle=1.76}
2020-02-19 00:48:04.045 17624-17624/com.graphhopper.android D/qw: extra {exit_number=1, exited=true, turn_angle=2.81}
2020-02-19 00:48:04.045 17624-17624/com.graphhopper.android D/qw: extra {last_heading=73.96885135138928}

If I now log two fields, including one that is always populated, like so如果我现在记录两个字段,包括一个总是填充的字段,就像这样

Log.d("qw", "NUMBER OF INSTRUCTIONS " + resp.getInstructions().size());
for (Instruction i: resp.getInstructions()) {

    Log.d("qw", "extra " + i.getExtraInfoJSON()); // heading | roundabout 

    Log.d("qw", "translation " + i.getTurnDescription(esTR)); // translation of 
}

now, all of the 10 instructions are logged现在,所有 10 条指令都已记录

this is what is logged
2020-02-19 00:21:48.185 17624-17624/com.graphhopper.android D/qw: NUMBER OF INSTRUCTIONS 10
2020-02-19 00:21:48.185 17624-17624/com.graphhopper.android D/qw: extra {heading=251.34}
2020-02-19 00:21:48.185 17624-17624/com.graphhopper.android D/qw: translation continue onto Clements Crescent
2020-02-19 00:21:48.185 17624-17624/com.graphhopper.android D/qw: extra {}
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: translation turn left onto Samuel Place
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: extra {}
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: translation turn right onto Herbert Road
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: extra {}
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: translation turn left onto Laurence Street
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: extra {}
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: translation turn right onto Bankwood Road
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: extra {}
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: translation turn left onto Comries Road
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: extra {}
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: translation turn right onto Bankwood Road
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: extra {exit_number=1, exited=true, turn_angle=1.76}
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: translation At roundabout, take exit 1 onto Clarkin Road
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: extra {exit_number=1, exited=true, turn_angle=2.81}
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: translation At roundabout, take exit 1 onto Clarkin Road
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: extra {last_heading=73.96885135138928}
2020-02-19 00:21:48.186 17624-17624/com.graphhopper.android D/qw: translation arrive at destination

Why am I experiencing this behaviour ?为什么我会遇到这种行为?

已解决:添加一个递增字段,在这种情况下,每条指令的索引会导致 Logcat 在“每个”情况下打印

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM