Giter VIP home page Giter VIP logo

cocoalumberjack / cocoalumberjack Goto Github PK

View Code? Open in Web Editor NEW
13.1K 382.0 2.3K 6.04 MB

A fast & simple, yet powerful & flexible logging framework for macOS, iOS, tvOS and watchOS

Home Page: https://cocoalumberjack.github.io

License: BSD 3-Clause "New" or "Revised" License

Objective-C 79.47% C 0.91% Swift 18.07% Shell 1.55%
macos ios watchos tvos logging log objective-c swift cocoapods carthage

cocoalumberjack's Introduction

CocoaLumberjack

Version License Pod Platform Carthage compatible Unit Tests codecov codebeat badge

CocoaLumberjack is a fast & simple, yet powerful & flexible logging framework for macOS, iOS, tvOS and watchOS.

How to get started

First, install CocoaLumberjack via CocoaPods, Carthage, Swift Package Manager or manually. Then use DDOSLogger for iOS 10 and later, or DDTTYLogger and DDASLLogger for earlier versions to begin logging messages.

CocoaPods

platform :ios, '11.0'

target 'SampleTarget' do
  use_frameworks!
  pod 'CocoaLumberjack/Swift'
end

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.

For Objective-C use the following:

platform :ios, '11.0'

target 'SampleTarget' do
    pod 'CocoaLumberjack'
end

Carthage

Carthage is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods.

To install with Carthage, follow the instruction on Carthage

Cartfile

github "CocoaLumberjack/CocoaLumberjack"

Swift Package Manager

As of CocoaLumberjack 3.6.0, you can use the Swift Package Manager as integration method. If you want to use the Swift Package Manager as integration method, either use Xcode to add the package dependency or add the following dependency to your Package.swift:

.package(url: "https://github.com/CocoaLumberjack/CocoaLumberjack.git", from: "3.8.0"),

Note that you may need to add both products, CocoaLumberjack and CocoaLumberjackSwift to your target since SPM sometimes fails to detect that CocoaLumerjackSwift depends on CocoaLumberjack.

Install manually

If you want to install CocoaLumberjack manually, read the manual installation guide for more information.

Swift Usage

Usually, you can simply import CocoaLumberjackSwift. If you installed CocoaLumberjack using CocoaPods, you need to use import CocoaLumberjack instead.

DDLog.add(DDOSLogger.sharedInstance) // Uses os_log

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

...

DDLogVerbose("Verbose")
DDLogDebug("Debug")
DDLogInfo("Info")
DDLogWarn("Warn")
DDLogError("Error")

Obj-C usage

If you're using Lumberjack as a framework, you can @import CocoaLumberjack;. Otherwise, #import <CocoaLumberjack/CocoaLumberjack.h>

[DDLog addLogger:[DDOSLogger sharedInstance]]; // Uses os_log

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");

Objective-C ARC Semantic Issue

When integrating Lumberjack into an existing Objective-C it is possible to run into Multiple methods named 'tag' found with mismatched result, parameter type or attributes build error.

Add #define DD_LEGACY_MESSAGE_TAG 0 before importing CocoaLumberjack or add #define DD_LEGACY_MESSAGE_TAG 0 or add -DDD_LEGACY_MESSAGE_TAG=0 to Other C Flags/OTHER_CFLAGS in your Xcode project.

swift-log backend

CocoaLumberjack also ships with a backend implementation for swift-log. Simply add CocoaLumberjack as dependency to your SPM target (see above) and also add the CocoaLumberjackSwiftLogBackend product as dependency to your target.

You can then use DDLogHandler as backend for swift-log, which will forward all messages to CocoaLumberjack's DDLog. You will still configure the loggers and log formatters you want via DDLog, but writing log messages will be done using Logger from swift-log.

In your own log formatters, you can make use of the swiftLogInfo property on DDLogMessage to retrieve the details of a message that is logged via swift-log.

To use swift-log with CocoaLumberjack, take a look the following code snippet to see how to get started.

import CocoaLumberjack
import CocoaLumberjackSwiftLogBackend
import Logging

// In your application's entry point (e.g. AppDelegate):
DDLog.add(DDOSLogger.sharedInstance) // Configure loggers
LoggingSystem.bootstrapWithCocoaLumberjack() // Use CocoaLumberjack as swift-log backend

