Skip to content

Commit

Permalink
Fix #4: add example of a conditional log
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira committed Dec 2, 2016
1 parent 60bf20b commit 5b4bfb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Example/WSLoggerExample/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@ private func logEntry(message: String, level: LogLevel = .Debug, customAttribute
func logEntry(identifier: String, message: String, level: LogLevel, className: String = "", fileName: NSString = #file, line: Int = #line, function: String = #function) {
logEntry(message, level: level, customAttributes: ["ID": identifier], className: className, fileName: fileName, line: line, function: function)
}

func logEntryIf(condition: Bool, message: String, level: LogLevel, className: String = "", fileName: NSString = #file, line: Int = #line, function: String = #function) {
if !condition {
return
}
logEntry(message, level: level, className: className, fileName: fileName, line: line, function: function)
}
2 changes: 2 additions & 0 deletions Example/WSLoggerExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class ViewController: UIViewController, Loggable {
super.viewDidLoad()
log("Test using Loggable")
logEntry(NSUUID().UUIDString, message: "App has started", level: .Info)
logEntryIf(true, message: "App is not ready", level: .Warning)
logEntryIf(false, message: "App is ready", level: .Warning)
}

class func register() {
Expand Down

0 comments on commit 5b4bfb1

Please sign in to comment.