Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Androidのログ出力をいい感じにする #potatotips 9
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Tatsuya Arai
September 24, 2014
Programming
10k
8
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Androidのログ出力をいい感じにする #potatotips 9
Tatsuya Arai
September 24, 2014
More Decks by Tatsuya Arai
See All by Tatsuya Arai
5 minutes PWA
cutmail
0
250
Androidアプリ開発における技術顧問としての役割 #DroidKaigi 2018
cutmail
1
2.5k
4年続くアプリにおけるチーム開発 #DroidKaigi 2017
cutmail
13
5.1k
フリルにおけるドッグフーディング / Fashion Tech Meetup #2 LT
cutmail
2
4k
Adapter and Custom Layout
cutmail
3
990
いかにして不具合発見時の フィードバックを素早く行うか #potatotips 12
cutmail
0
2.7k
コーディング規約を緩く守りつつ仕事の成果を出す方法
cutmail
2
680
Other Decks in Programming
See All in Programming
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
22
22k
SREの越境 / SRE Collaboration
y0hgi
2
300
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
210
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
150
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
220
Are APIs Still Relevant in the AI Era?
soyuka
0
450
Kubernetes祭り #2 OP/ED
bells17
0
110
カツオ、ご期待ください
suneo3476
0
160
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
260
Java 27新機能 / Java 27 new features
kishida
2
210
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
golang-bob.pdf
iwatsukayura
0
120
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
109
250k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.3k
Building Adaptive Systems
keathley
44
3.2k
Thoughts on Productivity
jonyablonski
76
5.4k
Unsuck your backbone
ammeep
672
58k
Code Review Best Practice
trishagee
74
20k
Six Lessons from altMBA
skipperchong
29
4.5k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
370
Transcript
"OESPJEͷϩάग़ྗΛ ͍͍ײ͡ʹ͢Δ QPUBUPUJQT
@cutmail • Fablic, Inc. • iOS / Android App Developer.
Agenda • AndroidΞϓϦ։ൃʹ͓͚ΔLog • Α͋͘Δ • Timber • Timberͷ͍ํ •
·ͱΊ
Log • Debug Log • Crash Log • Event Tracking
Log
Build Variants • Build Types • ϏϧυઃఆΛΓସ͑ΔΈ • debug, release
• Product Flavours • ΞϓϦʹผ໊Λ͚ͨΓɺҰ෦Λมߋͨ͠ΓͰ͖ΔΈ • FlavorຖʹAndroidManifestϦιʔεΛ࣋ͯΔ • Free, Normal • Staging, Production
#VJME7BSJBOUTͰ։ൃ൛"OESPJEΞϓϦΛ͚Δ IUUQOJOKJOLVOIBUFOBCMPHDPNFOUSZ
ϏϧυڥʹΑΔ߹͚ EFCVH SFMFBTF ϩάग़ྗ ̋ ✕ $SBTIMZUJDT ✕ ̋ Πϕϯτϩά
✕ ̋
σόοάϩάͬͯ Ͳ͏ͯ͠·͔͢ʁ
Log.d(“MainActivity”, "Activity Created”);
ΈΜͳେ͖ LogΫϥε
public class MainActivity extends Activity { private static final String
TAG = MainActivity.class.getSimpleName(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "MainActivity created!"); } } Α͋͘Δ࣮
Α͋͘Δ࣮ public class Util { public static void log(String message)
{ if (BuildConfig.DEBUG) { Log.d("DemoAppLog", message); } } }
Α͋͘Δ࣮2 public class Logger { public static final void d(String
tag, String msg) { if (BuildConfig.DEBUG) { Log.d(tag, msg); } } public static final void e(String tag, String msg) { if (BuildConfig.DEBUG) { Log.e(tag, msg); } } public static final void i(String tag, String msg) { if (BuildConfig.DEBUG) { Log.i(tag, msg); } } }
ى͜Γ͕ͪͳ͜ͱ • releaseϏϧυͳͷʹσόοάϩάग़ྗ • debugϏϧυͳͷʹCrashlyticsʹૹ৴͞ΕͯΔ
AndroidͷLogϥΠϒϥϦ • android-logging-log4j • SLF4J • hugo
None
• https://github.com/JakeWharton/timber • ҆৺ͷSquareɺJakeWharton࡞ • AndroidͷLogΫϥεͷϥούʔ • ࣮ଶ1ͭͷϑΝΠϧ • ʮࡐʯ
Tree public interface Tree { void v(String message, Object... args);
void v(Throwable t, String message, Object... args); void d(String message, Object... args); void d(Throwable t, String message, Object... args); void i(String message, Object... args); void i(Throwable t, String message, Object... args); void w(String message, Object... args); void w(Throwable t, String message, Object... args); void e(String message, Object... args); void e(Throwable t, String message, Object... args); }
͍ํ • ApplicationΫϥεͷonCreateͰTreeΫϥεͷΠϯ ελϯεΛ࡞ͬͯTimberʹplant͢Δ public class ExampleApp extends Application {
@Override public void onCreate() { super.onCreate(); if (BuildConfig.DEBUG) { Timber.plant(new DebugTree()); } else { Timber.plant(new CrashReportingTree()); } } }
HollowTree 5SFFΠϯλϑΣʔεΛ࣮ͨ͠ςϯϓϨʔτΫϥε public static class HollowTree implements Tree { @Override
public void v(String message, Object... args) { } @Override public void v(Throwable t, String message, Object... args) { } @Override public void d(String message, Object... args) { } @Override public void d(Throwable t, String message, Object... args) { } }
ಠࣗͷTreeΛ࡞Δ private static class CrashReportingTree extends Timber.HollowTree { @Override public
void i(String message, Object... args) { i(message, args); Crashlytics.log(String.format(message, args)); } @Override public void i(Throwable t, String message, Object... args) { i(message, args); } @Override public void e(String message, Object... args) { e("ERROR: " + message, args); } @Override public void e(Throwable t, String message, Object... args) { e(message, args); Crashlytics.logException(t); } }
͍ํ2 (ϩάͷग़ྗ) • ΞϓϦ͔ΒTimberͷstaticϝιουΛݺͼग़͢ @Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.demo_activity); Timber.d("Activity Created”); }
@OnClick({ R.id.hello, R.id.hey, R.id.hi }) public void greetingClicked(Button button) {
Timber.i("A button with ID %s was clicked to say ‘%s'.", button.getId(), button.getText()); }
Timberͷ͓࡞๏ • BehaviorTreeΛ௨ͯ͠ఆٛ͢Δ • Timber.plantͰҙͷTreeΠϯελϯε͕Πϯε τʔϧͰ͖Δ • ෳͷTreeΛplantͰ͖Δ • ༻ҙ͞Ε͍ͯΔDebugTreeΛ͏ͱɺݺͼग़͞Εͨ
Ϋϥε͔ΒࣗಈͰTAGΛઃఆͯ͘͠ΕΔ
Treeͱ͍͏֓೦ͱ ͦͷΠϯλϑΣʔε͕؊
ͭ·Γ
TreeΠϯλϑΣʔεΛ ௨ͯ͠
͚ࣗͩͷTreeΛ࡞Ε
ͱ͍͏͜ͱ
Timber.plant public static void plant(Tree tree) { if (tree instanceof
TaggedTree) { TAGGED_TREES.append(FOREST.size(), true); } FOREST.add(tree); }
Timber.uproot /** Remove a planted tree. */ public static void
uproot(Tree tree) { for (int i = 0, size = FOREST.size(); i < size; i++) { if (FOREST.get(i) == tree) { TAGGED_TREES.delete(i); FOREST.remove(i); return; } } throw new IllegalArgumentException( "Cannot uproot tree which is not planted: " + tree); }
Timberͷྑ͍ͱ͜Ζ • LogΫϥεͷϥούʔͳͷͰϥΠϒϥϦࣗମ͕ബ͘ɺ ಋೖ͕؆୯ • TreeͷΠϯλϑΣʔε͕༻ҙ͞Ε͍ͯͯɺॻ͖͍͢ • LogΛ͏ͱ͖ʹඞਢͩͬͨɺTAGΛॻ͘ඞཁ͕ͳ͍ • ҾʹϑΥʔϚοτจͱΦϒδΣΫτΛͤΔ
• JakeWhartonͳͷͰ҆৺
·ͱΊ • TimberLogΫϥεͷബ͍ϥούʔ • LogΫϥεΛͦͷ··͏ͳΒɺTimber͍·͠ΐ ͏
ΤϯδχΞืूத