Questions tagged [oslog]

41 questions
560
votes
6 answers

Swift: print() vs println() vs NSLog()

What's the difference between print, NSLog and println and when should I use each? For example, in Python if I wanted to print a dictionary, I'd just print myDict, but now I have 2 other options. How and when should I use each?
User
  • 23,729
  • 38
  • 124
  • 207
39
votes
4 answers

Xcode logging: "Metal API Validation Enabled"

I'm building a macOS app via Xcode. Every time I build, I get the log output: Metal API Validation Enabled To my knowledge my app is not using any Metal features. I'm not using hardware-accelerated 3D graphics or shaders or video game features or…
pkamb
  • 33,281
  • 23
  • 160
  • 191
22
votes
1 answer

Apple Recommended Logging approach for Swift

Note: This is not a duplicate of the linked questions Goal: I am not looking for a print vs NSLog differences In fact I don't want to use either of them (presently using print) I am looking for an Apple recommended way, just can't seem to find the…
user1046037
  • 16,755
  • 12
  • 92
  • 138
19
votes
2 answers

Xcode 12 and OSLog (os.log): wrapping OSLogMessage causes compile error: Argument must be a string interpolation

In Xcode 12 / iOS 14, OSLog gained support for string interpolation (yay!). But it's still not possible to attach hooks to easily log to other channels, such as Crashlytics. So I figured I'll just make a simple wrapper and pass on the parameters.…
Kevin R
  • 8,230
  • 4
  • 41
  • 46
18
votes
3 answers

Apple iPhone - debugging with console - ?

I'm using Console to debug iPhone 7 I am seeing on most information. I am able to access Xcode simulator iPhone 7 device which does not show . However I need to debug a passkit pass on the phone. I think my devices development…
user8518780
15
votes
4 answers

How to write Application Logs to File and get them

I´m taking baby steps in iOS development and searching for a method to use logging in iOS. I found these docs about logging with swift 3 : https://developer.apple.com/documentation/os/logging#1682426 The Docs say that the logs aren´t saved on disk.…
Offset
  • 609
  • 1
  • 5
  • 22
13
votes
5 answers

Using os_log to log function arguments, or other dynamic data

I'm trying to log function arguments into os_log like this: func foo(x: String, y: [String:String]) { //... os_log("foo: \(x) \(y.description)", log: OSLog.default, type: .debug) } But getting error: Cannot convert value of type 'String'…
timbre timbre
  • 12,648
  • 10
  • 46
  • 77
9
votes
1 answer

What is os.log for?

I am going through a few Swift tutorials on how to build simple apps, as I am just starting to code. I want to make my app iOS 9 compatible, as I have an iPad 3. However, all the os.log statements generate an error in Xcode which tells me to add an…
TonyStark4ever
  • 848
  • 1
  • 9
  • 24
9
votes
3 answers

How can I retrieve messages logged with os_log from iPad/iPhone?

I am using the new Unified Logging API in Swift. So I create a logger and use it as below: let testLogger = OSLog(subsystem: "my.subsystem", category: "test") os_log("just a test: %@", log: testLogger, type: .error, "error") How can I retrieve the…
jair.jr
  • 597
  • 1
  • 7
  • 13
8
votes
0 answers

Is there a way to make interpolated strings public by default when using Swift Logger?

In Swift, I use code like this: let logger = Logger() let someInfo = "information" logger.warning("blah: \(someInfo)") but the console output shows: blah: \ unless I change the final line to: logger.warning("blah: \(someInfo, privacy:…
Kem Mason
  • 1,548
  • 17
  • 26
7
votes
2 answers

How do I view logs from a REMOTE iOS device using the unified logging system?

First, it's important to know that, OSLogStore didn't work in iOS as recently as 4 months ago. Since that's so recent and documentation is so sparse, what may have been true a year ago may not be true today. Here's some context to my question…
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
6
votes
0 answers

Enable debug logging through OSLog

I've set up logging through OSLog in my iOS App, and I've added a button to export logs with OSLogStore: extension OSLog { private static let subsystem = Bundle.main.bundleIdentifier! @available(iOS 15.0, *) static func…
Nick
  • 3,958
  • 4
  • 32
  • 47
6
votes
1 answer

os_log - use of unresolved identifier error

I'm trying to use the new os_log API, by logging a simple statement: os_log("Hello") And I get an error for os_log: Use of unresolved identifier 'os_log' I also tried wrapping it in a block, like this if #available(iOS 10.0, *) { let foo:…
Sheamus
  • 6,506
  • 3
  • 35
  • 61
5
votes
1 answer

How to use Console.app to view debug-level logs from os_log from an iOS app running in the Simulator?

This is a question about how to use Apple's Unified Logging framework, also known as "os_log", the function you call from Swift. Specifically, I want to know if it is possible: to view logs in Console.app (not with the log command line tool) ... to…
algal
  • 27,584
  • 13
  • 78
  • 80
5
votes
2 answers

How can I disable a certain oslog log level?

For the following function: let authenticationLogger = OSLog(subsystem: "com.Company.AppNameQA" ?? "Empty bundleIdentifier", category: "Authenticaiton) What should I do if I want to disable/enable a certain log level? Currently with the API the…
mfaani
  • 33,269
  • 19
  • 164
  • 293
1
2 3