View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Debug with structured logging

    Discover the debug console in Xcode 15 and learn how you can improve your diagnostic experience through logging. Explore how you can navigate your logs easily and efficiently using advanced filtering and improved visualization. We'll also show you how to use the dwim-print command to evaluate expressions in your code while debugging.

    Chapitres

    • 0:44 - Tour of the Debug Console
    • 3:28 - Live debugging
    • 7:25 - LLDB improvements
    • 9:04 - Tips for logging
    • 12:04 - Get the most out of your logging

    Ressources

    • Logging
      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC23

    • What’s new in Xcode 15

    WWDC20

    • Explore logging in Swift

    WWDC18

    • Measuring Performance Using Logging
  • Rechercher dans cette vidéo…
    • 5:17 - Calling setDisplayName from Edit Account page

      .onSubmit {
          logger.info("Requesting to change displayName to \(displayName)")
          accountViewModel.setDisplayName(displayName)
      }
    • 5:34 - Account Data Setters (Before Fix)

      public func setDisplayName(_ newDisplayName: String) {
          logger.info("Sending Request to update DisplayName")
      
          Database.setValueForKey(Database.Key.displayName, value: newDisplayName, forAccount: account.id)
      
          logger.info("Updated DisplayName to '\(newDisplayName)'")
      }
      
      public func setEmailAddressName(_ newEmailAddress: String) {
          logger.info("Sending Request to update EmailAddress")
      
          Database.setValueForKey(Database.Key.emailAddress, value: newEmailAddress, forAccount: account.id)
      
          logger.info("Updated EmailAddress to '\(newEmailAddress)'")
      }
    • 6:04 - Account Data Setters (After Fix)

      public func setDisplayName(_ newDisplayName: String) {
          logger.info("Sending Request to update DisplayName")
      
          Database.setValueForKey(Database.Key.displayName, value: newDisplayName, forAccount: account.id)
      
          account.displayName = newDisplayName
      
          logger.info("Updated DisplayName to '\(newDisplayName)'")
      }
      
      public func setEmailAddressName(_ newEmailAddress: String) {
          logger.info("Sending Request to update EmailAddress")
      
          Database.setValueForKey(Database.Key.emailAddress, value: newEmailAddress, forAccount: account.id)
      
          account.emailAddress = newEmailAddress
      
          logger.info("Updated EmailAddress to '\(newEmailAddress)'")
      }
    • 6:35 - po account

      (lldb) po account
    • 6:39 - po account (with result)

      (lldb) po account
      <Account: 0x60000223b2a0>
    • 7:00 - p account

      (lldb) p account
    • 7:04 - po account (with result)

      (lldb) p account
      (BackyardBirdsData.Account) =0x000060000223b2a0 {
      	id = 3A9FC684-8DFC-4D7D-B645-E393AEBA14EE
      	joinDate = 2023-06-05 16:41:00 UTC
      	displayName = "Sample Account"
      	emailAddress = "sample_account@icloud.com"
      	isPremiumMember = true
      }
    • 7:18 - p account (after fix)

      (lldb) p account
      (BackyardBirdsData.Account) =0x000060000223b2a0 {
      	id = 3A9FC684-8DFC-4D7D-B645-E393AEBA14EE
      	joinDate = 2023-06-05 16:41:00 UTC
      	displayName = "Johnny Appleseed"
      	emailAddress = "johnny_appleseed@icloud.com"
      	isPremiumMember = true
      }
    • 9:43 - Login Method Skeleton

      func login(password: String) -> Error? {
          var error: Error? = nil
      
          //...
      
          loggedIn = true
          return error
      }
    • 9:56 - Login Method with Print Statements

      func login(password: String) -> Error? {
          var error: Error? = nil
          print("Logging in user '\(username)'...")
      
          …
      
          if let error {
              print("User '\(username)' failed to log in. Error: \(error)")
          } else {
              loggedIn = true
              print("User '\(username)' logged in successfully.")
          }
          return error
      }
    • 10:18 - Login Method with Extended Print Statements

      func login(password: String) -> Error? {
          var error: Error? = nil
          print("🤖 Logging in user '\(username)'... (\(#file):\(#line))")
      
          //...
      
          if let error {
              print("🤖 User '\(username)' failed to log in. Error: \(error) (\(#file):\(#line))")
          } else {
              loggedIn = true
              print("🤖 User '\(username)' logged in successfully. (\(#file):\(#line))")
          }
          return error
      }
    • 10:40 - Login Method with Partial OSLog Transition

      import OSLog
      
      let logger = Logger(subsystem: "BackyardBirdsData", category: "Account")
      
      func login(password: String) -> Error? {
          var error: Error? = nil
          print("🤖 Logging in user '\(username)'... (\(#file):\(#line))")
      
          //...
      
          if let error {
              print("🤖 User '\(username)' failed to log in. Error: \(error) (\(#file):\(#line))")
          } else {
              loggedIn = true
              print("🤖 User '\(username)' logged in successfully. (\(#file):\(#line))")
          }
          return error
      }
    • 11:00 - Login Method with OSLog Statements

      import OSLog
      
      let logger = Logger(subsystem: "BackyardBirdsData", category: "Account")
      
      func login(password: String) -> Error? {
          var error: Error? = nil
          logger.info("Logging in user '\(username)'...")
      
          //...
      
          if let error {
              logger.error("User '\(username)' failed to log in. Error: \(error)")
          } else {
              loggedIn = true
              logger.notice("User '\(username)' logged in successfully.")
          }
          return error
      }
    • 11:16 - Example Logging Statements

      let logger = Logger(subsystem: "BackyardBirdsData", category: "Account")
      logger.error("User '\(username)' failed to log in. Error: \(error)")
      logger.notice("User '\(username)' logged in successfully.")

Developer Footer

  • Vidéos
  • WWDC23
  • Debug with structured logging
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines