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
Unified Logging
Search
Jelle Vandebeeck
December 21, 2018
Technology
0
1.7k
Unified Logging
Jelle Vandebeeck
December 21, 2018
Tweet
Share
More Decks by Jelle Vandebeeck
See All by Jelle Vandebeeck
RubyMotion
fousa
1
92
Git
fousa
1
140
Heroku
fousa
0
140
Cappuccino
fousa
0
120
Other Decks in Technology
See All in Technology
The Rise of LLMOps
asei
9
1.9k
OCI Security サービス 概要
oracle4engineer
PRO
0
6.6k
Terraform Stacks入門 #HashiTalks
msato
0
370
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
600
SRE×AIOpsを始めよう!GuardDutyによるお手軽脅威検出
amixedcolor
1
240
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
120
OOM発生時のトラブルシューティング Profilerを活用できるか調査してみた
atsushii
0
110
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
7
720
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.8k
心が動くエンジニアリング ── 私が夢中になる理由
16bitidol
0
120
初心者向けAWS Securityの勉強会mini Security-JAWSを9ヶ月ぐらい実施してきての近況
cmusudakeisuke
0
150
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
3
370
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
38
7.1k
How to train your dragon (web standard)
notwaldorf
88
5.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Bash Introduction
62gerente
608
210k
The World Runs on Bad Software
bkeepers
PRO
65
11k
What's in a price? How to price your products and services
michaelherold
243
12k
Statistics for Hackers
jakevdp
796
220k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Transcript
UNIFIED LOGGING JELLE VANDEBEECK / ICAPPS 1
Why? ๏ Improved debugging during development ๏ Track down crashes
in asynchronous code ๏ Improved privacy JELLE VANDEBEECK / ICAPPS 2
Legacy NSLog(@"Hello!") asl_log_message syslog JELLE VANDEBEECK / ICAPPS 3
Legacy ๏ Visible in Xcode ๏ Visible in the Console.app
application JELLE VANDEBEECK / ICAPPS 4
Swift print("Hello!") ๏ Visible in Xcode ๏ Not visible in
the Console.app application JELLE VANDEBEECK / ICAPPS 5
New API Exists since iOS 10... ! JELLE VANDEBEECK /
ICAPPS 6
os_log import os os_log(.debug, "Hello") os_log(.info, "Hello") os_log(.default, "Hello") os_log(.error,
"Hello") os_log(.fault, "Hello") JELLE VANDEBEECK / ICAPPS 7
Logging Levels Level Enabled Initially stored On bu!er full Debug
! ! ! Info ✅ Memory ! 1 Default ✅ Memory Disk Error ✅ Disk Disk Fault ✅ Disk Disk 1 Except when an error occurs JELLE VANDEBEECK / ICAPPS 8
To disk ๏ You can find a .tracev3 file that
contains the logs inside of /var/db/diagnostics. ๏ Data stores instead of text-based files. ๏ When date storage is exceeded oldest messages are purged JELLE VANDEBEECK / ICAPPS 9
Usage ๏ Level: Debug ๏ High volume debugging during development
๏ Console.app: ⚫ JELLE VANDEBEECK / ICAPPS 10
Usage ๏ Level: Info ๏ Additional info that will be
captured during an error or faultent ๏ Console.app: ⚪ JELLE VANDEBEECK / ICAPPS 11
Usage ๏ Level: Default ๏ Log critical details to help
debug issues ๏ Console.app: N/A JELLE VANDEBEECK / ICAPPS 12
Usage ๏ Level: Error ๏ Additional information capture from the
app ๏ Console.app: ! JELLE VANDEBEECK / ICAPPS 13
Usage ๏ Level: Fault ๏ Additional information capture from the
system ๏ Console.app: ! JELLE VANDEBEECK / ICAPPS 14
Subsystem & Category let logger = OSLog(subsystem: "com.icapps.logging", category: "Monkey")
os_log("Hello ! ", log: logger) JELLE VANDEBEECK / ICAPPS 15
Privacy ๏ Prevents accidental leak of Personally Identifiable Information ๏
Replaces dynamic strings, collections, arrays with a <private> keyword JELLE VANDEBEECK / ICAPPS 16
Privacy ๏ Primitive types are public by default, but can
be made private with the <public> keyword JELLE VANDEBEECK / ICAPPS 17
Privacy let name: String = "Jake" os_log("Hi \(name)") // !
os_log("Hi %@", name) // Hi <private> os_log("Hi %{public}@", name) // Hi Jake os_log("Hi %{private}d", someNumber) // Hi <private> JELLE VANDEBEECK / ICAPPS 18
Formatters os_log("Time: %{time_t}d", timeInterval) // 2016-01-12 19:41:37 os_log("UUID: %{uuid_t}.16P", uuid)
// 2F6B8A25-A539-4320-A416-83649B8D50BC os_log("IPv4: %{network:in_addr}.16P", address) // 17.43.23.87 JELLE VANDEBEECK / ICAPPS 19
DEMO ! JELLE VANDEBEECK / ICAPPS 20
Overview ๏ Automatic formatting ๏ Automatic collecting file / function
/ line information ๏ Huge performance improvement compared to NSLog JELLE VANDEBEECK / ICAPPS 21
Overview ๏ Improved security ๏ Improved filtertering in the Console.app
JELLE VANDEBEECK / ICAPPS 22
Best practices ๏ Keep the logs compact ๏ Use the
formatters provided by Apple ๏ Don't wrap os_log in other functions ๏ Avoid dictionaries or arrays JELLE VANDEBEECK / ICAPPS 23
Activities JELLE VANDEBEECK / ICAPPS 24
Activities ๏ What happens in async code ๏ Track down
crashes ๏ Shows a clean trace in the Console.app JELLE VANDEBEECK / ICAPPS 25
Activities os_activity_create(...) ๏ Creates an activity ๏ Can be added
to the current activity with OS_ACTIVITY_CURRENT JELLE VANDEBEECK / ICAPPS 26
Scope if(...) { os_activity_scope(...) os_log(...) } JELLE VANDEBEECK / ICAPPS
27
Apply os_activity_apply(activity, ^{ os_log(...) }) JELLE VANDEBEECK / ICAPPS 28
Activity in Swift Should be bridged from Obj-C 2 !
2 Luckely someone create a wrapper that can easily be used in Swift JELLE VANDEBEECK / ICAPPS 29
DEMO ! JELLE VANDEBEECK / ICAPPS 30
References ๏ WWDC 2016 Session ๏ Bridged Activity Gist ๏
Unified Logging and Activity Tracing ๏ Activity Tracing JELLE VANDEBEECK / ICAPPS 31