1 Star 0 Fork 0

frankgit/ios-app-signer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Log.swift 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
Daniel Radtke 提交于 2016-11-27 03:47 +08:00 . Convert to Swift 3.0 syntax
//
// Log.swift
// iOS App Signer
//
// Created by Daniel Radtke on 11/14/15.
// Copyright © 2015 Daniel Radtke. All rights reserved.
//
import Foundation
class Log {
static let mainBundle = Bundle.main
static let bundleID = mainBundle.bundleIdentifier
static let bundleName = mainBundle.infoDictionary!["CFBundleName"]
static let bundleVersion = mainBundle.infoDictionary!["CFBundleShortVersionString"]
static let tempDirectory = NSTemporaryDirectory()
static var logName = Log.tempDirectory.stringByAppendingPathComponent("\(Log.bundleID!)-\(Date().timeIntervalSince1970).log")
static func write(_ value:String) {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
if let outputStream = OutputStream(toFileAtPath: logName, append: true) {
outputStream.open()
let text = "\(formatter.string(from: Date())) \(value)\n"
let data = text.data(using: String.Encoding.utf8, allowLossyConversion: false)!
outputStream.write((data as NSData).bytes.bindMemory(to: UInt8.self, capacity: data.count), maxLength: data.count)
outputStream.close()
}
NSLog(value)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/frankgiteespace/ios-app-signer.git
git@gitee.com:frankgiteespace/ios-app-signer.git
frankgiteespace
ios-app-signer
ios-app-signer
master

搜索帮助