aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMLogger+ASL.h
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2011-04-28 20:30:21 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2011-04-28 20:30:21 +0000
commit784f85ae9a475667b7afb726d0653701c196ed48 (patch)
treecc258f8f11881c38875e3edc8bc8ef699ef24857 /Foundation/GTMLogger+ASL.h
parente27ef9a94628853e1ab7dd9cf7ac883d96596dda (diff)
[Author: aharper]
- Fix ASL logging to reference the correct formatter (and then replace with a new formatter). - Format ASL messages to include information that would normally be present in the standard formatter. - Allow ASL writers to pass a facility string. - Pretty up the function names in all logging, better matching NSAssert() names (as one example). - Don't throw if a logging filehandle is closed (SIGPIPE). Random exceptions from logging is bad, m'kay? R=thomasvl,dmaclach APPROVED=thomasvl
Diffstat (limited to 'Foundation/GTMLogger+ASL.h')
-rw-r--r--Foundation/GTMLogger+ASL.h47
1 files changed, 32 insertions, 15 deletions
diff --git a/Foundation/GTMLogger+ASL.h b/Foundation/GTMLogger+ASL.h
index 689a0d9..87a513d 100644
--- a/Foundation/GTMLogger+ASL.h
+++ b/Foundation/GTMLogger+ASL.h
@@ -6,9 +6,9 @@
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -23,14 +23,14 @@
// GTMLogger (GTMLoggerASLAdditions)
//
-// Adds a convenience creation method that allows you to get a standard
+// Adds a convenience creation method that allows you to get a standard
// GTMLogger object that is configured to write to ASL (Apple System Log) using
// the GTMLogASLWriter (declared below).
//
@interface GTMLogger (GTMLoggerASLAdditions)
// Returns a new autoreleased GTMLogger instance that will log to ASL, using
-// the GTMLogStandardFormatter, and the GTMLogLevelFilter filter.
+// the GTMLogASLFormatter, and the GTMLogLevelFilter filter.
+ (id)standardLoggerWithASL;
@end
@@ -39,10 +39,10 @@
@class GTMLoggerASLClient;
// GTMLogASLWriter
-//
-// A GTMLogWriter implementation that will send log messages to ASL (Apple
-// System Log facility). To use with GTMLogger simply set the "writer" for a
-// GTMLogger to be an instance of this class. The following example sets the
+//
+// A GTMLogWriter implementation that will send log messages to ASL (Apple
+// System Log facility). To use with GTMLogger simply set the "writer" for a
+// GTMLogger to be an instance of this class. The following example sets the
// shared system logger to lot to ASL.
//
// [[GTMLogger sharedLogger] setWriter:[GTMLogASLWriter aslWriter]];
@@ -53,34 +53,51 @@
@interface GTMLogASLWriter : NSObject <GTMLogWriter> {
@private
__weak Class aslClientClass_;
+ NSString *facility_;
}
-// Returns an autoreleased GTMLogASLWriter instance that uses an instance of
-// GTMLoggerASLClient.
+// Returns an autoreleased GTMLogASLWriter instance that uses an instance of
+// GTMLoggerASLClient and the default ASL facility.
+ (id)aslWriter;
+// Returns an autoreleased GTMLogASLWriter instance that uses an instance of
+// GTMLoggerASLClient and the supplied facility. See asl_open(3) for a
+// discusssion of ASL facility strings.
++ (id)aslWriterWithFacility:(NSString *)facility;
+
// Designated initializer. Uses instances of the specified |clientClass| to talk
-// to the ASL system. This method is typically only useful for testing. Users
+// to the ASL system. All logs from this method will use |facility| as the ASL
+// log facility. This method is typically only useful for testing. Users
// should generally NOT use this method to get an instance. Instead, simply use
-// the +aslWriter method to obtain an instance.
-- (id)initWithClientClass:(Class)clientClass;
+// the +aslWriter or +aslWriterWithFacility: methods to obtain an instance.
+- (id)initWithClientClass:(Class)clientClass facility:(NSString *)facility;
@end // GTMLogASLWriter
+// An ASL-specific log formatter that replicates the same fields as
+// GTMLogStandardFormatter except for those (date, process name) that ASL
+// records independently.
+@interface GTMLogASLFormatter : GTMLogBasicFormatter
+@end // GTMLogASLFormatter
+
+
// Helper class used by GTMLogASLWriter to create an ASL client and write to the
// ASL log. This class is need to make management/cleanup of the aslclient work
// in a multithreaded environment. You'll need one of these GTMLoggerASLClient
-// per thread (this is automatically handled by GTMLogASLWriter).
+// per thread (this is automatically handled by GTMLogASLWriter).
//
// This class should rarely (if EVER) be used directly. It's designed to be used
-// internally by GTMLogASLWriter, and by some unit tests. It should not be
+// internally by GTMLogASLWriter, and by some unit tests. It should not be
// used externally.
@interface GTMLoggerASLClient : NSObject {
@private
aslclient client_;
}
+// Designated initializer, |facility| is supplied to asl_open().
+- (id)initWithFacility:(NSString *)facility;
+
// Sends the given string to ASL at the specified ASL log |level|.
- (void)log:(NSString *)msg level:(int)level;