Skip to content

Instantly share code, notes, and snippets.

@maysamsh
Created July 21, 2020 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maysamsh/9a71815b088adee33c47d22c921b384d to your computer and use it in GitHub Desktop.
Save maysamsh/9a71815b088adee33c47d22c921b384d to your computer and use it in GitHub Desktop.
//
// 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