Avatar ·

Swift: print() vs println() vs NSLog() — what to choose for logging?

Hello everyone! I'm a beginner iOS developer writing my first app in Swift. I've encountered that several different functions can be used to output messages to the console: `print()`, `println()`, and `NSLog()`. I've already seen that `println()` seems to be deprecated, but it still appears in old tutorials. Currently, I use `print()` for debugging, but I noticed that when I write: ```swift print("User logged in") ``` Only the string is printed to the console. But when a colleague showed me `NSLog`: ```swift NSLog("User logged in") ``` It includes the date, time, process name, and PID. Is this convenient for production? Or is it better not to use `NSLog` at all due to performance? I've also heard about `os_log` from the `os.log` framework, but I don't understand why it's needed if `print()` works fine. Please explain the difference between these approaches and which one is best to use in modern projects? It's important for me to understand not just the syntax, but also when to apply each tool.