-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
35 changed files
with
1,550 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,9 @@ | |
|
||
Pod::Spec.new do |s| | ||
s.name = 'CSwiftLog' | ||
s.version = '0.1.0' | ||
s.summary = 'A short description of CSwiftLog.' | ||
s.version = '1.0.0' | ||
s.summary = 'Logger for Xcode' | ||
s.swift_version = '5.0' | ||
|
||
# This description is used to generate tags and improve search results. | ||
# * Think: What does it do? Why did you write it? What is the focus? | ||
|
@@ -21,11 +22,11 @@ Pod::Spec.new do |s| | |
TODO: Add long description of the pod here. | ||
DESC | ||
|
||
s.homepage = 'https://github.com/Andrew/CSwiftLog' | ||
s.homepage = 'https://github.com/andrewfirsenko/CSwiftLog' | ||
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' | ||
s.license = { :type => 'MIT', :file => 'LICENSE' } | ||
s.author = { 'Andrew' => '[email protected]' } | ||
s.source = { :git => 'https://github.com/Andrew/CSwiftLog.git', :tag => s.version.to_s } | ||
s.author = { 'Andrew Firsenko' => '[email protected]' } | ||
s.source = { :git => 'https://github.com/andrewfirsenko/CSwiftLog.git', :tag => s.version.to_s } | ||
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>' | ||
|
||
s.ios.deployment_target = '9.0' | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Log+Extensions.swift | ||
// SwiftLog | ||
// | ||
// Created by Andrew on 04.10.2021. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Log { | ||
|
||
internal static func time(date: Date = Date(), style: Log.LogStyle = .short) -> String { | ||
let df = DateFormatter() | ||
switch style { | ||
case .full: | ||
df.dateFormat = "HH:mm:ss.SSS" | ||
case .short: | ||
df.dateFormat = "HH:mm:ss.SSS" | ||
} | ||
return df.string(from: date) | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// | ||
// Log.swift | ||
// SwiftLog | ||
// | ||
// Created by Andrew on 05.10.2021. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Log { | ||
|
||
// Default categories | ||
public static let ui = Log(category: "UI") | ||
public static let network = Log(category: "NETWORK") | ||
|
||
public enum LogType: String { | ||
case error = "📕" | ||
case warning = "📙" | ||
case success = "📗" | ||
case info = "📘" | ||
case canceled = "📓" | ||
} | ||
|
||
public enum LogStyle { | ||
case full | ||
case short | ||
} | ||
|
||
} | ||
|
||
public class Log { | ||
|
||
private var category: String? = nil | ||
|
||
public init(category: String) { | ||
self.category = category | ||
} | ||
|
||
// MARK: With category | ||
public func log( | ||
tag: String? = nil, | ||
_ message: String, | ||
_ type: LogType = .info, | ||
style: LogStyle = .short, | ||
file: String = #file, | ||
function: String = #function, | ||
line: Int = #line | ||
) { | ||
Log.log(tag: tag, message, type, style: style, category: self.category, file: file, function: function, line: line) | ||
} | ||
|
||
// MARK: Not category | ||
public static func log( | ||
tag: String? = nil, | ||
_ message: String, | ||
_ type: LogType = .info, | ||
style: LogStyle = .short, | ||
file: String = #file, | ||
function: String = #function, | ||
line: Int = #line | ||
) { | ||
log(tag: tag, message, type, style: style, category: nil, file: file, function: function, line: line) | ||
} | ||
|
||
// MARK: Log | ||
private static func log( | ||
tag: String? = nil, | ||
_ message: String, | ||
_ type: LogType = .info, | ||
style: LogStyle = .short, | ||
category: String? = nil, | ||
file: String = #file, | ||
function: String = #function, | ||
line: Int = #line | ||
) { | ||
#if DEBUG | ||
let fileName = (file as NSString).lastPathComponent | ||
// Add time | ||
var printString = time(style: style) | ||
// Add Type icon | ||
printString.append(" " + type.rawValue) | ||
// Add fileName|line|function | ||
switch style { | ||
case .full: | ||
printString.append(" " + "[\(fileName): \(line)] \(function) ==>") | ||
case .short: | ||
printString.append(" " + "==>") | ||
} | ||
// Add category & tag | ||
if let category = category, let tag = tag { | ||
printString.append(" " + "[\(category)/\(tag)]") | ||
} else if let category = category { | ||
printString.append(" " + "[\(category)]") | ||
} else if let tag = tag { | ||
printString.append(" " + "[\(tag)]") | ||
} | ||
// Add message | ||
printString.append(" " + message) | ||
|
||
print(printString) | ||
#endif | ||
} | ||
|
||
} |
Empty file.
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
Example/CSwiftLog.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
PODS: | ||
- CSwiftLog (0.1.0) | ||
|
||
DEPENDENCIES: | ||
- CSwiftLog (from `../`) | ||
|
||
EXTERNAL SOURCES: | ||
CSwiftLog: | ||
:path: "../" | ||
|
||
SPEC CHECKSUMS: | ||
CSwiftLog: 935a2275435a48fd0e69df7a20f1c7a0560e5288 | ||
|
||
PODFILE CHECKSUM: 202d93f7aed4a586b9ba6a4ba466e56d0a7f16b4 | ||
|
||
COCOAPODS: 1.11.2 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.