All tests run on an 8-year-old MacBook Air.
"Analyze this log" produces a generic answer.
"You are an Android specialist. Identify the root cause and the specific fix." produces something useful.
Prompt design matters more than most people expect. Here's what I iterated through for HiyokoLogcat's diagnosis feature.
Version 1: too vague
Analyze this Android logcat output and tell me what's wrong.
[logs]
Result: long explanations of what logcat is, generic advice about NullPointerExceptions, no specific lines called out.
Version 2: role + constraint
You are an Android development specialist.
Analyze the following logcat output.
Identify the root cause and suggest a fix.
Be concise — 3-5 sentences maximum.
[logs]
Better. Concise output. But still sometimes focused on the wrong error when multiple exceptions appeared.
Version 3: focus on the target line
let prompt = format!(
"You are an Android development specialist.\n\
The following logcat output contains an error.\n\
The KEY ERROR LINE is marked with >>.\n\
Identify the root cause of this specific error and suggest a fix.\n\
Be concise and specific. Point to the relevant line numbers if possible.\n\n\
Logcat:\n{}",
context_with_marker
);
Mark the target line in the context:
pub fn build_context_with_marker(
lines: &[LogLine],
target_idx: usize,
) -> String {
lines.iter().enumerate().map(|(i, line)| {
if i == target_idx {
format!(">> {}", line.raw)
} else {
line.raw.clone()
}
}).collect::>().join("\n")
}
The >> marker tells Gemini exactly which error to focus on. Quality improved significantly.
Version 4: language-aware (current)
The app supports Japanese and English. The system prompt switches based on UI language:
let system = match lang {
Lang::Japanese =>
"あなたはAndroid開発のスペシャリストです。\
以下のlogcatからエラー原因と解決策を日本語で簡潔に答えてください。\
KEY ERROR LINEが対象のエラーです。",
Lang::English =>
"You are an Android development specialist. \
Identify the root cause of the KEY ERROR LINE \
and suggest a fix. Be concise and specific.",
};
Japanese prompt → Japanese response. No post-processing needed.
What I learned
Three things matter most:
- Role assignment — "You are a specialist" genuinely improves output
- Target marking — tell the model exactly which line to focus on
- Length constraint — "3-5 sentences" prevents essays
Everything else is noise.
HiyokoLogcat is free and open source → github.com/hiyoyok/HiyokoLogcat
X → @hiyoyok
Top comments (0)