Commit b6d902ee authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Add a simple ERR() logging macro that can be used from Cocoa code.

parent dadcacf9
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
#include "macdrv_cocoa.h" #include "macdrv_cocoa.h"
#define ERR(...) do { if (macdrv_err_on) LogError(__func__, __VA_ARGS__); } while (false)
@interface WineApplication : NSApplication <NSApplicationDelegate> @interface WineApplication : NSApplication <NSApplicationDelegate>
- (void) transformProcessToForeground; - (void) transformProcessToForeground;
...@@ -31,3 +34,6 @@ ...@@ -31,3 +34,6 @@
void OnMainThread(dispatch_block_t block); void OnMainThread(dispatch_block_t block);
void OnMainThreadAsync(dispatch_block_t block); void OnMainThreadAsync(dispatch_block_t block);
void LogError(const char* func, NSString* format, ...);
void LogErrorv(const char* func, NSString* format, va_list args);
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
#import "cocoa_app.h" #import "cocoa_app.h"
int macdrv_err_on;
@implementation WineApplication @implementation WineApplication
- (void) transformProcessToForeground - (void) transformProcessToForeground
...@@ -87,3 +90,24 @@ void OnMainThreadAsync(dispatch_block_t block) ...@@ -87,3 +90,24 @@ void OnMainThreadAsync(dispatch_block_t block)
{ {
dispatch_async(dispatch_get_main_queue(), block); dispatch_async(dispatch_get_main_queue(), block);
} }
/***********************************************************************
* LogError
*/
void LogError(const char* func, NSString* format, ...)
{
va_list args;
va_start(args, format);
LogErrorv(func, format, args);
va_end(args);
}
/***********************************************************************
* LogErrorv
*/
void LogErrorv(const char* func, NSString* format, va_list args)
{
NSString* message = [[NSString alloc] initWithFormat:format arguments:args];
fprintf(stderr, "err:%s:%s", func, [message UTF8String]);
[message release];
}
...@@ -109,6 +109,8 @@ struct macdrv_display { ...@@ -109,6 +109,8 @@ struct macdrv_display {
/* main */ /* main */
extern int macdrv_err_on;
extern int macdrv_start_cocoa_app(void) DECLSPEC_HIDDEN; extern int macdrv_start_cocoa_app(void) DECLSPEC_HIDDEN;
......
...@@ -36,6 +36,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) ...@@ -36,6 +36,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
switch(reason) switch(reason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
macdrv_err_on = ERR_ON(macdrv);
if (macdrv_start_cocoa_app()) if (macdrv_start_cocoa_app())
{ {
ERR("Failed to start Cocoa app main loop\n"); ERR("Failed to start Cocoa app main loop\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment