Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//
// ConsoleLogger.swift
//
// Created by Maysam Shahsavari on 2020-07-20.
// Copyright © 2020 Maysam Shahsavari. All rights reserved.
//
import Foundation
struct ConsoleLogger {
static func log(_ error: Error, file: String = #file, function: String = #function, line: Int = #line) {
let fileURL = URL.init(fileURLWithPath: file)
let pathExtention = fileURL.pathExtension
let fileName = "\(URL(fileURLWithPath: file).deletingPathExtension().lastPathComponent).\(pathExtention)"
print("**** Error in \(fileName), \(function) line #\(line): \(error.localizedDescription)")
}
static func log(_ message: String, file: String = #file, function: String = #function, line: Int = #line) {
let fileURL = URL.init(fileURLWithPath: file)
let pathExtention = fileURL.pathExtension
let fileName = "\(URL(fileURLWithPath: file).deletingPathExtension().lastPathComponent).\(pathExtention)"
print("**** Error in \(fileName), \(function) line #\(line): \(message)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment