Permalink
Browse files

When logging to Console, serialize all logs by writing exclusively fr…

…om the Logger thread. Renamed internal message building methods in anticipation for making them available to client application. Now use bitflags for options, will allow for more in the future. Added entry point to manually set the Bonjour service name / type to connect to.
  • Loading branch information...
1 parent f97ac94 commit a5d5c32915ed4be344d4b3cac42469152db62336 Florent Pillet committed Nov 23, 2010
Showing with 455 additions and 216 deletions.
  1. +32 −8 Client Logger/LoggerClient.h
  2. +421 −206 Client Logger/LoggerClient.m
  3. +2 −2 Client Logger/LoggerCommon.h
@@ -1,7 +1,7 @@
/*
* LoggerClient.h
*
- * version 1.0b6 2010-16-08
+ * version 1.0b7 2010-11-23
*
* Part of NSLogger (client side)
*
@@ -44,16 +44,37 @@
// This define is here so that user application can test whether NSLogger Client is
// being included in the project, and potentially configure their macros accordingly
-#define NSLOGGER_WAS_HERE 1
+#define NSLOGGER_WAS_HERE 1
// Set this to 0 if you absolutely NOT want any access to Cocoa (Objective-C, NS* calls)
// We need a couple ones to reliably obtain the thread number and device information
// Note that since we need NSAutoreleasePool when using Cocoa in the logger's worker thread,
// we need to put Cocoa in multithreading mode. Also, ALLOW_COCOA_USE allows the client code
// to use NSLog()-style message formatting (less verbose than CFShow()-style) through the
// use of -[NSString stringWithFormat:arguments:]
-#define ALLOW_COCOA_USE 1
+#define ALLOW_COCOA_USE 1
+/* -----------------------------------------------------------------
+ * Logger option flags & default options
+ * -----------------------------------------------------------------
+ */
+enum {
+ kLoggerOption_LogToConsole = 0x01,
+ kLoggerOption_BufferLogsUntilConnection = 0x02,
+ kLoggerOption_BrowseBonjour = 0x04,
+ kLoggerOption_BrowseOnlyLocalDomain = 0x08,
+ kLoggerOption_UseSSL = 0x10
+};
+
+#define LOGGER_DEFAULT_OPTIONS (kLoggerOption_BufferLogsUntilConnection | \
+ kLoggerOption_BrowseBonjour | \
+ kLoggerOption_BrowseOnlyLocalDomain | \
+ kLoggerOption_UseSSL)
+
+/* -----------------------------------------------------------------
+ * Structure defining a Logger
+ * -----------------------------------------------------------------
+ */
typedef struct
{
CFStringRef bufferFile; // If non-NULL, all buffering is done to the specified file instead of in-memory
@@ -84,10 +105,9 @@ typedef struct
int32_t messageSeq; // sequential message number (added to each message sent)
// settings
- BOOL logToConsole;
- BOOL bufferLogsUntilConnection; // if set to YES, all logs are buffered to memory until we can connect to a logging service
- BOOL browseBonjour;
- BOOL browseOnlyLocalDomain; // if set to YES, Bonjour only checks "local." domain to look for logger
+ uint32_t options; // Flags, see enum above
+ CFStringRef bonjourServiceType; // leave NULL to use the default
+ CFStringRef bonjourServiceName; // leave NULL to use the first one available
// internal state
BOOL connected; // Set to YES once the write stream declares the connection open
@@ -118,7 +138,11 @@ extern Logger *LoggerGetDefaultLogger();
extern Logger* LoggerInit();
// Set logger options if you don't want the default options (see above)
-extern void LoggerSetOptions(Logger *logger, BOOL logToConsole, BOOL bufferLocallyUntilConnection, BOOL browseBonjour, BOOL browseOnlyLocalDomains);
+extern void LoggerSetOptions(Logger *logger, uint32_t options);
+
+// Set Bonjour logging names, so you can force the logger to use a specific service type
+// or direct logs to the machine on your network which publishes a specific name
+extern void LoggerSetupBonjour(Logger *logger, CFStringRef bonjourServiceType, CFStringRef bonjourServiceName);
// Directly set the viewer host (hostname or IP address) and port we want to connect to. If set, LoggerStart() will
// try to connect there first before trying Bonjour
Oops, something went wrong.

0 comments on commit a5d5c32

Please sign in to comment.