2019-03-15 13:19:19 +01:00
|
|
|
//
|
|
|
|
// Logger.swift
|
|
|
|
// CapFinder
|
|
|
|
//
|
|
|
|
// Created by User on 11.04.18.
|
|
|
|
// Copyright © 2018 User. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
protocol Logger {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
extension Logger {
|
2020-05-16 11:21:55 +02:00
|
|
|
|
|
|
|
static var logToken: String {
|
|
|
|
"[" + String(describing: self) + "] "
|
|
|
|
}
|
2019-03-15 13:19:19 +01:00
|
|
|
|
|
|
|
func error(_ message: String) {
|
2020-05-16 11:21:55 +02:00
|
|
|
Self.addToFile(Self.logToken + "ERROR: " + message)
|
2019-03-15 13:19:19 +01:00
|
|
|
}
|
|
|
|
|
2020-05-16 11:21:55 +02:00
|
|
|
func log(_ message: String) {
|
|
|
|
Self.addToFile(Self.logToken + message)
|
2019-03-15 13:19:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static func error(_ message: String) {
|
2020-05-16 11:21:55 +02:00
|
|
|
addToFile(logToken + "ERROR: " + message)
|
2019-03-15 13:19:19 +01:00
|
|
|
}
|
|
|
|
|
2020-05-16 11:21:55 +02:00
|
|
|
static func log(_ message: String) {
|
|
|
|
addToFile(logToken + message)
|
2019-04-12 13:45:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static func addToFile(_ message: String) {
|
|
|
|
logFile += "\n" + message
|
|
|
|
print(message)
|
2019-03-15 13:19:19 +01:00
|
|
|
}
|
|
|
|
}
|
2019-04-12 13:45:31 +02:00
|
|
|
|
|
|
|
private(set) var logFile: String = ""
|
|
|
|
|