Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Androidのログ出力をいい感じにする #potatotips 9
Search
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
240
Androidアプリ開発における技術顧問としての役割 #DroidKaigi 2018
cutmail
1
2.5k
4年続くアプリにおけるチーム開発 #DroidKaigi 2017
cutmail
13
5k
フリルにおけるドッグフーディング / Fashion Tech Meetup #2 LT
cutmail
2
4k
Adapter and Custom Layout
cutmail
3
990
いかにして不具合発見時の フィードバックを素早く行うか #potatotips 12
cutmail
0
2.6k
コーディング規約を緩く守りつつ仕事の成果を出す方法
cutmail
2
670
Other Decks in Programming
See All in Programming
ITヒヤリハットを整理してみた ~ライフサイクルと原因から考える再発防止策~
koukimiura
1
140
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
330
Foundation Models frameworkで画像分析
ryodeveloper
1
600
今さら聞けない .NET CLI
htkym
0
180
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
140
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
370
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
160
継続モナドとリアクティブプログラミング
yukikurage
3
690
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
430
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
160
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
670
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
150
Featured
See All Featured
Code Review Best Practice
trishagee
74
20k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
450
The SEO identity crisis: Don't let AI make you average
varn
0
530
The browser strikes back
jonoalderson
0
1.5k
Are puppies a ranking factor?
jonoalderson
1
3.8k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
490
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.7k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
650
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
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͍·͠ΐ ͏
ΤϯδχΞืूத