aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMLogger+ASL.h
diff options
context:
space:
mode:
authorGravatar thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-07-21 14:49:00 +0000
committerGravatar thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2008-07-21 14:49:00 +0000
commit4963c8a9d57501b5ffb0fe52fbfe60cd71b3b916 (patch)
treedd70e4aba13b245427788ccdb075e04f1af0951c /Foundation/GTMLogger+ASL.h
parentef630a18e87e03f15a2ae2b7b90623d4a0183f89 (diff)
helps if I add the files before doing the commit
Diffstat (limited to 'Foundation/GTMLogger+ASL.h')
-rw-r--r--Foundation/GTMLogger+ASL.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/Foundation/GTMLogger+ASL.h b/Foundation/GTMLogger+ASL.h
new file mode 100644
index 0000000..689a0d9
--- /dev/null
+++ b/Foundation/GTMLogger+ASL.h
@@ -0,0 +1,87 @@
+//
+// GTMLogger+ASL.h
+//
+// Copyright 2007-2008 Google Inc.
+//
+// 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
+// License for the specific language governing permissions and limitations under
+// the License.
+//
+
+#import <Foundation/Foundation.h>
+#import <asl.h>
+#import "GTMLogger.h"
+
+
+// GTMLogger (GTMLoggerASLAdditions)
+//
+// 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.
++ (id)standardLoggerWithASL;
+
+@end
+
+
+@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
+// shared system logger to lot to ASL.
+//
+// [[GTMLogger sharedLogger] setWriter:[GTMLogASLWriter aslWriter]];
+// GTMLoggerInfo(@"Hi"); // This is sent to ASL
+//
+// See GTMLogger.h for more details and a higher-level view.
+//
+@interface GTMLogASLWriter : NSObject <GTMLogWriter> {
+ @private
+ __weak Class aslClientClass_;
+}
+
+// Returns an autoreleased GTMLogASLWriter instance that uses an instance of
+// GTMLoggerASLClient.
++ (id)aslWriter;
+
+// Designated initializer. Uses instances of the specified |clientClass| to talk
+// to the ASL system. 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;
+
+@end // GTMLogASLWriter
+
+
+// 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).
+//
+// 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
+// used externally.
+@interface GTMLoggerASLClient : NSObject {
+ @private
+ aslclient client_;
+}
+
+// Sends the given string to ASL at the specified ASL log |level|.
+- (void)log:(NSString *)msg level:(int)level;
+
+@end