remove prefix & make static let instead var
This commit is contained in:
parent
6af4668690
commit
ecfd326da4
|
|
@ -13,9 +13,9 @@
|
|||
952A63921C5408AC00E3572C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 952A63901C5408AC00E3572C /* Main.storyboard */; };
|
||||
952A63941C5408AC00E3572C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 952A63931C5408AC00E3572C /* Assets.xcassets */; };
|
||||
952A63971C5408AC00E3572C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 952A63951C5408AC00E3572C /* LaunchScreen.storyboard */; };
|
||||
952A63A51C543CD400E3572C /* TIApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63A41C543CD400E3572C /* TIApp.swift */; };
|
||||
952A63A71C54F71500E3572C /* TILog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63A61C54F71500E3572C /* TILog.swift */; };
|
||||
952A63AB1C54F76400E3572C /* TILogFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63AA1C54F76400E3572C /* TILogFormatter.swift */; };
|
||||
952A63A51C543CD400E3572C /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63A41C543CD400E3572C /* App.swift */; };
|
||||
952A63A71C54F71500E3572C /* Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63A61C54F71500E3572C /* Log.swift */; };
|
||||
952A63AB1C54F76400E3572C /* LogFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 952A63AA1C54F76400E3572C /* LogFormatter.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
|
|
@ -28,9 +28,9 @@
|
|||
952A63931C5408AC00E3572C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
952A63961C5408AC00E3572C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
952A63981C5408AC00E3572C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
952A63A41C543CD400E3572C /* TIApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TIApp.swift; sourceTree = "<group>"; };
|
||||
952A63A61C54F71500E3572C /* TILog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TILog.swift; sourceTree = "<group>"; };
|
||||
952A63AA1C54F76400E3572C /* TILogFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TILogFormatter.swift; sourceTree = "<group>"; };
|
||||
952A63A41C543CD400E3572C /* App.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; };
|
||||
952A63A61C54F71500E3572C /* Log.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Log.swift; sourceTree = "<group>"; };
|
||||
952A63AA1C54F76400E3572C /* LogFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LogFormatter.swift; sourceTree = "<group>"; };
|
||||
DF472984BADA33609A7AA065 /* Pods-iOS-Base-Library.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS-Base-Library.debug.xcconfig"; path = "Pods/Target Support Files/Pods-iOS-Base-Library/Pods-iOS-Base-Library.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
|
|
@ -106,9 +106,9 @@
|
|||
952A63A31C543CB100E3572C /* Logger */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
952A63A41C543CD400E3572C /* TIApp.swift */,
|
||||
952A63A61C54F71500E3572C /* TILog.swift */,
|
||||
952A63AA1C54F76400E3572C /* TILogFormatter.swift */,
|
||||
952A63A41C543CD400E3572C /* App.swift */,
|
||||
952A63A61C54F71500E3572C /* Log.swift */,
|
||||
952A63AA1C54F76400E3572C /* LogFormatter.swift */,
|
||||
);
|
||||
name = Logger;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -282,10 +282,10 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
952A638F1C5408AC00E3572C /* ViewController.swift in Sources */,
|
||||
952A63A71C54F71500E3572C /* TILog.swift in Sources */,
|
||||
952A63AB1C54F76400E3572C /* TILogFormatter.swift in Sources */,
|
||||
952A63A71C54F71500E3572C /* Log.swift in Sources */,
|
||||
952A63AB1C54F76400E3572C /* LogFormatter.swift in Sources */,
|
||||
952A638D1C5408AC00E3572C /* AppDelegate.swift in Sources */,
|
||||
952A63A51C543CD400E3572C /* TIApp.swift in Sources */,
|
||||
952A63A51C543CD400E3572C /* App.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,38 +9,32 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
|
||||
public class TIApp {
|
||||
private let stringVendorIdentifierKey: String = "stringIdentifierForVendor"
|
||||
public class App {
|
||||
private static let stringVendorIdentifierKey = "stringIdentifierForVendor"
|
||||
/// The value of CFBundleName
|
||||
public var bundleName: String
|
||||
public static var bundleName: String = NSBundle.mainBundle().infoDictionary!["CFBundleName"] as! String
|
||||
/// The value of CFBundleShortVersionString
|
||||
public var shortBundleVersion: String
|
||||
public static var shortVersion: String = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"] as! String
|
||||
/// The value of CFBundleVersion
|
||||
public var bundleVersion: String
|
||||
init() {
|
||||
bundleName = NSBundle.mainBundle().infoDictionary!["CFBundleName"] as! String
|
||||
|
||||
shortBundleVersion = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"] as! String
|
||||
bundleVersion = NSBundle.mainBundle().infoDictionary!["CFBundleVersion"] as! String
|
||||
}
|
||||
public static var bundleVersion: String = NSBundle.mainBundle().infoDictionary!["CFBundleVersion"] as! String
|
||||
|
||||
/**
|
||||
Return app's version
|
||||
- returns: shortBundleVersion.bundleVersion
|
||||
*/
|
||||
public func version() -> String {
|
||||
return shortBundleVersion + "." + bundleVersion
|
||||
public static func version() -> String {
|
||||
return App.shortVersion + "." + App.bundleVersion
|
||||
}
|
||||
|
||||
/**
|
||||
Return device identifier
|
||||
- returns: UUIDString
|
||||
*/
|
||||
public func stringIdentifierForVendor() -> String {
|
||||
var returnValue = NSUserDefaults.standardUserDefaults().stringForKey(stringVendorIdentifierKey)
|
||||
public static func stringIdentifierForVendor() -> String {
|
||||
var returnValue = NSUserDefaults.standardUserDefaults().stringForKey(App.stringVendorIdentifierKey)
|
||||
if returnValue == nil {
|
||||
returnValue = NSUUID().UUIDString
|
||||
NSUserDefaults.standardUserDefaults().setObject(returnValue, forKey: stringVendorIdentifierKey)
|
||||
NSUserDefaults.standardUserDefaults().setObject(returnValue, forKey: App.stringVendorIdentifierKey)
|
||||
NSUserDefaults.standardUserDefaults().synchronize()
|
||||
}
|
||||
return returnValue!
|
||||
|
|
@ -13,7 +13,7 @@ import CocoaLumberjack
|
|||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
var log: TILog?
|
||||
var log: Log?
|
||||
|
||||
func application(application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
||||
|
|
@ -24,8 +24,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
}
|
||||
|
||||
func initLog() -> Void {
|
||||
log = TILog.init()
|
||||
DDLogInfo(log!.startMessage())
|
||||
log = Log.init()
|
||||
DDLogInfo(Log.startMessage())
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,21 +9,20 @@
|
|||
import Foundation
|
||||
import CocoaLumberjack
|
||||
|
||||
public class TILog {
|
||||
public class Log {
|
||||
|
||||
/// Logger for CocoaLumberJack
|
||||
public var fileLogger: DDFileLogger
|
||||
public let fileLogger = DDFileLogger()
|
||||
|
||||
init() {
|
||||
fileLogger = DDFileLogger.init()
|
||||
|
||||
DDLog.addLogger(fileLogger)
|
||||
|
||||
DDLog.addLogger(DDASLLogger.sharedInstance())
|
||||
DDLog.addLogger(DDTTYLogger.sharedInstance())
|
||||
|
||||
DDASLLogger.sharedInstance().logFormatter = TILogFormatter.init()
|
||||
DDTTYLogger.sharedInstance().logFormatter = TILogFormatter.init()
|
||||
DDASLLogger.sharedInstance().logFormatter = LogFormatter.init()
|
||||
DDTTYLogger.sharedInstance().logFormatter = LogFormatter.init()
|
||||
|
||||
let assertionHandler = NSAssertionHandler.init()
|
||||
|
||||
|
|
@ -35,10 +34,9 @@ public class TILog {
|
|||
|
||||
- returns: Return value looks like "AppName 1.0.1 session started on version 9.2 (build 13c75)"
|
||||
*/
|
||||
public func startMessage() -> String {
|
||||
let app = TIApp.init()
|
||||
let startMessage = app.bundleName + " " + app.shortBundleVersion + "."
|
||||
+ app.bundleVersion + " session started on "
|
||||
public static func startMessage() -> String {
|
||||
let startMessage = App.bundleName + " " + App.shortVersion + "."
|
||||
+ App.bundleVersion + " session started on "
|
||||
+ NSProcessInfo.processInfo().operatingSystemVersionString.lowercaseString
|
||||
return startMessage
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ import Foundation
|
|||
import CocoaLumberjack
|
||||
import CocoaLumberjack.DDDispatchQueueLogFormatter
|
||||
|
||||
class TILogFormatter: DDDispatchQueueLogFormatter {
|
||||
class LogFormatter: DDDispatchQueueLogFormatter {
|
||||
let dateFormatter: NSDateFormatter
|
||||
|
||||
override init() {
|
||||
|
|
@ -25,13 +25,13 @@ class TILogFormatter: DDDispatchQueueLogFormatter {
|
|||
var level: String!
|
||||
|
||||
switch logMessage.flag {
|
||||
case (DDLogFlag.Error):
|
||||
case DDLogFlag.Error:
|
||||
level = "ERR"
|
||||
case (DDLogFlag.Warning):
|
||||
case DDLogFlag.Warning:
|
||||
level = "WRN"
|
||||
case (DDLogFlag.Info):
|
||||
case DDLogFlag.Info:
|
||||
level = "INF"
|
||||
case (DDLogFlag.Debug):
|
||||
case DDLogFlag.Debug:
|
||||
level = "DBG"
|
||||
default:
|
||||
level = "VRB"
|
||||
Loading…
Reference in New Issue