Re: Seeking feedback on an API for a logging object.
Re: Seeking feedback on an API for a logging object.
- Subject: Re: Seeking feedback on an API for a logging object.
- From: James Quick <email@hidden>
- Date: Sat, 19 Jul 2003 20:37:11 -0400
On Friday, July 18, 2003, at 05:01 PM, Chris Hanson wrote:
On Friday, July 18, 2003, at 12:42 PM, James Quick wrote:
I am designing on an object to provide, logging services.
Why not just use Log4Cocoa? http://sourceforge.net/projects/log4cocoa/
It already exists and it already works. If it's missing a feature you
need, it's probably easier to add it than to write an entirely new
framework from scratch.
Thank you for the heads up, I appreciate your suggestion of an
alternative.
Unfortunately Cocoa4J implements a design which is not flexible
enough for my requirements.
I have already implemented a superset of NSLog() and syslog()
functionality.
The implementation adds an additional layer of abstraction. The output
via syslog() calls or to a file descriptor is invoked after failure of
pattern matches
which trigger zero or more target/action invocations (0 blocks the
default, thus
providing both positive and negative filtering of events.) This is
driven by one or
more dictionaries which let the user determine how to respond to a
logged event.
In addition to accepting message format strings and format argument, a
message
may also be annotated with additional state available to the actions,
and a set of
tokens which are used as input to the pattern matching engine.
This layer of generality in the logger is there not only to replace the
fixed facility/priority
tuple used in traditional logging systems, but also to provide support
required by
the testing suite I am developing. I did spend a couple of days
looking at looking
at OCUnit and OBJCUnit, but each was far enough from what I wanted
that a clean
slate made more sense. Objective-C especially in the Cocoa environment
is so
dynamic and rich, that I also felt it would be beneficial not to be too
strongly swayed
by choices made in JUnit or SUnit.
The target/action abstraction layer of the logger is designed to
support things like:
Reporting on unmet functionality needed to meet the requirements of a
MileStone.
Triggering an email to a responsible person or Role, based on a runtime
event.
Transferring control to an inspector so the developer can investigate
something.
Passing a reference to, or copy of, a live object from the application
to a TestCase instance
and running it through it's paces, before returning to the normal flow
of control.
Storing a serialized object instance on disk or in a database to aid in
future testing.
I have already developed the base functionality.
What I am interested in is feedback on whether or not other developers
like or
the dislike the terse syntax in which embedded prefixes of an NSString
denote
that it contains a set of tokens rather than a format string. I will,
of course, provide
access to a formal interface with named parameters, but since it is
impossible for a
method or function to have more than one va_arg list, the verbose
interface may
not turn out to provide any compelling benefit such as significantly
better compile-time
type checking.
Currently the default syntax for the most common use of the logger
methods looks
like this when invoked via a macro.
log(@"!:Some,Tokens,Compound.If.You.Want", @"Format followed by an %s
of args", "arbitray number");
basically I want to reserve the first two characters of an NSString for
special handling
so that something like
[string hasPrefix: "!:"] denotes that is an event modifier, not a
format string.
If folks find it butt-ugly I can certainly graft on something else
later, I just want
gut level reactions, ugly, pretty, or I'd prefer this other thing
instead.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.