Newbie: Logging from a library

399 views
Skip to first unread message

NM

unread,
Mar 20, 2012, 12:40:49 PM3/20/12
to CocoaLumberjack
Hi,

I have just started playing with the CocoaLumberjack and I was
pleasantly surprised...it looks really great! I have couple of
questions:

1) Can it be used to log from a library/Cocoa framework? I didn't seem
to find such an example.
2) Can its log level be controlled via a configuration file(similar to
what is possible from log4net)?
3) I'm using the non-ARC version 1.2.3. Is it the latest for the non-
ARC?
4) Can the FileLogger be used to roll based on a maximum size only(and
not time) and specify maximum/unlimited number of files?
4) What is the exact logistics to use it in a commercial project? Will
including a copy of its BSD license in a notice.text file will do?

Thanks in advance and regards

Robbie Hanson

unread,
Mar 20, 2012, 5:13:14 PM3/20/12
to cocoalu...@googlegroups.com
Good questions. I'll do my best to answer your questions.

1) Can it be used to log from a library/Cocoa framework?

If I understand correctly, you're wondering if open source frameworks can use Lumberjack to replace their primitive NSLog statements with something more flexible and useful?

The answer is YES. Here's an example:

The entire framework uses "XMPPLog<Level>(…)". It makes the framework very transparent to those using it, by allowing them to easily enable logging in various components, and really see exactly what the code is doing.

Also, it makes use of the "logging context". Every single log statement coming from XMPPFramework has a specific logging context.  This is an integer that is set in all log messages, and allows developers to easily filter and/or redirect log statements coming from XMPPFramework vs log statements coming from their own application.


2) Can its log level be controlled via a configuration file?

I've experimented with this idea a bit, but never fully finished the implementation. Take a look at the "experimental" branch, then:
Xcode/LogLevelsConfigFile

Specifically the files DDLogLevelsConfig, DebugLogging.txt & ReleaseLogging.txt

This is a work in progress, so feel free to give me feedback.

3) I'm using the non-ARC version 1.2.3. Is it the latest for the non-ARC?

The non-ARC branch is deprecated. You are strongly encouraged to upgrade to the latest codebase. See this wiki page for information on supporting ARC versions of Lumberjack in Non-ARC projects:


4) Can the FileLogger be used to roll based on a maximum size only(and
not time) and specify maximum/unlimited number of files?

Theoretically, you can set these values to zero to disable them. But I just checked, and this isn't currently supported. This is a bug.

Until fixed, you can just set them to really big values.
For example:

fileLogger.rollingFrequency = [[NSDate distantFuture] timeIntervalSinceNow];

5) What is the exact logistics to use it in a commercial project? Will

including a copy of its BSD license in a notice.text file will do?

For Mac apps, yes the BSD license in some text file will do.

For iOS apps… well you're free to include a text file in your app bundle that has the BSD license. But we all know it won't be visible to anyone. So for shipped iOS apps in the app store, I've simply been stating that attribution isn't required. However, I'd appreciate it if you mention the project somewhere (could be on a credits screen, the app description in the store, or just on your website somewhere). Not required, but welcomed.

-Robbie Hanson



--
You received this message because you are subscribed to the Google Groups "CocoaLumberjack" group.
To post to this group, send email to cocoalu...@googlegroups.com.
To unsubscribe from this group, send email to cocoalumberja...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cocoalumberjack?hl=en.


Navin Mishra

unread,
Mar 21, 2012, 2:54:17 PM3/21/12
to cocoalu...@googlegroups.com
Thanks...appreciate quick and detailed reply. Please see some further comments/questions inline:

Thanks again and regards



From: Robbie Hanson <robbie...@deusty.com>
To: cocoalu...@googlegroups.com
Sent: Tuesday, March 20, 2012 2:13 PM
Subject: Re: Newbie: Logging from a library

Good questions. I'll do my best to answer your questions.

1) Can it be used to log from a library/Cocoa framework?

If I understand correctly, you're wondering if open source frameworks can use Lumberjack to replace their primitive NSLog statements with something more flexible and useful?

The answer is YES. Here's an example:

The entire framework uses "XMPPLog<Level>(…)". It makes the framework very transparent to those using it, by allowing them to easily enable logging in various components, and really see exactly what the code is doing.

Also, it makes use of the "logging context". Every single log statement coming from XMPPFramework has a specific logging context.  This is an integer that is set in all log messages, and allows developers to easily filter and/or redirect log statements coming from XMPPFramework vs log statements coming from their own application.

>> Thanks...I will browse through that project. I was more asking whether the Lumberjack can be used from Cocoa plug-in/bundle projects which are not executables and whether each such bundle can possibly have its own separate log file.

2) Can its log level be controlled via a configuration file?

I've experimented with this idea a bit, but never fully finished the implementation. Take a look at the "experimental" branch, then:
Xcode/LogLevelsConfigFile

Specifically the files DDLogLevelsConfig, DebugLogging.txt & ReleaseLogging.txt

This is a work in progress, so feel free to give me feedback.
>>Will do. It will be great addition to the framework!

3) I'm using the non-ARC version 1.2.3. Is it the latest for the non-ARC?

The non-ARC branch is deprecated. You are strongly encouraged to upgrade to the latest codebase. See this wiki page for information on supporting ARC versions of Lumberjack in Non-ARC projects:

>> That is a bummer for sure :( I have not migrated to ARC especially because some third party libraries I am using are not yet using ARC. Just wondering...would the current non-ARC branch too much behind the ARC branch w.r.t. bug fixes so that it is not recommended to use the 1.2.3 in a production application? I'm still using XCode 4.0.2 on MAC Snow Leopard 10.6.8. Should I need to use the latest Lumberjack(that is with ARC), can I still use it in the XCode 4.0.2 and have only Lumberjack files compiled with ARC? Or I must upgrade to XCode 4.2?

4) Can the FileLogger be used to roll based on a maximum size only(and
not time) and specify maximum/unlimited number of files?

Theoretically, you can set these values to zero to disable them. But I just checked, and this isn't currently supported. This is a bug.

Until fixed, you can just set them to really big values.
For example:

fileLogger.rollingFrequency = [[NSDate distantFuture] timeIntervalSinceNow];
>> Thanks. It looks like a negative number works as well. BTW what might be the way to change the log file name? Only by writing a custom FileLogger?

5) What is the exact logistics to use it in a commercial project? Will
including a copy of its BSD license in a notice.text file will do?

For Mac apps, yes the BSD license in some text file will do.

For iOS apps… well you're free to include a text file in your app bundle that has the BSD license. But we all know it won't be visible to anyone. So for shipped iOS apps in the app store, I've simply been stating that attribution isn't required. However, I'd appreciate it if you mention the project somewhere (could be on a credits screen, the app description in the store, or just on your website somewhere). Not required, but welcomed.
>> Thanks!
Reply all
Reply to author
Forward
0 new messages