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
滅・サービスクラス🔥 / Destruction Service Class
sinsoku
6
1.6k
CZII - CryoET Object Identification 参加振り返り・解法共有
tattaka
0
310
地方拠点で エンジニアリングマネージャーってできるの? 〜地方という制約を楽しむオーナーシップとコミュニティ作り〜
1coin
1
220
ユーザーストーリーマッピングから始めるアジャイルチームと並走するQA / Starting QA with User Story Mapping
katawara
0
170
次世代KYC活動報告 / 20250219-BizDay17-KYC-nextgen
oidfj
0
150
関東Kaggler会LT: 人狼コンペとLLM量子化について
nejumi
3
540
30分でわかる『アジャイルデータモデリング』
hanon52_
9
2.5k
技術負債の「予兆検知」と「状況異変」のススメ / Technology Dept
i35_267
1
1k
モノレポ開発のエラー、誰が見る?Datadog で実現する適切なトリアージとエスカレーション
biwashi
6
790
現場の種を事業の芽にする - エンジニア主導のイノベーションを事業戦略に装着する方法 -
kzkmaeda
2
1.8k
利用終了したドメイン名の最強終活〜観測環境を育てて、分析・供養している件〜 / The Ultimate End-of-Life Preparation for Discontinued Domain Names
nttcom
1
120
サーバーレスアーキテクチャと生成AIの融合 / Serverless Meets Generative AI
_kensh
12
3.1k
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
550
We Have a Design System, Now What?
morganepeng
51
7.4k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
Music & Morning Musume
bryan
46
6.3k
Designing Experiences People Love
moore
139
23k
Side Projects
sachag
452
42k
Building Adaptive Systems
keathley
40
2.4k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.4k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
6
240
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.3k
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