/core/externals/update-engine/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. #import <Foundation/Foundation.h>
  19. #import <asl.h>
  20. #import "GTMLogger.h"
  21. // GTMLogger (GTMLoggerASLAdditions)
  22. //
  23. // Adds a convenience creation method that allows you to get a standard
  24. // GTMLogger object that is configured to write to ASL (Apple System Log) using
  25. // the GTMLogASLWriter (declared below).
  26. //
  27. @interface GTMLogger (GTMLoggerASLAdditions)
  28. // Returns a new autoreleased GTMLogger instance that will log to ASL, using
  29. // the GTMLogASLFormatter, and the GTMLogLevelFilter filter.
  30. + (id)standardLoggerWithASL;
  31. @end
  32. @class GTMLoggerASLClient;
  33. // GTMLogASLWriter
  34. //
  35. // A GTMLogWriter implementation that will send log messages to ASL (Apple
  36. // System Log facility). To use with GTMLogger simply set the "writer" for a
  37. // GTMLogger to be an instance of this class. The following example sets the
  38. // shared system logger to lot to ASL.
  39. //
  40. // [[GTMLogger sharedLogger] setWriter:[GTMLogASLWriter aslWriter]];
  41. // GTMLoggerInfo(@"Hi"); // This is sent to ASL
  42. //
  43. // See GTMLogger.h for more details and a higher-level view.
  44. //
  45. @interface GTMLogASLWriter : NSObject <GTMLogWriter> {
  46. @private
  47. __weak Class aslClientClass_;
  48. NSString *facility_;
  49. }
  50. // Returns an autoreleased GTMLogASLWriter instance that uses an instance of
  51. // GTMLoggerASLClient and the default ASL facility.
  52. + (id)aslWriter;
  53. // Returns an autoreleased GTMLogASLWriter instance that uses an instance of
  54. // GTMLoggerASLClient and the supplied facility. See asl_open(3) for a
  55. // discusssion of ASL facility strings.
  56. + (id)aslWriterWithFacility:(NSString *)facility;
  57. // Designated initializer. Uses instances of the specified |clientClass| to talk
  58. // to the ASL system. All logs from this method will use |facility| as the ASL
  59. // log facility. This method is typically only useful for testing. Users
  60. // should generally NOT use this method to get an instance. Instead, simply use
  61. // the +aslWriter or +aslWriterWithFacility: methods to obtain an instance.
  62. - (id)initWithClientClass:(Class)clientClass facility:(NSString *)facility;
  63. @end // GTMLogASLWriter
  64. // An ASL-specific log formatter that replicates the same fields as
  65. // GTMLogStandardFormatter except for those (date, process name) that ASL
  66. // records independently.
  67. @interface GTMLogASLFormatter : GTMLogBasicFormatter
  68. @end // GTMLogASLFormatter
  69. // Helper class used by GTMLogASLWriter to create an ASL client and write to the
  70. // ASL log. This class is need to make management/cleanup of the aslclient work
  71. // in a multithreaded environment. You'll need one of these GTMLoggerASLClient
  72. // per thread (this is automatically handled by GTMLogASLWriter).
  73. //
  74. // This class should rarely (if EVER) be used directly. It's designed to be used
  75. // internally by GTMLogASLWriter, and by some unit tests. It should not be
  76. // used externally.
  77. @interface GTMLoggerASLClient : NSObject {
  78. @private
  79. aslclient client_;
  80. }
  81. // Designated initializer, |facility| is supplied to asl_open().
  82. - (id)initWithFacility:(NSString *)facility;
  83. // Sends the given string to ASL at the specified ASL log |level|.
  84. - (void)log:(NSString *)msg level:(int)level;
  85. @end