<rdar://problem/6583331> Configure system service to cleanly log events
authorsherscher@apple.com <sherscher@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Thu, 17 Sep 2009 22:07:45 +0000 (22:07 +0000)
committersherscher@apple.com <sherscher@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Thu, 17 Sep 2009 22:07:45 +0000 (22:07 +0000)
git-svn-id: http://svn.macosforge.org/repository/mDNSResponder/trunk@6680 214c2c4a-bf3b-4dcf-9390-e4dd3010487d

mDNSWindows/SystemService/EventLog.mc [new file with mode: 0644]
mDNSWindows/SystemService/Service.c
mDNSWindows/SystemService/Service.rc
mDNSWindows/SystemService/Service.vcproj

diff --git a/mDNSWindows/SystemService/EventLog.mc b/mDNSWindows/SystemService/EventLog.mc
new file mode 100644 (file)
index 0000000..248e6c1
--- /dev/null
@@ -0,0 +1,11 @@
+MessageIdTypedef=WORD
+LanguageNames=(English=0x409:MSG00409)
+
+MessageId=100
+SymbolicName=MDNSRESPONDER_LOG
+Severity=Success
+Facility=Application
+Language=English
+%1
+.
+
index 22f8620..e458734 100644 (file)
@@ -29,6 +29,7 @@
 #include       "uds_daemon.h"
 #include       "GenLinkedList.h"
 #include       "Service.h"
+#include       "EventLog.h"
 
 #include       "Resource.h"
 
@@ -421,7 +422,7 @@ static OSStatus     InstallService( LPCTSTR inName, LPCTSTR inDisplayName, LPCTSTR i
        err = translate_errno( ok, (OSStatus) GetLastError(), kInUseErr );
        require_noerr( err, exit );
        
-       ReportStatus( EVENTLOG_SUCCESS, "installed service \"%s\"/\"%s\" at \"%s\"\n", inName, inDisplayName, inPath );
+       ReportStatus( EVENTLOG_SUCCESS, "installed service\n" );
        err = kNoErr;
        
 exit:
@@ -477,7 +478,7 @@ static OSStatus     RemoveService( LPCTSTR inName )
        err = translate_errno( ok, (OSStatus) GetLastError(), kDeletedErr );
        require_noerr( err, exit );
                
-       ReportStatus( EVENTLOG_SUCCESS, "Removed service \"%s\"\n", inName );
+       ReportStatus( EVENTLOG_SUCCESS, "Removed service\n" );
        err = ERROR_SUCCESS;
        
 exit:
@@ -803,7 +804,7 @@ static void ReportStatus( int inType, const char *inFormat, ... )
                        
                        vsprintf( s, inFormat, args );
                        array[ 0 ] = s;
-                       ok = ReportEventA( gServiceEventSource, (WORD) inType, 0, 0x20000001L, NULL, 1, 0, array, NULL );
+                       ok = ReportEventA( gServiceEventSource, (WORD) inType, 0, MDNSRESPONDER_LOG, NULL, 1, 0, array, NULL );
                        check_translated_errno( ok, GetLastError(), kUnknownErr );
                }
                else
@@ -841,7 +842,7 @@ int RunDirect( int argc, LPTSTR argv[] )
        
        // Run the service. This does not return until the service quits or is stopped.
        
-       ReportStatus( EVENTLOG_SUCCESS, "Running \"%s\" service directly\n", kServiceName );
+       ReportStatus( EVENTLOG_INFORMATION_TYPE, "Running service directly\n" );
        
        err = ServiceSpecificRun( argc, argv );
        require_noerr( err, exit );
@@ -1121,9 +1122,9 @@ static OSStatus   ServiceRun( int argc, LPTSTR argv[] )
        
        // Run the service-specific stuff. This does not return until the service quits or is stopped.
        
-       ReportStatus( EVENTLOG_INFORMATION_TYPE, "mDNSResponder started\n" );
+       ReportStatus( EVENTLOG_INFORMATION_TYPE, "Service started\n" );
        err = ServiceSpecificRun( argc, argv );
-       ReportStatus( EVENTLOG_INFORMATION_TYPE, "mDNSResponder stopped (%d)\n", err );
+       ReportStatus( EVENTLOG_INFORMATION_TYPE, "Service stopped (%d)\n", err );
        require_noerr( err, exit );
        
        // Service stopped. Clean up and we're done.
index 41c4273..60ad484 100644 (file)
@@ -9,6 +9,7 @@
 //
 #include "winres.h"
 #include "WinVersRes.h"
+#include "EventLog.rc"
 /////////////////////////////////////////////////////////////////////////////
 #undef APSTUDIO_READONLY_SYMBOLS
 
index 25d3f8b..852cac5 100644 (file)
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalOptions="/NXCOMPAT /DYNAMICBASE"\r
-                               AdditionalDependencies="ws2_32.lib iphlpapi.lib crypt32.lib netapi32.lib"\r
+                               AdditionalDependencies="ws2_32.lib iphlpapi.lib crypt32.lib netapi32.lib powrprof.lib"\r
                                OutputFile="$(OutDir)/mDNSResponder.exe"\r
                                LinkIncremental="2"\r
                                IgnoreAllDefaultLibraries="false"\r
                                RelativePath="..\..\mDNSShared\dnssd_ipc.c"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\EventLog.mc"\r
+                               >\r
+                               <FileConfiguration\r
+                                       Name="Debug|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               Description="Compiling Message Resource"\r
+                                               CommandLine="mc.exe EventLog.mc"\r
+                                               Outputs="EventLog.rc EventLog.h"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Debug|x64"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               Description="Compiling Message Resource"\r
+                                               CommandLine="mc.exe EventLog.mc"\r
+                                               Outputs="EventLog.rc EventLog.h"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|Win32"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               Description="Compiling Message Resource"\r
+                                               CommandLine="mc.exe EventLog.mc"\r
+                                               Outputs="EventLog.rc EventLog.h"\r
+                                       />\r
+                               </FileConfiguration>\r
+                               <FileConfiguration\r
+                                       Name="Release|x64"\r
+                                       >\r
+                                       <Tool\r
+                                               Name="VCCustomBuildTool"\r
+                                               Description="Compiling Message Resource"\r
+                                               CommandLine="mc.exe EventLog.mc"\r
+                                               Outputs="EventLog.rc EventLog.h"\r
+                                       />\r
+                               </FileConfiguration>\r
+                       </File>\r
                        <File\r
                                RelativePath="Firewall.cpp"\r
                                >\r