Skip to content

Commit

Permalink
Merge pull request #530 from WillSuo-Github/patch-1
Browse files Browse the repository at this point in the history
Update README.md to demonstrate enabling OSLog printing in Xcode 15.
  • Loading branch information
skreutzberger committed May 21, 2024
2 parents 8cba041 + 43fa8fb commit 8a8eea6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@

### During Development: Colored Logging to Xcode Console

<img src="https://cloud.githubusercontent.com/assets/564725/18608323/ac065a98-7ce6-11e6-8e1b-2a062d54a1d5.png" width="608">
<img width="924" alt="image" src="https://github.com/SwiftyBeaver/SwiftyBeaver/assets/15070906/418a6a70-ced4-4000-91c3-8dc8fc235b7c">


#### In Xcode 15
```Swift
let console = ConsoleDestination()
// Note, this method relies on the OSLog API. If you do not want to use it, please replace it with .print.
console.logPrintWay = .logger(subsystem: "Main", category: "UI")
```
#### In Xcode 8
[Learn more](http://docs.swiftybeaver.com/article/9-log-to-xcode-console) about colored logging to Xcode 8 Console with Swift 3, 4 & 5. For Swift 2.3 [use this Gist](https://gist.github.com/skreutzberger/7c396573796473ed1be2c6d15cafed34). **No need to hack Xcode 8 anymore** to get color. You can even customize the log level word (ATTENTION instead of ERROR maybe?), the general amount of displayed data and if you want to use the 💜s or replace them with something else 😉

<br/>
Expand Down Expand Up @@ -138,6 +146,11 @@ let file = FileDestination() // log to default swiftybeaver.log file
console.format = "$DHH:mm:ss$d $L $M"
// or use this for JSON output: console.format = "$J"

// In Xcode 15, specifying the logging method as .logger to display color, subsystem, and category information in the console.(Relies on the OSLog API)
console.logPrintWay = .logger(subsystem: "Main", category: "UI")
// If you prefer not to use the OSLog API, you can use print instead.
// console.logPrintWay = .print

// add the destinations to SwiftyBeaver
log.addDestination(console)
log.addDestination(file)
Expand Down

0 comments on commit 8a8eea6

Please sign in to comment.