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
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
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
デプロイ直後のレイテンシスパイクを調べたら、 Railsの仕様にたどり着いた
nhsykym
0
110
Security issues being discussed on Web Platforms
petamoriken
0
700
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
150
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
160
Swift愛好会100回記念 第1回を振り返る
jollyjoester
0
120
業務時間外もAIに働いてもらう話
colorful12
3
10k
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
4.4k
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
240
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.4k
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
700
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
390
Featured
See All Featured
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
450
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
270
So, you think you're a good person
axbom
PRO
2
2.1k
Practical Orchestrator
shlominoach
191
12k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
RailsConf 2023
tenderlove
30
1.5k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
300
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.9k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
540
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
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͍·͠ΐ ͏
ΤϯδχΞืूத