惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
G
Google Developers Blog
小众软件
小众软件
V
V2EX
月光博客
月光博客
腾讯CDC
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 【当耐特】
D
Docker
M
MIT News - Artificial intelligence
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
MongoDB | Blog
MongoDB | Blog
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I Added Gemini AI to My Android Logcat Viewer. One Click ...
hiyoyo · 2026-05-01 · via DEV Community
<p><em>All tests run on an 8-year-old MacBook Air.</em></p> <p>Android Studio's logcat is fine. But opening a full IDE just to read logs and debug an error felt like overkill.</p> <p>I built a lightweight logcat viewer in Rust + Tauri. Then I added a Gemini button next to every error line. One click — AI diagnosis, no copy-pasting, no context switching.</p> <p>Here's how the AI integration works.</p> <h2> The idea: click the error, get the diagnosis </h2> <p>Every error line in the viewer has a small button. Click it, and the app:</p> <ol> <li>Pulls that error line plus the surrounding 50–100 lines from a ring buffer</li> <li>Strips any PII (IP addresses, emails) before sending</li> <li>Sends the context to Gemini with a carefully crafted prompt</li> <li>Displays the diagnosis in an overlay panel</li> </ol> <p>No manual copy-pasting. No switching to a browser. The diagnosis appears where the error is.</p> <h2> The ring buffer design </h2> <p>Logcat streams thousands of lines per minute. You can't keep all of them in memory.</p> <p>The Rust backend maintains a ring buffer of the last 2,000 lines. When the user clicks diagnose, slicing out the relevant context is instant:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight rust"><code><span class="k">pub</span> <span class="k">struct</span> <span class="n">LogRingBuffer</span> <span class="p">{</span> <span class="n">lines</span><span class="p">:</span> <span class="n">VecDeque</span><span class="p">,</span> <span class="n">capacity</span><span class="p">:</span> <span class="nb">usize</span><span class="p">,</span> <span class="p">}</span> <span class="k">impl</span> <span class="n">LogRingBuffer</span> <span class="p">{</span> <span class="k">pub</span> <span class="k">fn</span> <span class="nf">push</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span> <span class="k">self</span><span class="p">,</span> <span class="n">line</span><span class="p">:</span> <span class="n">LogLine</span><span class="p">)</span> <span class="p">{</span> <span class="k">if</span> <span class="k">self</span><span class="py">.lines</span><span class="nf">.len</span><span class="p">()</span> <span class="o">&gt;=</span> <span class="k">self</span><span class="py">.capacity</span> <span class="p">{</span> <span class="k">self</span><span class="py">.lines</span><span class="nf">.pop_front</span><span class="p">();</span> <span class="p">}</span> <span class="k">self</span><span class="py">.lines</span><span class="nf">.push_back</span><span class="p">(</span><span class="n">line</span><span class="p">);</span> <span class="p">}</span> <span class="k">pub</span> <span class="k">fn</span> <span class="nf">context_around</span><span class="p">(</span><span class="o">&amp;</span><span class="k">self</span><span class="p">,</span> <span class="n">target_idx</span><span class="p">:</span> <span class="nb">usize</span><span class="p">,</span> <span class="n">window</span><span class="p">:</span> <span class="nb">usize</span><span class="p">)</span> <span class="k">-&gt;</span> <span class="nb">Vec</span><span class="o">&lt;&amp;</span><span class="n">LogLine</span><span class="o">&gt;</span> <span class="p">{</span> <span class="k">let</span> <span class="n">start</span> <span class="o">=</span> <span class="n">target_idx</span><span class="nf">.saturating_sub</span><span class="p">(</span><span class="n">window</span><span class="p">);</span> <span class="k">let</span> <span class="n">end</span> <span class="o">=</span> <span class="p">(</span><span class="n">target_idx</span> <span class="o">+</span> <span class="n">window</span><span class="p">)</span><span class="nf">.min</span><span class="p">(</span><span class="k">self</span><span class="py">.lines</span><span class="nf">.len</span><span class="p">());</span> <span class="k">self</span><span class="py">.lines</span><span class="nf">.range</span><span class="p">(</span><span class="n">start</span><span class="o">..</span><span class="n">end</span><span class="p">)</span><span class="nf">.collect</span><span class="p">()</span> <span class="p">}</span> <span class="p">}</span> </code></pre> </div> <p>2,000 lines, instant slice, minimal memory.</p> <h2> The prompt </h2> <div class="highlight js-code-highlight"> <pre class="highlight rust"><code><span class="k">let</span> <span class="n">system</span> <span class="o">=</span> <span class="s">"You are an Android development specialist. </span><span class="err">\</span><span class="s"> Analyze the following logcat output and explain </span><span class="err">\</span><span class="s"> the root cause and fix concisely."</span><span class="p">;</span> <span class="k">let</span> <span class="n">context_text</span> <span class="o">=</span> <span class="n">context_lines</span> <span class="nf">.iter</span><span class="p">()</span> <span class="nf">.map</span><span class="p">(|</span><span class="n">l</span><span class="p">|</span> <span class="n">l</span><span class="py">.raw</span><span class="nf">.as_str</span><span class="p">())</span> <span class="py">.collect</span><span class="p">::</span><span class="o">&gt;</span><span class="p">()</span> <span class="nf">.join</span><span class="p">(</span><span class="s">"</span><span class="se">\n</span><span class="s">"</span><span class="p">);</span> <span class="k">let</span> <span class="n">prompt</span> <span class="o">=</span> <span class="nd">format!</span><span class="p">(</span><span class="s">"{}</span><span class="se">\n\n</span><span class="s">Logcat:</span><span class="se">\n</span><span class="s">{}"</span><span class="p">,</span> <span class="n">system</span><span class="p">,</span> <span class="n">context_text</span><span class="p">);</span> </code></pre> </div> <p>Simple. The context does the heavy lifting — Gemini doesn't need elaborate prompting when the relevant lines are right there.</p> <h2> Result </h2> <p>Open the viewer, run the app, see an error → click the button → diagnosis in 2–3 seconds. No IDE required.</p> <p>HiyokoLogcat is free and open source → github.com/hiyoyok/HiyokoLogcat<br> X → <a class="mentioned-user" href="https://dev.to/hiyoyok">@hiyoyok</a></p>