CocoaLumberjack 官方文档翻译

https://github.com/CocoaLumberjack/CocoaLumberjack

在练习双拼,顺手随便翻下,慢慢更新吧,不对之处还请指正。

CocoaLumberjack

CocoaLumberjack is a fast & simple, yet powerful & flexible logging framework for Mac and iOS.
CocoaLumberjack 是一个快速&简单,是 Mac 和 iOS 上强大&灵活的日志框架.

How to get started

怎么开始

Swift version via CocoaPods
通过 CocoaPods 安装 Swift 版本
platform :ios, '8.0'
pod 'CocoaLumberjack/Swift'
use_frameworks!

Note: Swift is a subspec which will include all the Obj-C code plus the Swift one, so this is sufficient.
For more details about how to use Swift with Lumberjack, see this conversation.

Swift Usage

If you installed using CocoaPods or manually:

import CocoaLumberjack
DDLog.addLogger(DDTTYLogger.sharedInstance()) // TTY = Xcode console
DDLog.addLogger(DDASLLogger.sharedInstance()) // ASL = Apple System Logs

let fileLogger: DDFileLogger = DDFileLogger() // File Logger
fileLogger.rollingFrequency = 60*60*24  // 24 hours
fileLogger.logFileManager.maximumNumberOfLogFiles = 7
DDLog.addLogger(fileLogger)

...

DDLogVerbose("Verbose");
DDLogDebug("Debug");
DDLogInfo("Info");
DDLogWarn("Warn");
DDLogError("Error");
Obj-C version via CocoaPods
通过 CocoaPods 安装 Obj-C 版本
platform :ios, '7.0'
pod 'CocoaLumberjack'
Obj-C usage
Obj-C 用法

If you're using Lumberjack as a framework, you can @import CocoaLumberjack.
如果你在使用 Lumberjack 作为框架,你可以@import CocoaLumberjack.

Otherwise, #import <CocoaLumberjack/CocoaLumberjack.h>
否则,#import <CocoaLumberjack/CocoaLumberjack.h>

[DDLog addLogger:[DDTTYLogger sharedInstance]]; // TTY = Xcode console
// TTY = Xcode 控制台
[DDLog addLogger:[DDASLLogger sharedInstance]]; // ASL = Apple System Logs
// ASL = 苹果系统日志

DDFileLogger *fileLogger = [[DDFileLogger alloc] init]; // File Logger
fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
[DDLog addLogger:fileLogger];

...

DDLogVerbose(@"Verbose");
DDLogDebug(@"Debug");
DDLogInfo(@"Info");
DDLogWarn(@"Warn");
DDLogError(@"Error");
Installation with Carthage (iOS 8+)

Carthage 的安装方式 (iOS 8+)

Carthage is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods.
Carthage是一个轻量级的 Swift 和 Objective-C 的依赖管理器。它会对 CocoaTouch 模块起作用,比 CocoaPods 影响的东西要少。

To install with Carthage, follow the instruction on Carthage
按照这个指示安装Carthage
Cartfile

github "CocoaLumberjack/CocoaLumberjack"

CocoaLumberjack 2

Migrating to 2.x

迁移至 2.x 版本

  • Replace DDLog.h imports by #import <CocoaLumberjack/CocoaLumberjack.h>.
  • 导入用#import <CocoaLumberjack/CocoaLumberjack.h>替换 DDLog.h .

Advanced users, third party libraries:

  • Replace all DDLogC macros for regular DDLog macros.
  • Replace log level (LOG_LEVEL_*) macros with DDLogLevel enum values
  • Replace log flag (LOG_FLAG_*) macros with DDLogFlag enum values
  • Replace DDLogMessage ivars and method calls to the new ivars and methods
    • logMsg with _message
    • logLevel with _level
    • logFlag with _flag
    • logContext with _context
    • lineNumber with _line (type changed from int to NSUInteger)
    • file with _file (filename contains just the file name, without the extension and the full path)
    • timestamp with _timestamp
    • methodName with function
  • Replace DDAbstractLogger formatter to logFormatter
  • YSSingleFileLogger ivars are no longer accesible, use the methods instead
  • Replace [DDLog addLogger:withLogLevel:] with [DDLog addLogger:withLevel:]

Forcing 1.x

If an included library requires it, you can force CocoaLumberjack 1.x by setting the version before the conflicting library:

pod 'CocoaLumberjack', '~> 1.9'
pod 'ConflictingLibrary'

Features

