Features -
- You can different level for log DEBUG,INFO,ERROR,EXCEPTION,WARNING
- You can configure it for DEBUG, RELEASE or any configurations
- You can configure statements for console logging.
- You can use file logger.
- You can configure statements for file logger.
- you can configure timestamp, filename, function name and line to be added or not
How to use this logger ?
STEP 1
Just add following files to you project
YBLogger.swift
YBLoggerConfiguration.swift
YBFileLogger.swift
STEP 2
let employee = ["name":"Alex","empId":123] as [String : Any]
print("One operation is completed.",logLevel:.DEBUG)
print("Operation ",logLevel:.INFO)
print("Divide by zero error",logLevel:.ERROR)
print("Could not able to read the data.",logLevel:.EXCEPTION)
print("Only three items are left.",logLevel:.WARNING)
print(employee,logLevel:.DEBUG)
print(10,logLevel:.WARNING)
print(employee,10,employee,55,logLevel:.DEBUG)
OUTPUT
🔹 DEBUG ➯ 2017-07-23T13:43:57.135Z ⇨ ViewController ⇨ viewDidLoad() : 17 ⇨ One operation is completed.
🔸 INFO ➯ 2017-07-23T13:43:57.152Z ⇨ ViewController ⇨ viewDidLoad() : 18 ⇨ Operation
🚫 ERROR ➯ 2017-07-23T13:43:57.226Z ⇨ ViewController ⇨ viewDidLoad() : 19 ⇨ Divide by zero error
❗️ EXCEPTION ➯ 2017-07-23T13:43:57.226Z ⇨ ViewController ⇨ viewDidLoad() : 20 ⇨ Could not able to read the data.
🔹 DEBUG ➯ ViewController ⇨ viewDidLoad() : 17 ⇨ One operation is completed.
🔸 INFO ➯ ViewController ⇨ viewDidLoad() : 18 ⇨ Operation
🚫 ERROR ➯ ViewController ⇨ viewDidLoad() : 19 ⇨ Divide by zero error
❗️ EXCEPTION ➯ ViewController ⇨ viewDidLoad() : 20 ⇨ Could not able to read the data.
🔹 DEBUG ➯ ViewController ⇨ viewDidLoad() : 22 ⇨ ["name": "Alex", "empId": 123]
🔹 DEBUG ➯ ViewController ⇨ viewDidLoad() : 24 ⇨ ["name": "Alex", "empId": 123] 10 ["name": "Alex", "empId": 123] 55
🔹 DEBUG ➯ viewDidLoad() : 17 ⇨ One operation is completed.
🔸 INFO ➯ viewDidLoad() : 18 ⇨ Operation
🚫 ERROR ➯ viewDidLoad() : 19 ⇨ Divide by zero error
❗️ EXCEPTION ➯ viewDidLoad() : 20 ⇨ Could not able to read the data.
🔹 DEBUG ➯ viewDidLoad() : 22 ⇨ ["name": "Alex", "empId": 123]
🔹 DEBUG ➯ viewDidLoad() : 24 ⇨ ["name": "Alex", "empId": 123] 10 ["name": "Alex", "empId": 123] 55
For more detail visit my blog. http://swiftlearningbyyogesh.blogspot.com/2017/07/simple-loggerconsole-and-file-for-swift.html