Caps-iOS/CapCollector/Logger.swift

43 lines
785 B
Swift
Raw Normal View History

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 {
static var logToken: String { get }
}
extension Logger {
func error(_ message: String) {
2019-04-12 13:45:31 +02:00
Self.addToFile(Self.logToken + " ERROR: " + message)
2019-03-15 13:19:19 +01:00
}
func event(_ message: String) {
2019-04-12 13:45:31 +02:00
Self.addToFile(Self.logToken + " " + message)
2019-03-15 13:19:19 +01:00
}
static func error(_ message: String) {
2019-04-12 13:45:31 +02:00
addToFile(logToken + " ERROR: " + message)
2019-03-15 13:19:19 +01:00
}
static func event(_ message: String) {
2019-04-12 13:45:31 +02:00
addToFile(logToken + " " + message)
}
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 = ""