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

This commit is contained in:
Ken Thomases 2013-01-21 00:07:47 -06:00 committed by Alexandre Julliard
parent dadcacf99a
commit b6d902ee46
4 changed files with 33 additions and 0 deletions

View File

@ -23,6 +23,9 @@
#include "macdrv_cocoa.h"
#define ERR(...) do { if (macdrv_err_on) LogError(__func__, __VA_ARGS__); } while (false)
@interface WineApplication : NSApplication <NSApplicationDelegate>
- (void) transformProcessToForeground;
@ -31,3 +34,6 @@ - (void) transformProcessToForeground;
void OnMainThread(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);

View File

@ -21,6 +21,9 @@
#import "cocoa_app.h"
int macdrv_err_on;
@implementation WineApplication
- (void) transformProcessToForeground
@ -87,3 +90,24 @@ void OnMainThreadAsync(dispatch_block_t 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];
}

View File

@ -109,6 +109,8 @@
/* main */
extern int macdrv_err_on;
extern int macdrv_start_cocoa_app(void) DECLSPEC_HIDDEN;

View File

@ -36,6 +36,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
switch(reason)
{
case DLL_PROCESS_ATTACH:
macdrv_err_on = ERR_ON(macdrv);
if (macdrv_start_cocoa_app())
{
ERR("Failed to start Cocoa app main loop\n");