ݺߣ

ݺߣShare a Scribd company logo
Effortless network response logging
on Android
Simon Per?i?, senior Android developer
Thursday, April 21st, 2016 @ 17:00
http://square.github.io/okhttp/
Networking on Android
http://square.github.io/retrofit/
Retrofit 1
Retrofit 2
Retrofit 2
Logging: Retrofit  OkHttps interceptors
Retrofit 2
How does the log output look like?
JSON formatter / JSON viewer
OkLog
https://github.com/simonpercic/OkLog
OkLog
OkLog
Share url with coworkers.
(Usually REST API developers)
OkLog is like git blame, but for network requests
How does it work?
Response string from OkHttp via
application-level interceptor
gzip
Base64 encode
Create url and write string to log (w/
Timber if present)
OkLog
Get string from url param
Base64 decode
un-gzip
Return string to browser,
pretty-print if JSON
ResponseEcho
Ok, how do I use it?
1.
2.
3.
Known limitations
- Androids logging system: limited line length ~4k chars
- on some very long responses, 4k chars is not enough, even if
gzipped
- if using Timber, url is split into multiple lines
...everything works fine for the majority of cases
Non-logging approaches
Facebooks Stetho
http://facebook.github.io/stetho/
Non-logging approaches
Charles Proxy
https://www.charlesproxy.com
Which one should you use?
- No silver bullet that would cover all cases
- Use side-by-side, depending on the use case you want to cover
Logging in production
every time you log in production, a puppy dies.
- Jake Wharton, Timber readme
(https://github.com/JakeWharton/timber)
http://developer.android.com/tools/publishing/preparing.html#publishing-configure
Questions?
@simonpercic @simonpercicsimonpercic

More Related Content

What's hot (20)

A small introduction to rust language
A small introduction to rust languageA small introduction to rust language
A small introduction to rust language
Ahmad Hosseini
?
Moving to Git
Moving to GitMoving to Git
Moving to Git
Tim Moore
?
Mission ImpAnsible - NSM at (RobotFrame)work
Mission ImpAnsible - NSM at (RobotFrame)work Mission ImpAnsible - NSM at (RobotFrame)work
Mission ImpAnsible - NSM at (RobotFrame)work
Adam Przyby?a
?
Consuming API description languages - Refract & Minim
Consuming API description languages - Refract & MinimConsuming API description languages - Refract & Minim
Consuming API description languages - Refract & Minim
Jakub Nesetril
?
Infrastructure as code might be literally impossible
Infrastructure as code might be literally impossibleInfrastructure as code might be literally impossible
Infrastructure as code might be literally impossible
ice799
?
Infrastructure coders logstash
Infrastructure coders logstashInfrastructure coders logstash
Infrastructure coders logstash
David Lutz
?
Hacking Robotics(English Version)
Hacking Robotics(English Version)Hacking Robotics(English Version)
Hacking Robotics(English Version)
Kensei Demura
?
Geecon11 - Git: a Gentle InTroduction
Geecon11 -  Git: a Gentle InTroductionGeecon11 -  Git: a Gentle InTroduction
Geecon11 - Git: a Gentle InTroduction
Bruno Bossola
?
GIT: a Gentle InTroduction
GIT: a Gentle InTroductionGIT: a Gentle InTroduction
GIT: a Gentle InTroduction
Codemotion
?
8 Ways Network Engineers use Snabb (RIPE 77)
8 Ways Network Engineers use Snabb (RIPE 77)8 Ways Network Engineers use Snabb (RIPE 77)
8 Ways Network Engineers use Snabb (RIPE 77)
Igalia
?
٧ҧߧڧ ڧ ܧ ߧ Kotlin
  ٧ҧߧڧ ڧ ܧ ߧ Kotlin  ٧ҧߧڧ ڧ ܧ ߧ Kotlin
٧ҧߧڧ ڧ ܧ ߧ Kotlin
phpfriendsclub
?
TinkerPop and Titan from a Python State of Mind
TinkerPop and Titan from a  Python State of MindTinkerPop and Titan from a  Python State of Mind
TinkerPop and Titan from a Python State of Mind
Denise Gosnell, Ph.D.
?
Updates of socket.io@1.0
Updates of socket.io@1.0Updates of socket.io@1.0
Updates of socket.io@1.0
Jxck Jxck
?
Odyssey to async ruby
Odyssey to async rubyOdyssey to async ruby
Odyssey to async ruby
Delton Ding
?
Dev + DevOps էݧ PHP ٧ҧߧڧܧ
Dev + DevOps էݧ PHP ٧ҧߧڧܧDev + DevOps էݧ PHP ٧ҧߧڧܧ
Dev + DevOps էݧ PHP ٧ҧߧڧܧ
phpfriendsclub
?
Git - (a) Gentle InTroduction
Git - (a) Gentle InTroductionGit - (a) Gentle InTroduction
Git - (a) Gentle InTroduction
Bruno Bossola
?
PythonhBλA ĩ`α^
PythonhBλA ĩ`α^PythonhBλA ĩ`α^
PythonhBλA ĩ`α^
cocodrips
?
Coding in the context era
Coding in the context eraCoding in the context era
Coding in the context era
lestrrat
?
??? '????' Ch07 ?? ??
??? '????' Ch07 ?? ????? '????' Ch07 ?? ??
??? '????' Ch07 ?? ??
Covenant Ko
?
FIWARE Global Summit - FIROS: Helping Robots to be Context Aware
FIWARE Global Summit - FIROS: Helping Robots to be Context AwareFIWARE Global Summit - FIROS: Helping Robots to be Context Aware
FIWARE Global Summit - FIROS: Helping Robots to be Context Aware
FIWARE
?
A small introduction to rust language
A small introduction to rust languageA small introduction to rust language
A small introduction to rust language
Ahmad Hosseini
?
Mission ImpAnsible - NSM at (RobotFrame)work
Mission ImpAnsible - NSM at (RobotFrame)work Mission ImpAnsible - NSM at (RobotFrame)work
Mission ImpAnsible - NSM at (RobotFrame)work
Adam Przyby?a
?
Consuming API description languages - Refract & Minim
Consuming API description languages - Refract & MinimConsuming API description languages - Refract & Minim
Consuming API description languages - Refract & Minim
Jakub Nesetril
?
Infrastructure as code might be literally impossible
Infrastructure as code might be literally impossibleInfrastructure as code might be literally impossible
Infrastructure as code might be literally impossible
ice799
?
Infrastructure coders logstash
Infrastructure coders logstashInfrastructure coders logstash
Infrastructure coders logstash
David Lutz
?
Hacking Robotics(English Version)
Hacking Robotics(English Version)Hacking Robotics(English Version)
Hacking Robotics(English Version)
Kensei Demura
?
Geecon11 - Git: a Gentle InTroduction
Geecon11 -  Git: a Gentle InTroductionGeecon11 -  Git: a Gentle InTroduction
Geecon11 - Git: a Gentle InTroduction
Bruno Bossola
?
GIT: a Gentle InTroduction
GIT: a Gentle InTroductionGIT: a Gentle InTroduction
GIT: a Gentle InTroduction
Codemotion
?
8 Ways Network Engineers use Snabb (RIPE 77)
8 Ways Network Engineers use Snabb (RIPE 77)8 Ways Network Engineers use Snabb (RIPE 77)
8 Ways Network Engineers use Snabb (RIPE 77)
Igalia
?
٧ҧߧڧ ڧ ܧ ߧ Kotlin
  ٧ҧߧڧ ڧ ܧ ߧ Kotlin  ٧ҧߧڧ ڧ ܧ ߧ Kotlin
٧ҧߧڧ ڧ ܧ ߧ Kotlin
phpfriendsclub
?
TinkerPop and Titan from a Python State of Mind
TinkerPop and Titan from a  Python State of MindTinkerPop and Titan from a  Python State of Mind
TinkerPop and Titan from a Python State of Mind
Denise Gosnell, Ph.D.
?
Updates of socket.io@1.0
Updates of socket.io@1.0Updates of socket.io@1.0
Updates of socket.io@1.0
Jxck Jxck
?
Odyssey to async ruby
Odyssey to async rubyOdyssey to async ruby
Odyssey to async ruby
Delton Ding
?
Dev + DevOps էݧ PHP ٧ҧߧڧܧ
Dev + DevOps էݧ PHP ٧ҧߧڧܧDev + DevOps էݧ PHP ٧ҧߧڧܧ
Dev + DevOps էݧ PHP ٧ҧߧڧܧ
phpfriendsclub
?
Git - (a) Gentle InTroduction
Git - (a) Gentle InTroductionGit - (a) Gentle InTroduction
Git - (a) Gentle InTroduction
Bruno Bossola
?
PythonhBλA ĩ`α^
PythonhBλA ĩ`α^PythonhBλA ĩ`α^
PythonhBλA ĩ`α^
cocodrips
?
Coding in the context era
Coding in the context eraCoding in the context era
Coding in the context era
lestrrat
?
??? '????' Ch07 ?? ??
??? '????' Ch07 ?? ????? '????' Ch07 ?? ??
??? '????' Ch07 ?? ??
Covenant Ko
?
FIWARE Global Summit - FIROS: Helping Robots to be Context Aware
FIWARE Global Summit - FIROS: Helping Robots to be Context AwareFIWARE Global Summit - FIROS: Helping Robots to be Context Aware
FIWARE Global Summit - FIROS: Helping Robots to be Context Aware
FIWARE
?

Similar to Effortless network response logging on Android (20)

Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Tim Burks
?
OpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideOpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-Side
Tim Burks
?
LF_APIStrat17_OpenAPI and gRPC Side-by-Side
LF_APIStrat17_OpenAPI and gRPC Side-by-SideLF_APIStrat17_OpenAPI and gRPC Side-by-Side
LF_APIStrat17_OpenAPI and gRPC Side-by-Side
LF_APIStrat
?
Android internals 06 - Binder, Typical subsystem (rev_1.1)
Android internals 06 - Binder, Typical subsystem (rev_1.1)Android internals 06 - Binder, Typical subsystem (rev_1.1)
Android internals 06 - Binder, Typical subsystem (rev_1.1)
Egor Elizarov
?
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScript
Oleg Podsechin
?
Aplica??es realtime com gRPC
Aplica??es realtime com gRPCAplica??es realtime com gRPC
Aplica??es realtime com gRPC
Leandro Lugaresi
?
CocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIsCocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIs
Tim Burks
?
ORTC Library - Introduction
ORTC Library - IntroductionORTC Library - Introduction
ORTC Library - Introduction
Erik Lagerway
?
Welcome to Erlang
Welcome to ErlangWelcome to Erlang
Welcome to Erlang
Oleg Zinchenko
?
Erlang (GeekTalks)
Erlang (GeekTalks)Erlang (GeekTalks)
Erlang (GeekTalks)
Oleg Zinchenko
?
cReComp : Automated Design Tool for ROS-Compliant FPGA Component
cReComp : Automated Design Tool  for ROS-Compliant FPGA Component cReComp : Automated Design Tool  for ROS-Compliant FPGA Component
cReComp : Automated Design Tool for ROS-Compliant FPGA Component
Kazushi Yamashina
?
The Onward Journey: Porting Twisted to Python 3
The Onward Journey: Porting Twisted to Python 3The Onward Journey: Porting Twisted to Python 3
The Onward Journey: Porting Twisted to Python 3
Craig Rodrigues
?
Modern webservices using gRPC and Protocol Buffers in Golang
Modern webservices using gRPC and Protocol Buffers in GolangModern webservices using gRPC and Protocol Buffers in Golang
Modern webservices using gRPC and Protocol Buffers in Golang
OmidHojabri1
?
Developing Rich Internet Applications with Perl and JavaScript
Developing Rich Internet Applications with Perl and JavaScriptDeveloping Rich Internet Applications with Perl and JavaScript
Developing Rich Internet Applications with Perl and JavaScript
nohuhu
?
Orion RESTful git API
Orion RESTful git APIOrion RESTful git API
Orion RESTful git API
Tomasz Zarna
?
The Go features I can't live without, 2nd round
The Go features I can't live without, 2nd roundThe Go features I can't live without, 2nd round
The Go features I can't live without, 2nd round
Rodolfo Carvalho
?
Google Protocol Buffers + gRPC
Google Protocol Buffers + gRPCGoogle Protocol Buffers + gRPC
Google Protocol Buffers + gRPC
Imal hasaranga
?
Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022
QAware GmbH
?
Kernel load-balancing for Docker containers using IPVS
Kernel load-balancing for Docker containers using IPVSKernel load-balancing for Docker containers using IPVS
Kernel load-balancing for Docker containers using IPVS
Docker, Inc.
?
gRPC ?????? ??? ???? ??? - ???2020
gRPC ?????? ??? ???? ???  - ???2020gRPC ?????? ??? ???? ???  - ???2020
gRPC ?????? ??? ???? ??? - ???2020
?? ?
?
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Tim Burks
?
OpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-SideOpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-Side
Tim Burks
?
LF_APIStrat17_OpenAPI and gRPC Side-by-Side
LF_APIStrat17_OpenAPI and gRPC Side-by-SideLF_APIStrat17_OpenAPI and gRPC Side-by-Side
LF_APIStrat17_OpenAPI and gRPC Side-by-Side
LF_APIStrat
?
Android internals 06 - Binder, Typical subsystem (rev_1.1)
Android internals 06 - Binder, Typical subsystem (rev_1.1)Android internals 06 - Binder, Typical subsystem (rev_1.1)
Android internals 06 - Binder, Typical subsystem (rev_1.1)
Egor Elizarov
?
The future of server side JavaScript
The future of server side JavaScriptThe future of server side JavaScript
The future of server side JavaScript
Oleg Podsechin
?
CocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIsCocoaConf: The Language of Mobile Software is APIs
CocoaConf: The Language of Mobile Software is APIs
Tim Burks
?
ORTC Library - Introduction
ORTC Library - IntroductionORTC Library - Introduction
ORTC Library - Introduction
Erik Lagerway
?
cReComp : Automated Design Tool for ROS-Compliant FPGA Component
cReComp : Automated Design Tool  for ROS-Compliant FPGA Component cReComp : Automated Design Tool  for ROS-Compliant FPGA Component
cReComp : Automated Design Tool for ROS-Compliant FPGA Component
Kazushi Yamashina
?
The Onward Journey: Porting Twisted to Python 3
The Onward Journey: Porting Twisted to Python 3The Onward Journey: Porting Twisted to Python 3
The Onward Journey: Porting Twisted to Python 3
Craig Rodrigues
?
Modern webservices using gRPC and Protocol Buffers in Golang
Modern webservices using gRPC and Protocol Buffers in GolangModern webservices using gRPC and Protocol Buffers in Golang
Modern webservices using gRPC and Protocol Buffers in Golang
OmidHojabri1
?
Developing Rich Internet Applications with Perl and JavaScript
Developing Rich Internet Applications with Perl and JavaScriptDeveloping Rich Internet Applications with Perl and JavaScript
Developing Rich Internet Applications with Perl and JavaScript
nohuhu
?
Orion RESTful git API
Orion RESTful git APIOrion RESTful git API
Orion RESTful git API
Tomasz Zarna
?
The Go features I can't live without, 2nd round
The Go features I can't live without, 2nd roundThe Go features I can't live without, 2nd round
The Go features I can't live without, 2nd round
Rodolfo Carvalho
?
Google Protocol Buffers + gRPC
Google Protocol Buffers + gRPCGoogle Protocol Buffers + gRPC
Google Protocol Buffers + gRPC
Imal hasaranga
?
Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022Cloud native IPC for Microservices Workshop @ Containerdays 2022
Cloud native IPC for Microservices Workshop @ Containerdays 2022
QAware GmbH
?
Kernel load-balancing for Docker containers using IPVS
Kernel load-balancing for Docker containers using IPVSKernel load-balancing for Docker containers using IPVS
Kernel load-balancing for Docker containers using IPVS
Docker, Inc.
?
gRPC ?????? ??? ???? ??? - ???2020
gRPC ?????? ??? ???? ???  - ???2020gRPC ?????? ??? ???? ???  - ???2020
gRPC ?????? ??? ???? ??? - ???2020
?? ?
?

Effortless network response logging on Android