CocoaLumberjack

iOS CocoaLumberjack: New log file is creating on every time app launch, if backgroundModes enabled and app running in simulator

安稳与你 提交于 2020-01-06 08:59:48
问题 I have configured library like below let fileLogger: DDFileLogger = DDFileLogger() fileLogger.rollingFrequency = -1 fileLogger.maximumFileSize = 1024 * 1024 fileLogger.logFileManager.maximumNumberOfLogFiles = 7 DDLog.add(fileLogger) File has to roll only if it reaches 1MB size. Recently i observed one thing, if app running in simulator with background mode enabled. New log file is creating on every time app launch irrespective of file size. Is this known thing?. Because NSFileProtectionType

Global import for Swift CocoaLumberjack

放肆的年华 提交于 2019-12-25 08:19:55
问题 I configured CocoaLumberjack properly using the swift pod. And I can log whatever: DDLogVervose("") DDLogInfo("") But I have to in every class to use it: import CocoaLumberjack Isnt there a way that I can globaly import ? 回答1: The only "trick" to have it available in all your classes is to use a pch (precompiled header) and import CocoaLumberjack there. It's a header that gets imported in all your files. 来源: https://stackoverflow.com/questions/40568997/global-import-for-swift-cocoalumberjack

CocoaLumberjack in Swift, how to print line number and filne name

妖精的绣舞 提交于 2019-12-10 06:14:57
问题 I'm new to CocoaLumberjack and I get it to work on Swift following this. If I try to print logs doing: DDLogDebug("Debug") DDLogInfo("Info") DDLogWarn("Warning") DDLogVerbose("Verbose") DDLogError("Error") Everything works fine and I get all the levels printed as my defaultDebugLevel is DDLogLevel.Verbose. But I can't find/find out how to print the line or the filename with the log. Any idea? Thanks a lot!! 回答1: After some more research I found that you have to create a log formatter, this

利用 CocoaLumberjack 搭建自己的 Log 系统

爱⌒轻易说出口 提交于 2019-12-06 08:40:26
先说下需求,我理想中的 Log 系统需要: 可以设定 Log 等级 可以积攒到一定量的 log 后,一次性发送给服务器,绝对不能打一个 Log 就发一次 可以一定时间后,将未发送的 log 发送到服务器 可以在 App 切入后台时将未发送的 log 发送到服务器 其他一些需求,比如可以远程设定发送 log 的等级阀值,还有阀值的有效期等,和本文无关就不写了。 开始动手前,先了解下 CocoaLumberjack 是什么: CocoaLumberjack 最早是由 Robbie Hanson 开发的日志库,可以在 iOS 和 MacOSX 开发上使用。其简单,快读,强大又不失灵活。它自带了几种log方式,分别是: DDASLLogger 将 log 发送给苹果服务器,之后在 Console.app 中可以查看 DDTTYLogger 将 log 发送给 Xcode 的控制台 DDFileLogger 讲 log 写入本地文件 CocoaLumberjack 打一个 log 的流程大概就是这样的: 所有的 log 都会发给 DDLog 对象,其运行在自己的一个GCD队列(GlobalLoggingQueue),之后,DDLog 会将 log 分发给其下注册的一个或多个 Logger,这步在多核下是并发的,效率很高。每个 Logger 处理收到的 log 也是在它们自己的 GCD队列下

CocoaLumberjack 的使用

陌路散爱 提交于 2019-12-05 12:49:32
安装XcodeColors插件 下载地址: https://github.com/robbiehanson/XcodeColors 安装方法: 下载并解压缩XcodeColors-master.zip 打开XcodeColors项目,编译项目可以自动将插件安装至~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XcodeColors.xcplugin 重新启动Xcode 再次打开XcodeColors项目 运行TestXcodeColors测试插件是否安装成功 下载CocoaLumberjack开源框架 下载地址: https://github.com/CocoaLumberjack/CocoaLumberjack 新建项目,将CocoaLumberjack拖入项目中 创建Common.h #ifdef DEBUG static const int ddLogLevel = LOG_LEVEL_VERBOSE; #else static const int ddLogLevel = LOG_LEVEL_OFF; #endif 在xxx-Prefix.pch中添加Common.h的引入 #import "Common.h" 实例化DDLog 在- (BOOL)application:(UIApplication

CocoaLumberjack in Swift, how to print line number and filne name

大憨熊 提交于 2019-12-05 12:40:24
I'm new to CocoaLumberjack and I get it to work on Swift following this . If I try to print logs doing: DDLogDebug("Debug") DDLogInfo("Info") DDLogWarn("Warning") DDLogVerbose("Verbose") DDLogError("Error") Everything works fine and I get all the levels printed as my defaultDebugLevel is DDLogLevel.Verbose. But I can't find/find out how to print the line or the filename with the log. Any idea? Thanks a lot!! Andres After some more research I found that you have to create a log formatter, this log formatter is a subclass of DDDispatchQueueLogFormatter and you have to override a function that

CocoaLumberjack iOS - Can we change the logfile name and directory?

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am using CocoaLumberjack in my project. I need to change the name of the logfile to my custom file name. NSString * applicationDocumentsDirectory = [[[[ NSFileManager defaultManager ] URLsForDirectory : NSDocumentDirectory inDomains : NSUserDomainMask ] lastObject ] path ]; DDLogFileManagerDefault * documentsFileManager = [[ DDLogFileManagerDefault alloc ] initWithLogsDirectory : applicationDocumentsDirectory ]; DDFileLogger * fileLogger = [[ DDFileLogger alloc ] initWithLogFileManager : documentsFileManager ]; // Configure File