PageRenderTime 20ms CodeModel.GetById 12ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/google-toolbox-for-mac/Foundation/GTMLogger+ASL.h

http://macfuse.googlecode.com/
C++ Header | 104 lines | 25 code | 19 blank | 60 comment | 0 complexity | fe5e31ff10396ebd70144b17e41743a7 MD5 | raw file
  1//
  2//  GTMLogger+ASL.h
  3//
  4//  Copyright 2007-2008 Google Inc.
  5//
  6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7//  use this file except in compliance with the License.  You may obtain a copy
  8//  of the License at
  9//
 10//  http://www.apache.org/licenses/LICENSE-2.0
 11//
 12//  Unless required by applicable law or agreed to in writing, software
 13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 15//  License for the specific language governing permissions and limitations under
 16//  the License.
 17//
 18
 19#import <Foundation/Foundation.h>
 20#import <asl.h>
 21#import "GTMLogger.h"
 22
 23
 24// GTMLogger (GTMLoggerASLAdditions)
 25//
 26// Adds a convenience creation method that allows you to get a standard
 27// GTMLogger object that is configured to write to ASL (Apple System Log) using
 28// the GTMLogASLWriter (declared below).
 29//
 30@interface GTMLogger (GTMLoggerASLAdditions)
 31
 32// Returns a new autoreleased GTMLogger instance that will log to ASL, using
 33// the GTMLogASLFormatter, and the GTMLogLevelFilter filter.
 34+ (id)standardLoggerWithASL;
 35
 36@end
 37
 38
 39@class GTMLoggerASLClient;
 40
 41// GTMLogASLWriter
 42//
 43// A GTMLogWriter implementation that will send log messages to ASL (Apple
 44// System Log facility). To use with GTMLogger simply set the "writer" for a
 45// GTMLogger to be an instance of this class. The following example sets the
 46// shared system logger to lot to ASL.
 47//
 48//   [[GTMLogger sharedLogger] setWriter:[GTMLogASLWriter aslWriter]];
 49//   GTMLoggerInfo(@"Hi");  // This is sent to ASL
 50//
 51// See GTMLogger.h for more details and a higher-level view.
 52//
 53@interface GTMLogASLWriter : NSObject <GTMLogWriter> {
 54 @private
 55  __weak Class aslClientClass_;
 56  NSString *facility_;
 57}
 58
 59// Returns an autoreleased GTMLogASLWriter instance that uses an instance of
 60// GTMLoggerASLClient and the default ASL facility.
 61+ (id)aslWriter;
 62
 63// Returns an autoreleased GTMLogASLWriter instance that uses an instance of
 64// GTMLoggerASLClient and the supplied facility. See asl_open(3) for a
 65// discusssion of ASL facility strings.
 66+ (id)aslWriterWithFacility:(NSString *)facility;
 67
 68// Designated initializer. Uses instances of the specified |clientClass| to talk
 69// to the ASL system. All logs from this method will use |facility| as the ASL
 70// log facility. This method is typically only useful for testing. Users
 71// should generally NOT use this method to get an instance. Instead, simply use
 72// the +aslWriter or +aslWriterWithFacility: methods to obtain an instance.
 73- (id)initWithClientClass:(Class)clientClass facility:(NSString *)facility;
 74
 75@end  // GTMLogASLWriter
 76
 77
 78// An ASL-specific log formatter that replicates the same fields as
 79// GTMLogStandardFormatter except for those (date, process name) that ASL
 80// records independently.
 81@interface GTMLogASLFormatter : GTMLogBasicFormatter
 82@end  // GTMLogASLFormatter
 83
 84
 85// Helper class used by GTMLogASLWriter to create an ASL client and write to the
 86// ASL log. This class is need to make management/cleanup of the aslclient work
 87// in a multithreaded environment. You'll need one of these GTMLoggerASLClient
 88// per thread (this is automatically handled by GTMLogASLWriter).
 89//
 90// This class should rarely (if EVER) be used directly. It's designed to be used
 91// internally by GTMLogASLWriter, and by some unit tests. It should not be
 92// used externally.
 93@interface GTMLoggerASLClient : NSObject {
 94 @private
 95  aslclient client_;
 96}
 97
 98// Designated initializer, |facility| is supplied to asl_open().
 99- (id)initWithFacility:(NSString *)facility;
100
101// Sends the given string to ASL at the specified ASL log |level|.
102- (void)log:(NSString *)msg level:(int)level;
103
104@end