More information

  • read the Getting started guide, check out the FAQ section or the other docs
  • if you find issues or want to suggest improvements, create an issue or a pull request
  • for all kinds of questions involving CocoaLumberjack, use the Google group or StackOverflow (use #lumberjack).

CocoaLumberjack 3

Migrating to 3.x

  • To be determined

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.

Lumberjack is Fast

In most cases it is an order of magnitude faster than 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 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.
  • You're frustrated with the super short console log on the 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 14.1 or later
  • Swift 5.5 or later
  • macOS 10.13 or later
  • iOS 11 or later
  • tvOS 11 or later
  • watchOS 4 or later

Backwards compatibility

  • for iOS/tvOS up to 10, watchOS up to 3, macOS up to 10.12, Xcode up to 13 and Swift up to 5.4, use the 3.7.4 version
  • for Xcode 11 and Swift up to 5.2, use the 3.6.2 version
  • for Xcode 10 and Swift 4.2, use the 3.5.2 version
  • for iOS 8, use the 3.6.1 version
  • for iOS 6, iOS 7, OS X 10.8, OS X 10.9 and Xcode 9, use the 3.4.2 version
  • for iOS 5 and OS X 10.7, use the 3.3 version
  • for Xcode 8 and Swift 3, use the 3.2 version
  • for Xcode 7.3 and Swift 2.3, use the 2.4.0 version
  • for Xcode 7.3 and Swift 2.2, use the 2.3.0 version
  • 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.

Data Collection Practices

Per App privacy details on the App Store, Apple is requesting app developers to provide info about their data collection, us SDK maintainers must provide them with the same data.

Data collection by the framework

By default, CocoaLumberjack does NOT collect any data on its own.

See our Data Collection Practices list.

Indirect data collection through the framework

CocoaLumberjack is a logging framework which makes it easy to send those logs to different platforms.

This is why collecting data might happen quite easily, if app developers include any sensitive data into their log messages.

Important note: app developers are fully responsible for any sensitive data collected through our logging system!

In consequence, you must comply to the Apple's privacy details policy (mentioned above) and document the ways in which user data is being collected. Since the number of scenarios where data might be indirectly collected through CocoaLumberjack is quite large, it's up to you, as app developers, to properly review your app's code and identify those cases. What we can do to help is raise awareness about potential data collection through our framework.

Private data includes but isn't limited to:

  • user info (name, email, address, ...)
  • location info
  • contacts
  • identifiers (user id, device id, ...)
  • app usage data
  • performance data
  • health and fitness info
  • financial info
  • sensitive info
  • user content
  • history (browsing, search, ...)
  • purchases
  • diagnostics
  • ...

Example: DDLogInfo("User: \(myUser)") will add the myUser info to the logs, so if those are forwarded to a 3rd party or sent via email, that may qualify as data collection.

Author

  • Robbie Hanson
  • Love the project? Wanna buy me a coffee? (or a beer :D) donation

Collaborators

License

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

Extensions

Architecture

cocoalumberjack's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cocoalumberjack's Issues

Printing URLs With %20 Print Garbage / % Not Escaped?

There seems to be an issue around printing urls with spaces in them. I have a webview that prints this on failure:

DDLogError(@"Problem loading url: %@ ", [[[webview request] url] absoluteString]

This ends up printing a lot of junk. I originally thought maybe [ absoluteString], was doing something weird, but I ultimately found that formatting a string that ends up with a % in it starts printing what I'm assuming is memory.

As a quick example:

DDLogError(@"Problem loading url: %@ ", @"file:///Users/chris/Library/Application%20Support/iPhone%20Simulator/5.1/Applications/7D46BE84-C769-4320-B56B-81C050EB4EC4/Documents/widgets/info/full.html");

Outputs:
    Problem loading url: file:///Users/chris/Library/Application(null)upport/iPhoneไกฅๆ…ฅๆฅคๆฎๆขๆ„ขๆฃ็‰ตๆกโ‰นโ‰คๆฅดๆ•ญ็‘ณๆตกโ‰ฐโ‰คๆ•ด็ญ็‰ฅ็‘ก็‰ตโ‰ฅโ‰คๆ…ญๆนง็‘ฉๆ‘ตโ‰ฅโ‰คๆนฉๆฑฃๆนฉ็‘กๆฝฉโ‰ฎโ‰คๆ…ฃๆฅฌ็‰ข็‘กๆฝฉโ‰ฎ็ตฉไ€€ใตไ€ดใจฐ็ฌดใดฟใฝปๆฝ็ตคๅญคใ„ตๆŒฒ็ต8ใฝปโˆฝๆ•ฃ็‘ฎ็‰ฅ็ฌขใดฟๆฐข็‘ก็‘ฉๆ‘ตโ‰ฅโ‰คๆฝฌๆฎ็‘ฉๆ‘ตโ‰ฅ็ตค็ˆขๆ‘ก็•ฉโ‰ณโ‰คๆ‘ฉๆนฅๆฅดๆฅฆ็‰ฅๅฌขใ„ตๆŒฒ็ตไ€€ใ˜ณใ€ใบใฝปๆฝ็ตคๆธใฒใ€2ใฝป็ฌฝใดฟๆ‘คๆ‘ฝใ•›ใˆฑๅตฃใกฝใ€ใบๆŒ€ใฒใ€ใบใฝปๆฝ็ตค8ใฝ€ไ€€ไœขไฝ…ๆ•‡ๆฏๆ‘ฏๅ‰ฅ็…ฅๆ•ต็‘ณ"็ญžๆฅค็ณ็‘กๆกฃ็…Ÿๆ•ตๆ•ต็Ÿ\347

This version is fine though:

DDLogError(@"Problem loading url: %@ ", @"file:///Users/chris/Library/Application Support/iPhone Simulator/5.1/Applications/7D46BE84-C769-4320-B56B-81C050EB4EC4/Documents/widgets/info/full.html");

Outputs:
    Problem loading url: file:///Users/chris/Library/Application Support/iPhone Simulator/5.1/Applications/7D46BE84-C769-4320-B56B-81C050EB4EC4/Documents/widgets/info/full.html

Both print out fine using vanilla NSLogs. I'm thinking there's a sprintf or something somewhere in here that's trying to format the %s, but nothing it standing out right now. Maybe

I'm using the most recent master release. This is in the XCode (4.3.2) console, so I'm assuming I'm looking at TTY logger output.

Thanks.

Allow header/footer in DDLogFormatter

In some log file syntaxes (like XML) it's useful for the log formatter to support a header and footer method that are invoked at the beginning and end of the log stream. For plain text log formats, these will be the empty string.

Please either add header and footer methods to the DDLogFormatter protocol, or add a new protocol with those methods that is checked and invoked when a new log file is opened or closed.

Consider the Layout interface of the Java Logback framework: https://github.com/ceki/logback/blob/master/logback-core/src/main/java/ch/qos/logback/core/Layout.java

Force all other libraries to use CocoaLumberjack

A project will usually have many libraries and most will use NSLog. In my case, I use fmdb for SQLite and all its errors are logged with NSLog so they never get to my CocoaLumberjack file. Is there a way to "rewrite" the NSLog command so that it is actually a wrapper for, say, DDLogVerbose?

Tag release versions

I recently added CocoaLumberjack to the CocoaPods package manager.

Since CocoaLumberjack doesn't currently have a discreet version, I treated the current commit as the 1.0 release. Would it be possible to have this commit tagged as v1.0 (or whatever version you feel comfortable with)? This will help greatly in dependency resolution.

Thanks!

CocoaLumberjack Error: Symbol not found: _objc_storeStrong

I'm relatively new to iOS development, and am trying to implement CocoaLumberjack logging.

I downloaded the latest source from https://github.com/robbiehanson/CocoaLumberjack, have included the required files in my project, made the necessary code changes, and am getting the run-time linker error that follows below.

The environment is Xcode 4.2 Build 4C199, with the project Target set to Device=iPad and DeploymentTarget=4.3. The project was initially written using retain/release, so I left the original source as-is, adding the compiler flag "-fobjc-arc" for the Lumberjack files I'm using: DDFileLogger.m, DDLog.m and DDTTYLogger.m.

The console output is:

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Fri Sep 16 06:56:50 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys001
sharedlibrary apply-load-rules all
target remote-mobile /tmp/.XcodeGDBRemote-10996-56
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
[Switching to process 11779 thread 0x2e03]
[Switching to process 11779 thread 0x2e03]
dyld: lazy symbol binding failed: Symbol not found: _objc_storeStrong
  Referenced from: /var/mobile/Applications/32E4EEB9-765E-4C72-83C8-F5707253AA99/Demo.app/Demo
  Expected in: /usr/lib/libobjc.A.dylib

dyld: Symbol not found: _objc_storeStrong
  Referenced from: /var/mobile/Applications/32E4EEB9-765E-4C72-83C8-F5707253AA99/Demo.app/Demo
  Expected in: /usr/lib/libobjc.A.dylib

warning: Attempting to create USE_BLOCK_IN_FRAME variable with block that isn't in the frame.
(gdb) 

My project initializes the environment as follows, where fileLogger is an instance variable defined in the corresponding AppDelegate.h file:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    /*
     * Configure the Lumberjack logging framework (we'll use it instead of NSLog)
     */

    // the TTY logger is the Xcode console
    [DDLog addLogger:[DDTTYLogger sharedInstance]];

    // we'll also use a file logger
    fileLogger = [[DDFileLogger alloc] init];
    fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
    fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
    [DDLog addLogger:fileLogger];


    // Override point for customization after application launch.
    DDLogInfo(@"didFinishLaunchingWithOptions: entered");

    // create instance of the view controller
    MainViewController *aViewController = [[MainViewController alloc]
                                           initWithNibName:@"MainView" bundle:nil];
    self.mainViewController = aViewController;  // same as: [self setMainViewController:aViewController];
    [aViewController release];

    // Add the main view controller's view to the window and display.
    self.window.rootViewController = self.mainViewController;

    [self.window makeKeyAndVisible];
    return YES;
}

Has anyone encountered this problem, and know of a solution or workaround? Is what I'm doing even possible... having mixed ARC and non-ARC files in a project?

EXC_BAD_ACCESS because NSDateFormatter is not thread-safe in DispatchQueueLogFormatter

I've been using Cocoa Lumberjack with the DispatchQueueLogFormatter for a while, and just hit a crash which appears to be due to using a single NSDateFormatter simultaneously across two threads.

The relevant backtraces are:

The thread that crashed:

* thread #15: tid = 0x2f03, 0x01761f8a CoreFoundation`CFDateFormatterCreateStringWithAbsoluteTime + 74
    frame #0: 0x01761f8a CoreFoundation`CFDateFormatterCreateStringWithAbsoluteTime + 74
    frame #1: 0x01761f2c CoreFoundation`CFDateFormatterCreateStringWithDate + 76
    frame #2: 0x00e6d888 Foundation`-[NSDateFormatter stringForObjectValue:] + 139
    frame #3: 0x00e6d7f4 Foundation`-[NSDateFormatter stringFromDate:] + 44
    frame #4: 0x0007d89f BibDeskReader`-[DispatchQueueLogFormatter formatLogMessage:] + 95 at DispatchQueueLogFormatter.m:183
    frame #5: 0x0007ca10 BibDeskReader`-[DDTTYLogger logMessage:] + 208 at DDTTYLogger.m:99
    frame #6: 0x0007a650 BibDeskReader`__16+[DDLog lt_log:]_block_invoke_0 + 80 at DDLog.m:615
    frame #7: 0x01e3c330 libdispatch.dylib`_dispatch_call_block_and_release + 15
    frame #8: 0x01e3df0c libdispatch.dylib`_dispatch_queue_drain + 460
    frame #9: 0x01e3dcb4 libdispatch.dylib`_dispatch_queue_invoke + 50
    frame #10: 0x01e3d402 libdispatch.dylib`_dispatch_worker_thread2 + 247
    frame #11: 0x91db0b24 libsystem_c.dylib`_pthread_wqthread + 346

The other thread that was using the same NSDateFormatter:

* thread #14: tid = 0x3003, 0x91dadaf6 libsystem_c.dylib`__mtx_droplock + 773
    frame #0: 0x91dadaf6 libsystem_c.dylib`__mtx_droplock + 773
    frame #1: 0x91dadc4c libsystem_c.dylib`pthread_mutex_unlock + 320
    frame #2: 0x0196786b libicucore.A.dylib`umtx_unlock + 76
    frame #3: 0x019f4070 libicucore.A.dylib`ures_getLocaleInternal + 3419
    frame #4: 0x0196b002 libicucore.A.dylib`ures_openDirect + 109
    frame #5: 0x01a1ae62 libicucore.A.dylib`icu::Calendar::setWeekData(icu::Locale const&, char const*, UErrorCode&) + 804
    frame #6: 0x019761c7 libicucore.A.dylib`icu::Calendar::Calendar(icu::TimeZone*, icu::Locale const&, UErrorCode&) + 161
    frame #7: 0x019760b7 libicucore.A.dylib`icu::GregorianCalendar::GregorianCalendar(icu::Locale const&, UErrorCode&) + 49
    frame #8: 0x0197510e libicucore.A.dylib`icu::Calendar::createInstance(icu::TimeZone*, icu::Locale const&, UErrorCode&) + 700
    frame #9: 0x019734c0 libicucore.A.dylib`icu::SimpleDateFormat::initializeCalendar(icu::TimeZone*, icu::Locale const&, UErrorCode&) + 52
    frame #10: 0x01972edc libicucore.A.dylib`icu::SimpleDateFormat::construct(icu::DateFormat::EStyle, icu::DateFormat::EStyle, icu::Locale const&, UErrorCode&) + 62
    frame #11: 0x01972e48 libicucore.A.dylib`icu::SimpleDateFormat::SimpleDateFormat(icu::DateFormat::EStyle, icu::DateFormat::EStyle, icu::Locale const&, UErrorCode&) + 180
    frame #12: 0x01972d27 libicucore.A.dylib`icu::DateFormat::create(icu::DateFormat::EStyle, icu::DateFormat::EStyle, icu::Locale const&) + 171
    frame #13: 0x01972c76 libicucore.A.dylib`icu::DateFormat::createDateTimeInstance(icu::DateFormat::EStyle, icu::DateFormat::EStyle, icu::Locale const&) + 40
    frame #14: 0x01972b03 libicucore.A.dylib`udat_open + 126
    frame #15: 0x0175c11c CoreFoundation`__ResetUDateFormat + 556
    frame #16: 0x0175be95 CoreFoundation`CFDateFormatterCreate + 453
    frame #17: 0x00e6cda5 Foundation`-[NSDateFormatter _regenerateFormatter] + 322
    frame #18: 0x00e6d864 Foundation`-[NSDateFormatter stringForObjectValue:] + 103
    frame #19: 0x00e6d7f4 Foundation`-[NSDateFormatter stringFromDate:] + 44
    frame #20: 0x0007d89f BibDeskReader`-[DispatchQueueLogFormatter formatLogMessage:] + 95 at DispatchQueueLogFormatter.m:183
    frame #21: 0x000715cd BibDeskReader`-[DDASLLogger logMessage:] + 141 at DDASLLogger.m:71
    frame #22: 0x0007a650 BibDeskReader`__16+[DDLog lt_log:]_block_invoke_0 + 80 at DDLog.m:615
    frame #23: 0x01e3c330 libdispatch.dylib`_dispatch_call_block_and_release + 15
    frame #24: 0x01e3df0c libdispatch.dylib`_dispatch_queue_drain + 460
    frame #25: 0x01e3dcb4 libdispatch.dylib`_dispatch_queue_invoke + 50
    frame #26: 0x01e3d402 libdispatch.dylib`_dispatch_worker_thread2 + 247
    frame #27: 0x91db0b24 libsystem_c.dylib`_pthread_wqthread + 346

These two threads were formatting the same message for different loggers (DDTTYLogger and DDASLLogger).

Potential leak in DDlog isRegisteredClass

My application has implemented dynamic loglevels as described in https://github.com/robbiehanson/CocoaLumberjack/wiki/DynamicLogLevels

When profiling my application, I'm receiving a leak when retrieving the list of registered classes :

The responsible caller is :

+[DDlog isRegisteredClass:]

The event causing the leak is a malloc

My code is retrieving a list of registered classes like this

self.registeredLogClasses = [DDLog registeredClasses];

This array is then used to toggle loglevels on those classes. It seems that this is causing the leak.

Outdated wiki sample code

This line from the wiki about custom formatters wouldn't compile on Mac OS >= 10.6.
[threadUnsafeDateFormatter setDateFormat:dateFormatString];
Please fix this.

DDTTYLogger can cause a crash if the log message is too big for the stack

At about line 1094:

char msg[msgLen + 1];

[logMsg getCString:msg maxLength:(msgLen + 1) encoding:NSUTF8StringEncoding];

Was crashing for a very large log message. I assume this is because it was too big for the stack. I was able to fix by malloc'ing the msg instead and freeing after it's used. Not sure if this is the best fix due to potential performance implications.

Remove broken iOS3 support

With the transition to ARC, CocoaLumberjack lost support for iOS3.
I see that as a good sign and an opportunity to delete A LOT of code, everything related to GCD_MAYBE_AVAILABLE.
We know can be sure that GCD is available!

XcodeColors doesn't work

I follow the step to configured the xcode but the content in output did't render with color but with messy code.

    //Adds the logger to the console (similar to nslog)
    [DDLog addLogger:[DDTTYLogger sharedInstance]];
    // And we also enable colors
    [[DDTTYLogger sharedInstance] setColorsEnabled:YES];

    DDLogWarn(@"waring");
    DDLogError(@"error");
[38;5;130m2012-08-03 22:22:50:735[10875:c07] waring
๏ฟฝ[0m๏ฟฝ[38;5;124m2012-08-03 22:22:50:735[10875:c07] error
๏ฟฝ[0m

[38;5;130m and ๏ฟฝ[0m๏ฟฝ[38;5;124m are the messy code.

I also test with xcodecolor test project and it works fine.

Thanks.

Automated Exception Throwing

First of all, thanks a lot for Cocoa Lumberjack, it's a really nice piece of software.

The way I usually program, I would of liked Cocoa Lumberjack to be able to automatically throw exceptions/assert. For example, I would like to set: I want all logs > Error to assert in Debug and none in Release. Like that, errors are fixed quickly instead of pilling up in the console.

What do you think?

doesn't handle out-of-space

I love your logger - thank you.

Just found this in my crash reports.

* Terminating app due to uncaught exception 'NSFileHandleOperationException', reason: '* -[NSConcreteFileHandle writeData:]: No space left on device'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff97158f56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff9408ad5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff97158d8a +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff97158d14 +[NSException raise:format:] + 116
4 Foundation 0x00007fff90c25faa _NSFileHandleRaiseOperationException + 130
5 Foundation 0x00007fff90c25158 -[NSConcreteFileHandle writeData:] + 138
6 VLCStreamer 0x000000010002505f -[DDFileLogger logMessage:] + 182
7 VLCStreamer 0x00000001000270e6 __16+[DDLog lt_log:]_block_invoke_0 + 73
8 libdispatch.dylib 0x00007fff965b0a86 _dispatch_call_block_and_release + 18
9 libdispatch.dylib 0x00007fff965b22d6 _dispatch_queue_drain + 264

Force log rotation

I've setup the framework and the sample compression class. Everything works fine so far. My question is that I need to find a way to focre log rotation (and compression) before uploading logs to my server if not I risk losing logged data.

How can this be done?

Thanks!

EDIT: Re-reading my initial post I think it may be misunderstood. I DO know about the rollLogFile method. The problem with that is that compressing the files takes a little while and I can't know exactly how much I have to wait before the log files are ready to be sent.

crash on deallocated NSFileHandle in DDFileLogger

  • (NSFileHandle *)currentLogFileHandle creates a fileHandleForWritingAtPath (line 735) but does not retain this handle, so on the second call of
  • (void)logMessage:(DDLogMessage *)logMessage the statement [[self currentLogFileHandle] writeData:logData]; (line 769) crashes as follows:
    -[NSConcreteFileHandle writeData:]: message sent to deallocated instance 0x8db6110

Based on this I believe the correction for this is to change line 735 to add a retain as follows:
currentLogFileHandle = [[NSFileHandle fileHandleForWritingAtPath:logFilePath] retain];

Then currentLogFileHandle will also need to be released after the file is closed in

  • (void)dealloc
    and
  • (void)rollLogFileNow

Regards,

Dan

Date/Time Formatting Issue

The problem is formatting of the date time functions. The following examples are from the console in Xcode using iPhone 5.1 simulator. The log is also written to a file and it has the same anomaly sometimes, but not always at the same places. These happen all the time in the logs. Its not hard to find and provide examples. This is using a fresh pull as of June 2, 09:41 Central time. Xcode is Version 4.3.2 (4E2002).

For example from file log.
2012/06/02 09:23:29:222 [DCADatabasesViewController getDatabases]:256, Sort by displaySequence 2012/06/00 00:00:00:000 [DCADatabasesViewController tableView:numberOfRowsInSection:]:277, count of db's = 1 2012/06/155 09:23:29:288 [DCADatabasesViewController tableView:cellForRowAtIndexPath:]:284, -
Note the time is just wrong. Now the same info from Xcode. A lot of the time the errors are the same.
2012/06/02 09:23:29:222 [DCADatabasesViewController getDatabases]:256, Sort by displaySequence 2012/06/00 00:00:00:000 [DCADatabasesViewController tableView:numberOfRowsInSection:]:277, count of db's = 1 2012/06/155 09:23:29:288 [DCADatabasesViewController tableView:cellForRowAtIndexPath:]:284, -

Another example from Xcode.
2012/06/02 09:23:23:022 [DCADatabasesEditNameViewController viewDidAppear:]:70, - 2012/06/02 09:0023:29:171 [DCADatabasesEditNameViewController saveButtonAction]:136, - 2012/06/03 09:23:29:222 [DCADatabasesEditNameViewController viewWillDisappear:]:76, -
But in this case the following from the file log is ok.
2012/06/02 09:23:23:022 [DCADatabasesEditNameViewController viewDidAppear:]:70, - 2012/06/02 09:23:29:171 [DCADatabasesEditNameViewController saveButtonAction]:136, - 2012/06/03 09:23:29:222 [DCADatabasesEditNameViewController viewWillDisappear:]:76, -

I am using a custom formatter (essentially directly from the example code.)

- (id)init
{
    if((self = [super init]))
    {
        dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"yyyy/MM/dd HH:mm:ss:SSS"];
    }
    return self;
}

- (NSString *)formatLogMessage:(DDLogMessage *)logMessage
{
    return [NSString stringWithFormat:@"%@ [%@ %s]:%i, %@",
            [dateFormatter stringFromDate:(logMessage->timestamp)], 
            [logMessage fileName], 
            logMessage->function, 
            logMessage->lineNumber, 
            logMessage->logMsg];
}

Possible thread issue causing crash

We ran into an issue in cocoa lumberjack where the file handle was closed at the same time the offsetInFile was checked and it threw an exception and crashed the application (see crash log details below). I was simply going to catch the exception and ignore it to prevent the crash but then we would have a lost log message(s).

Crash log:

Incident Identifier: 539F6A68-7FE0-4B0F-AFEB-D1BD6BB531E1
CrashReporter Key: b9cab57ad1f413a9d3a7745c5e110ea9cf3dcaed
Hardware Model: iPhone2,1
Process: VoalteOne Dev [4521]
Path: /var/mobile/Applications/6CE64EA2-2AFC-4B8A-8B7A-16134C10B166/VoalteOne Dev.app/VoalteOne Dev
Identifier: VoalteOne Dev
Version: ??? (???)
Code Type: ARM (Native)
Parent Process: launchd [1]

Date/Time: 2011-12-19 09:27:30.536 +0200
OS Version: iPhone OS 5.0 (9A334)
Report Version: 104

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 8

Last Exception Backtrace:
0 CoreFoundation 0x31a298bf __exceptionPreprocess + 163
1 libobjc.A.dylib 0x317991e5 objc_exception_throw + 33
2 CoreFoundation 0x31a297b9 +[NSException raise:format:] + 1
3 CoreFoundation 0x31a297db +[NSException raise:format:] + 35
4 Foundation 0x355fed25 _NSFileHandleRaiseOperationException + 153
5 Foundation 0x355ff0c5 -[NSConcreteFileHandle offsetInFile] + 81
6 VoalteOne Dev 0x000e2329 -DDFileLogger maybeRollLogFileDueToSize
7 VoalteOne Dev 0x000e2b03 -DDFileLogger logMessage:
8 VoalteOne Dev 0x000e4a7d __+[DDLog lt_log:]_block_invoke_2 (DDLog.m:917)
9 libdispatch.dylib 0x3217c7eb _dispatch_barrier_sync_f_invoke + 23
10 libdispatch.dylib 0x3217c65b dispatch_barrier_sync_f$VARIANT$up + 63
11 libdispatch.dylib 0x3217c28f dispatch_sync_f$VARIANT$up + 19
12 libdispatch.dylib 0x3217c911 dispatch_sync$VARIANT$up + 33
13 VoalteOne Dev 0x000e4971 +DDLog lt_log:
14 VoalteOne Dev 0x000e3ef3 __+[DDLog queueLogMessage:synchronously:]_block_invoke_1 (DDLog.m:453)
15 libdispatch.dylib 0x32171d55 _dispatch_call_block_and_release + 13
16 libdispatch.dylib 0x3217ccd3 _dispatch_queue_drain + 243
17 libdispatch.dylib 0x3217cb6d _dispatch_queue_invoke$VARIANT$up + 37
18 libdispatch.dylib 0x3217d773 _dispatch_worker_thread2 + 215
19 libsystem_c.dylib 0x3389d1cf _pthread_wqthread + 295
20 libsystem_c.dylib 0x3389d0a4 start_wqthread + 8

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x30ded724 close + 8
1 Foundation 0x355db8a2 -[NSConcreteFileHandle closeFile] + 58
2 VoalteOne Dev 0x000e2162 -DDFileLogger rollLogFileNow
3 VoalteOne Dev 0x000e22c2 -DDFileLogger maybeRollLogFileDueToAge:
4 Foundation 0x3563a616 NSFireTimer + 138
5 CoreFoundation 0x319fda5c __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION
+ 8
6 CoreFoundation 0x319fd6c2 __CFRunLoopDoTimer + 358
7 CoreFoundation 0x319fc298 __CFRunLoopRun + 1200
8 CoreFoundation 0x3197f4d6 CFRunLoopRunSpecific + 294
9 CoreFoundation 0x3197f39e CFRunLoopRunInMode + 98
10 GraphicsServices 0x31a8bfe6 GSEventRunModal + 150
11 UIKit 0x3250f73c UIApplicationMain + 1084
12 VoalteOne Dev 0x00006d42 main (main.m:12)
13 VoalteOne Dev 0x00002080 start + 32

Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x30ded3b4 kevent + 24
1 libdispatch.dylib 0x3217de78 _dispatch_mgr_invoke + 708
2 libdispatch.dylib 0x3217db96 _dispatch_mgr_thread + 30

Thread 2 name: WebThread
Thread 2:
0 libsystem_kernel.dylib 0x30ded010 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x30ded206 mach_msg + 50
2 CoreFoundation 0x319fd41c __CFRunLoopServiceMachPort + 120
3 CoreFoundation 0x319fc154 __CFRunLoopRun + 876
4 CoreFoundation 0x3197f4d6 CFRunLoopRunSpecific + 294
5 CoreFoundation 0x3197f39e CFRunLoopRunInMode + 98
6 WebCore 0x30434128 _ZL12RunWebThreadPv + 396
7 libsystem_c.dylib 0x338a2c16 _pthread_start + 314
8 libsystem_c.dylib 0x338a2ad0 thread_start + 0

Thread 3 name: com.apple.NSURLConnectionLoader
Thread 3:
0 libsystem_kernel.dylib 0x30ded010 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x30ded206 mach_msg + 50
2 CoreFoundation 0x319fd41c CFRunLoopServiceMachPort + 120
3 CoreFoundation 0x319fc154 __CFRunLoopRun + 876
4 CoreFoundation 0x3197f4d6 CFRunLoopRunSpecific + 294
5 CoreFoundation 0x3197f39e CFRunLoopRunInMode + 98
6 Foundation 0x355a5bc2 +[NSURLConnection(Loader) _resourceLoadLoop:] + 302
7 Foundation 0x355a5a8a -[NSThread main] + 66
8 Foundation 0x3563959a __NSThread__main
+ 1042
9 libsystem_c.dylib 0x338a2c16 _pthread_start + 314
10 libsystem_c.dylib 0x338a2ad0 thread_start + 0

Thread 4 name: com.apple.CFSocket.private
Thread 4:
0 libsystem_kernel.dylib 0x30dfd570 __select + 20
1 CoreFoundation 0x31a0166a __CFSocketManager + 726
2 libsystem_c.dylib 0x338a2c16 _pthread_start + 314
3 libsystem_c.dylib 0x338a2ad0 thread_start + 0

Thread 5:
0 libsystem_kernel.dylib 0x30ded010 mach_msg_trap + 20
1 libsystem_kernel.dylib 0x30ded206 mach_msg + 50
2 CoreFoundation 0x319fd41c CFRunLoopServiceMachPort + 120
3 CoreFoundation 0x319fc154 __CFRunLoopRun + 876
4 CoreFoundation 0x3197f4d6 CFRunLoopRunSpecific + 294
5 CoreFoundation 0x3197f39e CFRunLoopRunInMode + 98
6 Foundation 0x35599b7e -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
7 VoalteOne Dev 0x000fe802 +XMPPStream xmppThreadMain
8 Foundation 0x355a5a8a -[NSThread main] + 66
9 Foundation 0x3563959a __NSThread__main
+ 1042
10 libsystem_c.dylib 0x338a2c16 _pthread_start + 314
11 libsystem_c.dylib 0x338a2ad0 thread_start + 0

Thread 6:
0 libsystem_kernel.dylib 0x30dfd570 __select + 20
1 libsystem_kernel.dylib 0x30deed38 select + 44
2 VoalteOne Dev 0x0018d0da pj_sock_select + 78
3 VoalteOne Dev 0x0018af12 pj_ioqueue_poll + 166
4 VoalteOne Dev 0x0019cafe worker_proc + 42
5 VoalteOne Dev 0x0018bc96 thread_main + 58
6 libsystem_c.dylib 0x338a2c16 _pthread_start + 314
7 libsystem_c.dylib 0x338a2ad0 thread_start + 0

Thread 7:
0 libsystem_kernel.dylib 0x30dfd570 __select + 20
1 libsystem_kernel.dylib 0x30deed38 select + 44
2 VoalteOne Dev 0x0018d0da pj_sock_select + 78
3 VoalteOne Dev 0x0018af12 pj_ioqueue_poll + 166
4 VoalteOne Dev 0x001c8e64 pjsip_endpt_handle_events2 + 124
5 VoalteOne Dev 0x001ecba0 worker_thread + 56
6 VoalteOne Dev 0x0018bc96 thread_main + 58
7 libsystem_c.dylib 0x338a2c16 _pthread_start + 314
8 libsystem_c.dylib 0x338a2ad0 thread_start + 0

Thread 8 name: Dispatch queue: cocoa.lumberjack.fileLogger
Thread 8 Crashed:
0 libsystem_kernel.dylib 0x30dfd32c __pthread_kill + 8
1 libsystem_c.dylib 0x338e0f54 pthread_kill + 48
2 libsystem_c.dylib 0x338d9fe4 abort + 88
3 libc++abi.dylib 0x30caaf64 abort_message + 40
4 libc++abi.dylib 0x30ca8346 _ZL17default_terminatev + 18
5 libobjc.A.dylib 0x317992dc _objc_terminate + 140
6 libc++abi.dylib 0x30ca83be _ZL19safe_handler_callerPFvvE + 70
7 libc++abi.dylib 0x30ca844a std::terminate() + 14
8 libc++abi.dylib 0x30ca9798 __cxa_throw + 116
9 libobjc.A.dylib 0x3179921c objc_exception_throw + 88
10 CoreFoundation 0x31a297b2 +[NSException raise:format:arguments:] + 94
11 CoreFoundation 0x31a297d4 +[NSException raise:format:] + 28
12 Foundation 0x355fed1e _NSFileHandleRaiseOperationException + 146
13 Foundation 0x355ff0be -[NSConcreteFileHandle offsetInFile] + 74
14 VoalteOne Dev 0x000e2322 -DDFileLogger maybeRollLogFileDueToSize
15 VoalteOne Dev 0x000e2afc -DDFileLogger logMessage:
16 VoalteOne Dev 0x000e4a76 __+[DDLog lt_log:]_block_invoke_2 (DDLog.m:915)
17 libdispatch.dylib 0x3217c7e4 _dispatch_barrier_sync_f_invoke + 16
18 libdispatch.dylib 0x3217c654 dispatch_barrier_sync_f$VARIANT$up + 56
19 libdispatch.dylib 0x3217c288 dispatch_sync_f$VARIANT$up + 12
20 libdispatch.dylib 0x3217c90a dispatch_sync$VARIANT$up + 26
21 VoalteOne Dev 0x000e496a +DDLog lt_log:
22 VoalteOne Dev 0x000e3eec __+[DDLog queueLogMessage:synchronously:]_block_invoke_1 (DDLog.m:451)
23 libdispatch.dylib 0x32171d4e _dispatch_call_block_and_release + 6
24 libdispatch.dylib 0x3217cccc _dispatch_queue_drain + 236
25 libdispatch.dylib 0x3217cb66 _dispatch_queue_invoke$VARIANT$up + 30
26 libdispatch.dylib 0x3217d76c _dispatch_worker_thread2 + 208
27 libsystem_c.dylib 0x3389d1c8 _pthread_wqthread + 288
28 libsystem_c.dylib 0x3389d09c start_wqthread + 0

Thread 8 crashed with ARM Thread State:
r0: 0x00000000 r1: 0x00000000 r2: 0x00000001 r3: 0x00000000
r4: 0x00000006 r5: 0x2ff9e000 r6: 0x00000002 r7: 0x2ff9daec
r8: 0x356f293f r9: 0x30caba4a r10: 0x0062b0c0 r11: 0x00010001
ip: 0x00000148 sp: 0x2ff9dae0 lr: 0x338e0f5b pc: 0x30dfd32c
cpsr: 0x00000010

Binary Images:
0x1000 - 0x28dfff +VoalteOne Dev armv7 /var/mobile/Applications/6CE64EA2-2AFC-4B8A-8B7A-16134C10B166/VoalteOne Dev.app/VoalteOne Dev
0x2fe40000 - 0x2fe61fff dyld armv7 /usr/lib/dyld
0x3013a000 - 0x3015afff libxslt.1.dylib armv7 /usr/lib/libxslt.1.dylib
0x302d2000 - 0x3037efff MediaControlSender armv7 <4c0982b21ecf35aead8e0bef55d842b0> /System/Library/PrivateFrameworks/MediaControlSender.framework/MediaControlSender
0x3038c000 - 0x30b43fff WebCore armv7 <5a60e1e3f68331e5b426dd4dfeb3def8> /System/Library/PrivateFrameworks/WebCore.framework/WebCore
0x30b44000 - 0x30b48fff AggregateDictionary armv7 /System/Library/PrivateFrameworks/AggregateDictionary.framework/AggregateDictionary
0x30b53000 - 0x30b56fff CoreTime armv7 /System/Library/PrivateFrameworks/CoreTime.framework/CoreTime
0x30ba9000 - 0x30bb6fff libbsm.0.dylib armv7 /usr/lib/libbsm.0.dylib
0x30c7f000 - 0x30c94fff libresolv.9.dylib armv7 <2e35ec83cc823bbebf107dc4867e61d7> /usr/lib/libresolv.9.dylib
0x30ca4000 - 0x30cabfff libc++abi.dylib armv7 /usr/lib/libc++abi.dylib
0x30d68000 - 0x30debfff CoreMotion armv7 <5e0f8a464b0736cfaa6cf3a0c1f33f2c> /System/Library/Frameworks/CoreMotion.framework/CoreMotion
0x30dec000 - 0x30e02fff libsystem_kernel.dylib armv7 /usr/lib/system/libsystem_kernel.dylib
0x30e07000 - 0x30e07fff Accelerate armv7 /System/Library/Frameworks/Accelerate.framework/Accelerate
0x31350000 - 0x31440fff QuartzCore armv7 /System/Library/Frameworks/QuartzCore.framework/QuartzCore
0x315cb000 - 0x315ccfff CoreSurface armv7 /System/Library/PrivateFrameworks/CoreSurface.framework/CoreSurface
0x31790000 - 0x31856fff libobjc.A.dylib armv7 /usr/lib/libobjc.A.dylib
0x31970000 - 0x31a87fff CoreFoundation armv7 /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
0x31a88000 - 0x31a93fff GraphicsServices armv7 <08bfaa5766853884a09cd70f5ae37017> /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices
0x31aca000 - 0x31ca7fff AudioToolbox armv7 <59dd50551a893636b94bf4505a62ef97> /System/Library/Frameworks/AudioToolbox.framework/AudioToolbox
0x31d22000 - 0x31d6bfff ManagedConfiguration armv7 <80836b34a3ef389d82f0fa55cadccc61> /System/Library/PrivateFrameworks/ManagedConfiguration.framework/ManagedConfiguration
0x31d6c000 - 0x31d6efff libCoreVMClient.dylib armv7 <6ddb7cf8a93830628787a5b83eea0f1d> /System/Library/Frameworks/OpenGLES.framework/libCoreVMClient.dylib
0x31d6f000 - 0x31da6fff Security armv7 <195ed72ea7583470958d72652bd84f03> /System/Library/Frameworks/Security.framework/Security
0x31dba000 - 0x31dbdfff libsystem_network.dylib armv7 <48fe217ed667308bb9413c11f5b5b31d> /usr/lib/system/libsystem_network.dylib
0x31dd3000 - 0x31ea3fff WebKit armv7 /System/Library/PrivateFrameworks/WebKit.framework/WebKit
0x31fc0000 - 0x32017fff CoreAudio armv7 /System/Library/Frameworks/CoreAudio.framework/CoreAudio
0x32018000 - 0x32057fff QuickLook armv7 <2f7ad2dfd31f3473a89156da7f70740c> /System/Library/Frameworks/QuickLook.framework/QuickLook
0x32058000 - 0x32062fff libbz2.1.0.dylib armv7 <28583efb9f1b38e7ae83c667b07dbd08> /usr/lib/libbz2.1.0.dylib
0x32134000 - 0x32159fff OpenCL armv7 <051a834ba5583f47876f0c8b9a1e3dda> /System/Library/PrivateFrameworks/OpenCL.framework/OpenCL
0x32171000 - 0x32187fff libdispatch.dylib armv7 <86ed1499ae1e3f5ba389e657f6a23ced> /usr/lib/system/libdispatch.dylib
0x3219a000 - 0x3219efff IOSurface armv7 <0f003f50b18e3dbf87607d819e0ac6b9> /System/Library/PrivateFrameworks/IOSurface.framework/IOSurface
0x32241000 - 0x32386fff CoreGraphics armv7 <649b7b4a430a340b8c2b85c6fb4e1369> /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics
0x32388000 - 0x3239efff EAP8021X armv7 <3f7bd850face343495b2c542ef63d44d> /System/Library/PrivateFrameworks/EAP8021X.framework/EAP8021X
0x3240b000 - 0x32411fff MobileKeyBag armv7 <18472eec0dfa3aa993f4ae7f34ec5c52> /System/Library/PrivateFrameworks/MobileKeyBag.framework/MobileKeyBag
0x32412000 - 0x3242ffff libsystem_info.dylib armv7 <8e5dd82833293382a08f11517e9dcb9b> /usr/lib/system/libsystem_info.dylib
0x324de000 - 0x32977fff UIKit armv7 <87348d5d0d043aa095840765b6d73999> /System/Library/Frameworks/UIKit.framework/UIKit
0x32a5a000 - 0x32a65fff AccountSettings armv7 <090bb6a4f97433089b5cabc6a40c619a> /System/Library/PrivateFrameworks/AccountSettings.framework/AccountSettings
0x32b75000 - 0x32b7cfff AssetsLibraryServices armv7 /System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices
0x32be9000 - 0x32d0dfff JavaScriptCore armv7 <322e347adc08308ca55fc7de9598248c> /System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore
0x32d21000 - 0x32e0ffff libiconv.2.dylib armv7 <0f52661fd7af3a448b95f8d93d20f3f7> /usr/lib/libiconv.2.dylib
0x32edf000 - 0x32ee2fff libmacho.dylib armv7 /usr/lib/system/libmacho.dylib
0x32f59000 - 0x32f5ffff liblockdown.dylib armv7 <4e3671438f71326bbc507cb197a31322> /usr/lib/liblockdown.dylib
0x32fc8000 - 0x32fccfff IOMobileFramebuffer armv7 /System/Library/PrivateFrameworks/IOMobileFramebuffer.framework/IOMobileFramebuffer
0x335cc000 - 0x33616fff libvDSP.dylib armv7 /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/libvDSP.dylib
0x3361f000 - 0x3363efff libSystem.B.dylib armv7 <17803796ac1d31bdab85e651a74d5e0d> /usr/lib/libSystem.B.dylib
0x33649000 - 0x3364dfff libGFXShared.dylib armv7 <0a36fb9d60a43479943bafb2f81313b1> /System/Library/Frameworks/OpenGLES.framework/libGFXShared.dylib
0x3364e000 - 0x3365dfff SpringBoardServices armv7 <083fb830455f3cd0869bf54bfd91108c> /System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices
0x3369b000 - 0x33764fff Celestial armv7 /System/Library/PrivateFrameworks/Celestial.framework/Celestial
0x337af000 - 0x337f8fff CoreMedia armv7 <16e247e3f4a43fc5a72695092cf8ba96> /System/Library/Frameworks/CoreMedia.framework/CoreMedia
0x33812000 - 0x3381afff MobileWiFi armv7 /System/Library/PrivateFrameworks/MobileWiFi.framework/MobileWiFi
0x3381b000 - 0x33831fff DictionaryServices armv7 /System/Library/PrivateFrameworks/DictionaryServices.framework/DictionaryServices
0x3387b000 - 0x33880fff libcopyfile.dylib armv7 <49003f67c59730c9ac9c499517a3bb8b> /usr/lib/system/libcopyfile.dylib
0x33893000 - 0x33920fff libsystem_c.dylib armv7 <2eb267ac3b5e32b0a43a61ccb98e6dd1> /usr/lib/system/libsystem_c.dylib
0x33925000 - 0x3392cfff ProtocolBuffer armv7 <00599097fff03d02896974966dee6dda> /System/Library/PrivateFrameworks/ProtocolBuffer.framework/ProtocolBuffer
0x33a9e000 - 0x33aaffff DataAccessExpress armv7 <2306f236fe113baba3934f1884d36a47> /System/Library/PrivateFrameworks/DataAccessExpress.framework/DataAccessExpress
0x33ab2000 - 0x33ab3fff DataMigration armv7 <4179a9f217a8300d93c14b6fd87e5c31> /System/Library/PrivateFrameworks/DataMigration.framework/DataMigration
0x33cfb000 - 0x33cfffff libAccessibility.dylib armv7 /usr/lib/libAccessibility.dylib
0x33f52000 - 0x3410efff ImageIO armv7 /System/Library/Frameworks/ImageIO.framework/ImageIO
0x341e1000 - 0x3421dfff AppSupport armv7 <202262953e2d343cbf489fe1e308dba4> /System/Library/PrivateFrameworks/AppSupport.framework/AppSupport
0x342ad000 - 0x3456efff libLAPACK.dylib armv7 <5490a87fe5153771b9c67940292842ba> /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/libLAPACK.dylib
0x3456f000 - 0x3457efff GenerationalStorage armv7 /System/Library/PrivateFrameworks/GenerationalStorage.framework/GenerationalStorage
0x345b0000 - 0x34af4fff FaceCoreLight armv7 /System/Library/PrivateFrameworks/FaceCoreLight.framework/FaceCoreLight
0x34afa000 - 0x34bb5fff AVFoundation armv7 /System/Library/Frameworks/AVFoundation.framework/AVFoundation
0x34bbb000 - 0x34bcffff PersistentConnection armv7 <47b0ba3bcfd230a192119445de86cef1> /System/Library/PrivateFrameworks/PersistentConnection.framework/PersistentConnection
0x34bd0000 - 0x34bd3fff libcompiler_rt.dylib armv7 <414332f9a55238bab2cbec323e0fc8da> /usr/lib/system/libcompiler_rt.dylib
0x34d45000 - 0x34d4afff libsystem_dnssd.dylib armv7 <11ce894432a73b9485cce6f5b1ea6488> /usr/lib/system/libsystem_dnssd.dylib
0x34d4d000 - 0x34d88fff libCGFreetype.A.dylib armv7 <1f70c1e94e333f0bb0866143b2abb0a7> /System/Library/Frameworks/CoreGraphics.framework/Resources/libCGFreetype.A.dylib
0x34d89000 - 0x34d89fff libunwind.dylib armv7 /usr/lib/system/libunwind.dylib
0x34d8a000 - 0x34d8afff liblangid.dylib armv7 <342170169bf232a0888912f5ef97112d> /usr/lib/liblangid.dylib
0x34d91000 - 0x34da0fff OpenGLES armv7 <6d1afb451f50310895ec59864739e781> /System/Library/Frameworks/OpenGLES.framework/OpenGLES
0x34e23000 - 0x34efdfff vImage armv7 <42a5e58ff1b9350cad90de36bd3ceb09> /System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/vImage
0x34efe000 - 0x34f0afff libCRFSuite.dylib armv7 /usr/lib/libCRFSuite.dylib
0x34f7d000 - 0x34fa0fff Bom armv7 <0e6087f75a81345ea81751197ccb712c> /System/Library/PrivateFrameworks/Bom.framework/Bom
0x35013000 - 0x3501ffff CoreVideo armv7 <474c89eb09fe3464851a20d76052341b> /System/Library/Frameworks/CoreVideo.framework/CoreVideo
0x35095000 - 0x35096fff libsystem_blocks.dylib armv7 <4bb9797771d037879bec814fe750d86d> /usr/lib/system/libsystem_blocks.dylib
0x350e0000 - 0x35129fff libc++.1.dylib armv7 /usr/lib/libc++.1.dylib
0x3512a000 - 0x35185fff StoreServices armv7 <01e6b5e7449d39b8bc11e39fc217e645> /System/Library/PrivateFrameworks/StoreServices.framework/StoreServices
0x3521b000 - 0x3521cfff libremovefile.dylib armv7 <77460820431837d68f19c81d53b6ca83> /usr/lib/system/libremovefile.dylib
0x35418000 - 0x3541efff MobileIcons armv7 <2f4c13053206306996726629b0b7eb01> /System/Library/PrivateFrameworks/MobileIcons.framework/MobileIcons
0x3547c000 - 0x35485fff libMobileGestalt.dylib armv7 /usr/lib/libMobileGestalt.dylib
0x3551c000 - 0x35520fff libcache.dylib armv7 <607095842baf3c41be3127ed773582ea> /usr/lib/system/libcache.dylib
0x35595000 - 0x35713fff Foundation armv7 /System/Library/Frameworks/Foundation.framework/Foundation
0x3572b000 - 0x35733fff Librarian armv7 <6bcbcb11d2173d5ab8f6f6484e59b407> /System/Library/PrivateFrameworks/Librarian.framework/Librarian
0x357c4000 - 0x357cefff libvMisc.dylib armv7 /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/libvMisc.dylib
0x3580e000 - 0x3580ffff libdyld.dylib armv7 /usr/lib/system/libdyld.dylib
0x35ba2000 - 0x35bc5fff PrintKit armv7 <279fb51deec3377ab9f820af2da4d915> /System/Library/PrivateFrameworks/PrintKit.framework/PrintKit
0x35bc6000 - 0x35bc8fff MobileInstallation armv7 <4c0648df13af341e88ddca80be687794> /System/Library/PrivateFrameworks/MobileInstallation.framework/MobileInstallation
0x35c3e000 - 0x35c81fff libcommonCrypto.dylib armv7 /usr/lib/system/libcommonCrypto.dylib
0x35e98000 - 0x35e9efff liblaunch.dylib armv7 <8d5c3270e68e3dbbb2a72efd71314bf6> /usr/lib/system/liblaunch.dylib
0x35ebf000 - 0x35f96fff CFNetwork armv7 <794a80e086d23041bfdec139b01e80a2> /System/Library/Frameworks/CFNetwork.framework/CFNetwork
0x35f97000 - 0x35fb0fff libRIP.A.dylib armv7 /System/Library/Frameworks/CoreGraphics.framework/Resources/libRIP.A.dylib
0x36008000 - 0x36087fff libsqlite3.dylib armv7 /usr/lib/libsqlite3.dylib
0x36095000 - 0x360abfff libmis.dylib armv7 /usr/lib/libmis.dylib
0x361bd000 - 0x361c0fff CaptiveNetwork armv7 /System/Library/PrivateFrameworks/CaptiveNetwork.framework/CaptiveNetwork
0x361c9000 - 0x361c9fff libkeymgr.dylib armv7 <791bb8b832943b2392c0c35228f52e09> /usr/lib/system/libkeymgr.dylib
0x361ca000 - 0x361d0fff libnotify.dylib armv7 <19d7596821403d998017f03678d40514> /usr/lib/system/libnotify.dylib
0x36227000 - 0x36227fff libgcc_s.1.dylib armv7 <69d8dab7388b33d38b30708fd6b6a340> /usr/lib/libgcc_s.1.dylib
0x36350000 - 0x363c9fff ProofReader armv7 <09d057676f6837cd9e7a735444b67e77> /System/Library/PrivateFrameworks/ProofReader.framework/ProofReader
0x363ca000 - 0x36477fff libxml2.2.dylib armv7 <78462273eb5b38d1a0873b02f0e35e23> /usr/lib/libxml2.2.dylib
0x364a1000 - 0x364a1fff libCVMSPluginSupport.dylib armv7 <85582e1094633fccb52b50ca13c5a5d0> /System/Library/Frameworks/OpenGLES.framework/libCVMSPluginSupport.dylib
0x3651b000 - 0x3651dfff libsp.dylib armv7 <161d57cdb91438fbb5fb975a66bc3666> /usr/lib/libsp.dylib
0x36525000 - 0x3655afff SystemConfiguration armv7 <68dbad71a3cc32e5941ad70820f88caa> /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration
0x36594000 - 0x365cdfff VideoToolbox armv7 <49f9f09f23f7396b94a29bb1280759fe> /System/Library/PrivateFrameworks/VideoToolbox.framework/VideoToolbox
0x365ce000 - 0x3660efff libGLImage.dylib armv7 <9440420d838a382caa175399d74a5044> /System/Library/Frameworks/OpenGLES.framework/libGLImage.dylib
0x3660f000 - 0x36659fff CoreTelephony armv7 <7cb3680db3bb36a0b59b6d8e8cecf374> /System/Library/Frameworks/CoreTelephony.framework/CoreTelephony
0x36763000 - 0x367acfff AddressBook armv7 <9ac3368232663b5786382e33c3773678> /System/Library/Frameworks/AddressBook.framework/AddressBook
0x367b0000 - 0x367b1fff libsystem_sandbox.dylib armv7 /usr/lib/system/libsystem_sandbox.dylib
0x367b4000 - 0x367b5fff libdnsinfo.dylib armv7 <1dadb6191d1835e5b078594218ce14f3> /usr/lib/system/libdnsinfo.dylib
0x36895000 - 0x368dafff GeoServices armv7 <6c9eb6372f723a57852cfc9ed7b78e31> /System/Library/PrivateFrameworks/GeoServices.framework/GeoServices
0x368db000 - 0x3691ffff MobileCoreServices armv7 /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices
0x36b82000 - 0x36ef3fff TextInput armv7 /System/Library/PrivateFrameworks/TextInput.framework/TextInput
0x36f63000 - 0x36fd3fff CoreImage armv7 /System/Library/Frameworks/CoreImage.framework/CoreImage
0x36fd6000 - 0x36fe7fff libxpc.dylib armv7 <637167f4fa5c3cee99418295843e1580> /usr/lib/system/libxpc.dylib
0x36fe8000 - 0x37180fff CoreData armv7 <75030d6f36f9394592dd35af610e8960> /System/Library/Frameworks/CoreData.framework/CoreData
0x371f1000 - 0x371f6fff CrashReporterSupport armv7 /System/Library/PrivateFrameworks/CrashReporterSupport.framework/CrashReporterSupport
0x371fa000 - 0x37245fff CoreLocation armv7 <77f81f93c6483079b547b3552b0247d2> /System/Library/Frameworks/CoreLocation.framework/CoreLocation
0x37277000 - 0x372b4fff IOKit armv7 <284ee3241c4a3b43b81b9ff514997013> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x372c1000 - 0x3751bfff MediaToolbox armv7 /System/Library/PrivateFrameworks/MediaToolbox.framework/MediaToolbox
0x37959000 - 0x379aafff libstdc++.6.dylib armv7 /usr/lib/libstdc++.6.dylib
0x379ab000 - 0x379b7fff libz.1.dylib armv7 <8e4095644cc33c97aa5f9f0620387f88> /usr/lib/libz.1.dylib
0x379c5000 - 0x37a6ffff libBLAS.dylib armv7 <9aabff01422f3cb8960f93d11d2b6de1> /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/libBLAS.dylib
0x37adc000 - 0x37c25fff libicucore.A.dylib armv7 <1bc960f75d633190a09b093209a9f0c5> /usr/lib/libicucore.A.dylib
0x37c26000 - 0x37c26fff vecLib armv7 <106ef8294b0d3c2d89e9230527846227> /System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/vecLib
0x37c46000 - 0x37c97fff CoreText armv7 <23150093d39b393e9bc5f8230176df47> /System/Library/Frameworks/CoreText.framework/CoreText
0x37c98000 - 0x37df5fff libmecabra.dylib armv7 <170c82a3c716372abe7ae0aae96d4805> /usr/lib/libmecabra.dylib

Warnings even after making ARC in compile sources

Hi, I'm going through the well documented source by you, and word by word, and after I add the -fobj-arc to make it ARC, to remove the warning, I'm ending up with the warning but this time the semantic property warnings din't show up but stayed warnings are

"#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC)."

Help me out please.!

I see I have converted my project to ARC by following this instructions.
http://maniacdev.com/2012/01/easily-get-non-arc-enabled-open-source-libraries-working-in-arc-enabled-projects/

Analyze Warning DDTTYLogger.m VLA Zero Size

Not sure if this is a problem or not, but I try to keep zero analyze issues in my code. So this sticks out.

.../Lumberjack/DDTTYLogger.m:1215:3: warning: Declared variable-length array (VLA) has zero size
                char msgStack[useStack ? (msgLen + 1) : 0];
                ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Assuming 'isaTTY' is not equal to 0
Assuming 'logMsg' is non-nil
Declared variable-length array (VLA) has zero size

Declaration shadows variable in global scope

If you have the Hidden Local Variables LLVM compiler 3.0 warning turned on you will get a warning in 2 identical lines in DDLog.m:

dispatch_queue_t loggingQueue = [DDLog loggingQueue];

Rename the local declaration to fix.

32bit

Is there any interest in providing a version of CocoaLumberjack that supports 32bit on 10.6? It's something I'm going to be needing personally for the time being, so I figure whatever effort I spend on it might as well be useful for someone else.

There are two potential strategies here: providing an ARC-free branch (or ifdef'd) and using GC on x86. The benefit of an ARC-free branch is not forcing GC on x86, and the benefit of requiring GC is that there wouldn't need to be multiple branches and potentially divergent code. I'm OK with forcing GC on 32bit to make life easier... It's what I already do for another project.

Thoughts?

semaphore_wait_trap : failed to resume in time

I get the below error while resuming the application there is some code in on resume which does the loging. but after showing splash screen app crashes with below logs.
What could be going wrong?

0 libsystem_kernel.dylib 0x306eb060 semaphore_wait_trap + 8
1 libdispatch.dylib 0x33879472 _dispatch_group_wait_slow + 146
2 libdispatch.dylib 0x338793d2 dispatch_group_wait$VARIANT$mp + 22
3 XXXX 0x0012d38c +DDLog lt_log:
4 XXXX 0x0012c824 __+[DDLog queueLogMessage:asynchronously:]_block_invoke_1 (DDLog.m:476)
5 libdispatch.dylib 0x338778c8 _dispatch_barrier_sync_f_invoke + 20
6 libdispatch.dylib 0x33877728 dispatch_barrier_sync_f$VARIANT$mp + 56
7 libdispatch.dylib 0x33877348 dispatch_sync_f$VARIANT$mp + 12
8 libdispatch.dylib 0x338779f2 dispatch_sync$VARIANT$mp + 26
9 XXXX 0x0012c7d0 +DDLog queueLogMessage:asynchronously:
10 XXXX 0x0012ca8a +DDLog log:level:flag:context:file:function:line:withTag:format:

DDFileLogger.h : described location of log files in error

The comments in DDFileLogger.h say that log files are created in:

"~/Library/Application Support/Application Name/Logs"

but they are actually created in:

"~/Library/Logs/Application Name/"

A minor error, and easily discovered, but it might as well be corrected.

Using Lumberjack on other threads

It looks like there may be an issue using the DDLog macros on other threads. I initialized the framework on the main thread (appDidFinishLaunching), but whenever I try to use the DDLog macros on a background thread nothing is written. I am writing logs out on a subclassed NSOperation class.

Add indent/unindent for recursive debugging

Great framework, thanks for building it!

I frequently work with recursive data structures, and it helps considerably to use indentation to demark the different levels in recursive calls. I looked at using a custom formatter, but realized quickly that asychronous logging made that worthless. It'd be nice to have something like

[DDLogger indent]
[DDLogger unindent]

that would affect an integer indent level in the DDLogMessage that was passed to the formatter.

Multiple memory leaks in DDLogMessage

When running the profile over my application for iOS

  • XCode 4.2.1
  • No ARC
  • Using a custom log formatter (from the example in the docs)

I found a set of memory leaks in the DDLogMessage class

[DDLogMessage methodName]
[DDLogMessage threadID]
[DDLogMessage fileName]

Each of these methods alloc's a new string, assigns it to a member but then doesn't decrement the retain count at the end of the method

e.g.

  • (NSString *)methodName
    {
    if (methodName == nil && function != NULL)
    {
    methodName = [[NSString alloc] initWithUTF8String:function];
    }

    return methodName;
    }

the line with the alloc should have an autorelease at the end of it right?

doesn't compile in C functions

DDLog does not compile in C functions, which means it is not a direct replacement for NSLog:

// this doesn't compile
static void foo()
{
  DDLogVerbose(@"bar");
}
// this compiles
static void foo()
{
  NSLog(@"bar");
}

Failure on start when using DDTTYLogger with XCode 4.4 GM seed

XCode 4.4 GM seed. EXC_BAD_ACCESS when running app using DDTTYLogger in XCode 4.4

EXC_BAD_ACCES in thread 4: cocoa.lumberjack.ttyLogger

@DDTTYLogger.m, line 1262:
NSDateComponents *components = [calendar components:calendarUnitFlags fromDate:logMessage->timestamp];

Share scheme of TextXcodeColors Mobile

I was looking at the example for XcodeColors for iOS and noticed it did not work out of the box.

The ENV variable is missing. This is because the scheme is auto-generated by Xcode and does not include the ENV variable automatically. It is possible to share the the scheme (Manage Schemes -> Share checkbox) and thus have it be a part of the repository. This would make the project work out of the box.

Loggers don't flush in Command Line Tool

I use CocoaLumberjack in an Command Line Tool using Xcode 4.5. In code I add a tty and an asl logger. I do some logging with DDLogCInfo(). The documentation says the loggers flush when the application terminates but they don't โ€“ maybe sometimes. So I added the following code in main() after I add the loggers and it worked:

atexit_b(^{ @autoreleasepool {
    [DDLog flushLog];
}})

I removed it again and there was only one logged line โ€“ the first one, even if I called the program from command line. I looked a bit in your code and set an breakpoint in +[DDLog applicationWillTerminate:] -- and it wasn't called!

EXC_BAD_ACCESS in the logger

For some reason I'm getting EXC_BAD_ACCESS error on the following line

[loggerNode->logger logMessage:logMessage];

The method body is attached below. I'm using the latest commit.

/**
 * This method should only be run on the logging thread/queue.
**/
+ (void)lt_log:(DDLogMessage *)logMessage
{
// Execute the given log message on each of our loggers.

if (numProcessors > 1)
{
    // Execute each logger concurrently, each within its own queue.
    // All blocks are added to same group.
    // After each block has been queued, wait on group.
    // 
    // The waiting ensures that a slow logger doesn't end up with a large queue of pending log messages.
    // This would defeat the purpose of the efforts we made earlier to restrict the max queue size.

    for (DDLoggerNode *loggerNode in loggers)
    {
        dispatch_group_async(loggingGroup, loggerNode->loggerQueue, ^{ @autoreleasepool {

            [loggerNode->logger logMessage:logMessage];

        }});
    }

    dispatch_group_wait(loggingGroup, DISPATCH_TIME_FOREVER);
}
else

[Feature request] : StaticLibrary/Framework xcode project

Hi, robbiehanson.
Thank you for your awesome CocoaLumberjack framework.

The only thing it is missing is a separate XCode project with a static library target. Using source code references filesystem is not the best way to share your code.
It would be even easier to use your logger if it was packaged as an Objective-C framework.

If you need any help with this - just contact me (mailto:[email protected]) and provide some write-permissions for this repo.


Regards,
Oleksandr Dodatko.

Crashing in +[DDLog isRegisteredClass] in ARC+Simulator

Hi,

It SEEMS like the method +[DDLog isRegisteredClass] will crash a project when using it with ARC + Simulator.

Environment:
Lion 10.7.3
iOS 5 SDK
Xcode 4.2.1
iPhone 5.0 Simulator

Currently, the method contains a macro #if check that reads:

if TARGET_OS_IPHONE (near line 307)

For running in the Simulator, it needs to read:

if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR

such that the non-iOS code gets executed.

If the code is allowed to stand, it will trip up on the following classes:

"ARCLite"
"__NSGenericDeallocHandler"
"NSZombie"
"Object"
"__IncompleteProtocol"
"NSLeafProxy"
"Protocol"
"NSMessageBuilder"

which will throw a does not implement "-methodSignatureForSelector" exception on NSInvocation.

Thanks.

Use cocoaHttpServer to stream video

Hi i am using your project to download a file and stream it to a client that made a request.

i use this method:

  • (NSObject *)httpResponseForMethod:(NSString *)method URI:(NSString *)path

and add to it :
NSData *tmpData = [NSData dataWithContentsOfFile:filePath];
return [[[HTTPDataResponse alloc] initWithData:tmpData] autorelease];

i have a problem that i want to send this file before i finish to download it to the device and while i download it it will keep of sending the rest of the file.

it is possible with cocoahttpserver?

extra @ character

  • (NSString *)description
    {
    return [@{@"filePath": self.filePath,
    @"fileName": self.fileName,
    @"fileAttributes": self.fileAttributes,
    @"creationDate": self.creationDate,
    @"modificationDate": self.modificationDate,
    @"fileSize": @(self.fileSize),
    @"age": @(self.age),
    @"isArchived": @(self.isArchived)} description];
    }

extra @ character
does not compile

Crash in DDLogFormatter subclass when accessing logMessage->timestamp

I created a custom log formatter that is nearly identical to the example you posted under the wiki section. It seemed to work well so I went ahead and released the app. After some use, I am now experiencing an intermittent crash in my custom log formatter when access the timestamp instance variable of the logMessage passed into formatLogMessage. Specific, this line here is causing the crash, and it's rooted within the timestamp.

NSString *dateAndTime = [dateFormatter stringFromDate:(logMessage->timestamp)];

I've only noticed the issue when opening the app, and it's coming out of the background state. I haven't experienced it during normal use of the app once it's been running for a second or two. For what it's worth, when the app first comes out of a background state, I communicate with a remote server to retrieve any updated config info. It is typically a call to DDLogVerbose from within one of these API Interface functions.

Here is my complete custom formatter...

@implementation iNotaryLogFormatter

- (id)init
{
    self = [super init];
    if (self) {
        dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
        [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss:SSS"];
    }
    return self;
}

- (NSString *)formatLogMessage:(DDLogMessage *)logMessage
{
    NSString *logLevel;
    switch (logMessage->logFlag) {
        case LOG_FLAG_ERROR: logLevel = @"E"; break;
        case LOG_FLAG_WARN: logLevel = @"W"; break;
        case LOG_FLAG_INFO: logLevel = @"I"; break;
        default: logLevel = @"V"; break;
    }

    NSString *dateAndTime = [dateFormatter stringFromDate:(logMessage->timestamp)];
    NSString *logMsg = logMessage->logMsg;
    NSString *filename = [NSString stringWithUTF8String:logMessage->file];

    return [NSString stringWithFormat:@"%@ %@ | %@ [%d] %@\n", 
            logLevel, dateAndTime, 
            [filename lastPathComponent],
            logMessage->lineNumber,
            logMsg];
}

- (void)dealloc
{
    [dateFormatter release];
    [super dealloc];
}

How Lumberjack can work for command line application?

I want to develop a command line tool using your Lumberjack. It seems that Lumberjack need NSColor which is contained in AppKit.

So, is it possible that use Lumberjack in command line application where AppKit is not needed ?

Thanks in advance!

sunwrt

Adding new variable to 'DDLog' macro

Hi robbiehanson,
Thank you very much for the great scalable utility. I have custom need in which I need to add tag with the formatted message, I already have added custom formatter ( MyFormatter) by confirming to DDLogFormatter.
The solution I see here is that I need to add new tag variable to DDLogMessage as each log is executed in separate thread.

OPTION 1: Add variable to DDLog call
Change the whole call sequence of all the macros.
For example if I want to make

DDLogVerbose(@"test");
as
DDLogVerbose(@"TAG",@"test");

I will need to add this extra variable to whole call sequence and all the other macros.
DDLogVerbose -> LOG_OBJC_MAYBE -> LOG_MAYBE -> LOG_MACRO ->[ DDLog log: ...];

OPTION 2: Add string variable to MyFormatter and change that variable before every DDLog call and in the 'formatLogMessage' I look for its value and customize the return string accordingly.
Problem here is all threads would manipulate this variable and will give inaccurate result.

OPTION 3: To add thread-safety to the variable discussed in OPTION 2. But, that would add performance hit.

So, do you see any quick solution to this, which would require less changes to the existing code??
Thanks in advance.

CustomFormatters wiki page out of date with current DDLogFormatter protocol

The current wiki page refers to DDLogFormatter protocol with the following optional methods:

- (void)didAddToLogger:(id <DDLogger>)logger;
- (void)willRemoveFromLogger:(id <DDLogger>)logger;

However since at least 1.2.3 (from what I can tell) these have been

- (void)didAddLogger;
- (void)willRemoveLogger;

Xcode 4.5

Hello,

I would like to use your lib for coloring my debug output.
With folowing steps on the your "Getting Started" quide I try add CocoaLumberjack to my project, But I have next problems:
I don't see any log in the console with next code:

DDLogInfo(@"Broken sprocket detected!");
DDLogVerbose(@"User selected file:%@ withSize:%u", @"asdasd", 222);

in the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions methods I add

DDLog addLogger:[DDASLLogger sharedInstance]];
[DDLog addLogger:[DDTTYLogger sharedInstance]];
[[DDTTYLogger sharedInstance] setColorsEnabled:YES];

but no result. ((
Can you help me with this plroblem

P.S. My Xcode Version 4.5.1 (4G1004). iOS SDK 6.0. Mac os version 10.8.2(12C60)

thank you
WBR
Maxim

duplicate symbols for architecture armv7 (clang error)

dgqncsbjskiktcaeoqjmjpxkiaqr/Build/Intermediates/HHSlot.build/Debug-iphoneos/HHSlot-iPad.build/Objects-normal/armv7/DDAbstractDatabaseLogger-3EBF9C247AC7D879.o
ld: 13 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

DDLogFileManagerDefault can be deallocated while still KVO'ing itself

DDLogFileManagerDefault does a [self addObserver:self forKeyPath:@"maximumNumberOfLogFiles" options:kvoOptions context:nil]; in initWithLogsDirectory but never removes itself as an observer. Was able to fix by adding

  • (void)dealloc
    {
    [self removeObserver:self forKeyPath:@"maximumNumberOfLogFiles"];
    }

removing DDAbstractDatabaseLogger

I'm having difficultly removing DDAbstractDatabaseLogger with the call [DDLog removeLogger:databaseLogger]. The error EXC_BAD_INSTRUCTION occurs when calling dispatch_release(saveTimer) in the - (void)destroySaveTimer method. In the - (void)willRemoveLogger method, the saveTimer is suspended before calling release. It seems that the issue is because there is a unbalanced number of calls to dispatch_suspend and dispatch_resume on saveTimer. Is dispatch_suspend required as dispatch_source_cancel is called in - (void)destroySaveTimer which prevents any further invocation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.