Created
July 21, 2020 13:30
-
-
Save maysamsh/9a71815b088adee33c47d22c921b384d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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