特色

Lumberjack is Fast & Simple, yet Powerful & Flexible.

It is similar in concept to other popular logging frameworks such as log4j, yet is designed specifically for Objective-C, and takes advantage of features such as multi-threading, grand central dispatch (if available), lockless atomic operations, and the dynamic nature of the Objective-C runtime.
它和其他像 log4j 这样的热门日志记录框架的概念相似,目前只特别针对 Objective-C,在多线程,grand central dispatch(GCD),无锁的原子性操作比较有优势,还有Objective-C 运行时的动态特色。

Lumberjack is Fast

In most cases it is an order of magnitude faster than NSLog.
在大多数情况下,它比 NSLog 快速、有条理。

Lumberjack is Simple

It takes as little as a single line of code to configure lumberjack when your application launches. Then simply replace your NSLog statements with DDLog statements and that's about it. (And the DDLog macros have the exact same format and syntax as NSLog, so it's super easy.)
配置lumberjack 只需要很少的几行代码。只需简单的用DDLog替换 NSLog 。(并且DDLog的宏和NSLog的格式语法完全相同,所以它超级简单)

Lumberjack is Powerful:

One log statement can be sent to multiple loggers, meaning you can log to a file and the console simultaneously. Want more? Create your own loggers (it's easy) and send your log statements over the network. Or to a database or distributed file system. The sky is the limit.
一个日志声明可以被多次发送,意味着你可以同时输出日志到控制台和文件。想要更多?创建你自己的日志器,并且通过网络发送日志,或者发送到数据库、文件分发系统。完全没有限制。

Lumberjack is Flexible:

Configure your logging however you want. Change log levels per file (perfect for debugging). Change log levels per logger (verbose console, but concise log file). Change log levels per xcode configuration (verbose debug, but concise release). Have your log statements compiled out of the release build. Customize the number of log levels for your application. Add your own fine-grained logging. Dynamically change log levels during runtime. Choose how & when you want your log files to be rolled. Upload your log files to a central server. Compress archived log files to save disk space...

This framework is for you if:

如果

  • You're looking for a way to track down that impossible-to-reproduce bug that keeps popping up in the field.
  • 你在寻找一种方式来跟踪不可复现的bug。
  • You're frustrated with the super short console log on the iPhone.
  • 你被iphone上非常短的日志所困扰。
  • You're looking to take your application to the next level in terms of support and stability.
  • 你想让你的应用规范与稳定。
  • You're looking for an enterprise level logging solution for your application (Mac or iPhone).
  • 你在为你的应用寻找企业级的日志解决方案。

Documentation

说明文档

Requirements

The current version of Lumberjack requires:

  • Xcode 7.3 or later
  • iOS 5 or later
  • OS X 10.7 or later
  • WatchOS 2 or later
  • TVOS 9 or later

Backwards compability

  • for Xcode 7.2 and 7.1, use the 2.2.0 version
  • for Xcode 7.0 or earlier, use the 2.1.0 version
  • for Xcode 6 or earlier, use the 2.0.x version
  • for OS X < 10.7 support, use the 1.6.0 version

Communication

  • If you need help, use Stack Overflow. (Tag 'lumberjack')
  • If you'd like to ask a general question, use Stack Overflow.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Author

Collaborators

License

  • CocoaLumberjack is available under the BSD license. See the LICENSE file.

Architecture

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 201,681评论 5 474
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,710评论 2 377
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 148,623评论 0 334
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,202评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,232评论 5 363
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,368评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,795评论 3 393
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,461评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,647评论 1 295
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,476评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,525评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,226评论 3 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,785评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,857评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,090评论 1 258
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,647评论 2 348
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,215评论 2 341

推荐阅读更多精彩内容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,422评论 5 6
  • 曾经以为香芋味的奶茶,永远是我最喜欢的饮料。 曾经以为听过许多遍的歌,可以不忘词不跑调地唱给大家听。 曾经以为最看...
    愿小飞阅读 218评论 0 0
  • 无尘设备
    谷得阅读 240评论 0 0
  • 山西的省级艺术团在学校演了《生命如歌》,今天晚上和同学一起去观看了。本来是抱着不好就扯的打算去,七点钟开始的时候整...
    忽尔今至阅读 161评论 0 0
  • 不知是谁在我耳边曾经说过这样一句话:人这一辈子至少要看一场明星演唱会。无意中这句话被我记在心底了。 前几天...
    凤舞梧桐阅读 459评论 0 0