Caps-Server/Sources/App/Log.swift

21 lines
428 B
Swift
Raw Normal View History

2020-05-19 15:19:19 +02:00
//
// Log.swift
// App
//
// Created by Christoph on 05.05.20.
//
import Foundation
private let df: DateFormatter = {
let df = DateFormatter()
df.dateStyle = .short
df.timeStyle = .short
return df
}()
func log(_ message: String, file: String = #file, line: Int = #line) {
let date = df.string(from: Date())
print("[\(date)][\(file.components(separatedBy: "/").last ?? file):\(line)] \(message)")
}