Exemple #1
0
void SFB::Logger::Log(levels level, const char *facility, const char *message, const char *function, const char *file, int line)
{
	if(currentLogLevel < level)
		return;

	aslmsg msg = asl_new(ASL_TYPE_MSG);

	if(facility)
		asl_set(msg, ASL_KEY_FACILITY, facility);

	if(function)
		asl_set(msg, "Function", function);

	if(file)
		asl_set(msg, "File", file);

	if(-1 != line) {
		char buf [32];
		if(snprintf(buf, sizeof(buf), "%d", line))
			asl_set(msg, "Line", buf);
	}

	asl_log(nullptr, msg, level, "%s", message);

	asl_free(msg);
}
void __security_debug(const char *scope, const char *function,
    const char *file, int line, const char *format, ...)
{
#if !defined(NDEBUG)
	pthread_once(&__security_debug_once, __security_debug_init);

	CFStringRef scopeName = NULL;
	/* Scope NULL is always enabled. */
	if (scope) {
		/* Check if the scope is enabled. */
		if (scopeSet) {
			scopeName = copyScopeName(scope, strlen(scope));
			if (negate == CFSetContainsValue(scopeSet, scopeName)) {
				CFRelease(scopeName);
				return;
			}
		} else if (!negate) {
			return;
		}
	}

	CFStringRef formatStr = CFStringCreateWithCString(kCFAllocatorDefault,
		format, kCFStringEncodingUTF8);
	va_list args;
	va_start(args, format);
	CFStringRef message = CFStringCreateWithFormatAndArguments(
		kCFAllocatorDefault, NULL, formatStr, args);
	va_end(args);
	time_t now = time(NULL);
	char *date = ctime(&now);
	date[19] = '\0';
	CFStringRef logStr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
		CFSTR("%s %-*s %s %@\n"), date + 4, MAX_SCOPE_LENGTH - 1,
        scope ? scope : "", function, message);
	CFShow(logStr);
    char logMsg[4096];
    if (CFStringGetCString(logStr, logMsg, sizeof(logMsg), kCFStringEncodingUTF8)) {
#if 0
        asl_log(NULL, NULL, ASL_LEVEL_INFO, logMsg);
#else
        aslmsg msg = asl_new(ASL_TYPE_MSG);
        if (scope) {
            asl_set(msg, ASL_KEY_FACILITY, scope);
        }
        asl_set(msg, ASL_KEY_LEVEL, ASL_STRING_INFO);
        asl_set(msg, ASL_KEY_MSG, logMsg);
        asl_send(NULL, msg);
        asl_free(msg);
#endif
    }
	CFRelease(logStr);
	CFRelease(message);
	CFRelease(formatStr);
	if (scopeName)
		CFRelease(scopeName);
#endif
}
Exemple #3
0
void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
{
#if TARGET_OS_IPHONE
   static int asl_inited = 0;
#if !TARGET_IPHONE_SIMULATOR
static aslclient asl_client;
#endif
#endif

   if (!RARCH_LOG_VERBOSE())
      return;
#if TARGET_OS_IPHONE
#if TARGET_IPHONE_SIMULATOR
   vprintf(fmt, ap);
#else
   if (!asl_inited)
   {
      asl_client = asl_open("RetroArch", "com.apple.console", ASL_OPT_STDERR | ASL_OPT_NO_DELAY);
      asl_inited = 1;
   }
   aslmsg msg = asl_new(ASL_TYPE_MSG);
   asl_set(msg, ASL_KEY_READ_UID, "-1");
   if (tag)
      asl_log(asl_client, msg, ASL_LEVEL_NOTICE, "%s", tag);
   asl_vlog(asl_client, msg, ASL_LEVEL_NOTICE, fmt, ap);
   asl_free(msg);
#endif
#elif defined(_XBOX1)
   /* FIXME: Using arbitrary string as fmt argument is unsafe. */
   char msg_new[1024], buffer[1024];
   snprintf(msg_new, sizeof(msg_new), "%s: %s %s",
         PROGRAM_NAME,
         tag ? tag : "",
         fmt);
   wvsprintf(buffer, msg_new, ap);
   OutputDebugStringA(buffer);
#elif defined(ANDROID)
   int prio = ANDROID_LOG_INFO;
   if (tag)
   {
      if (string_is_equal("[WARN]", tag))
         prio = ANDROID_LOG_WARN;
      else if (string_is_equal("[ERROR]", tag))
         prio = ANDROID_LOG_ERROR;
   }
   __android_log_vprint(prio, PROGRAM_NAME, fmt, ap);
#else
   fprintf(LOG_FILE, "%s %s :: ", PROGRAM_NAME, tag ? tag : "[INFO]");
   vfprintf(LOG_FILE, fmt, ap);
   fflush(LOG_FILE);
#endif
}
Exemple #4
0
void SMBLogInfo(const char *fmt, int log_level,...)
{
    int save_errno = errno;
    va_list ap;
    aslmsg m = asl_new(ASL_TYPE_MSG);


    va_start(ap, log_level);
    asl_vlog(NULL, m, log_level, fmt, ap);
    va_end(ap);
    asl_free(m);
    errno = save_errno; /* Never let this routine change errno */
}
void _IOHIDLog(int level, const char *format, ...)
{
    aslmsg msg = NULL;
    
    if (1) {
        msg = asl_new(ASL_TYPE_MSG);
        asl_set(msg, ASL_KEY_FACILITY, "com.apple.iokit.IOHID");
    }
    va_list ap;
    va_start(ap, format);
    asl_vlog(NULL, msg, level, format, ap);
    va_end(ap);
    if (msg) {
        asl_free(msg);
    }
}
Exemple #6
0
static
void
sessionLogEvent (const char *domain, const char *event_msg)
{
	aslmsg m;

	if (!domain || !event_msg) {
		return;
	}

	m = asl_new(ASL_TYPE_MSG);
	asl_set(m, ASL_KEY_FACILITY, domain);
	asl_set(m, ASL_KEY_MSG, sessionString);
	asl_log(NULL, m, ASL_LEVEL_NOTICE, "SCNCController: %s", event_msg);
	asl_free(m);
}
Exemple #7
0
static void
sessionTracerLogStop (const char *domain, const char *type, int caused_by_failure, const char *reason, u_int32_t established, u_int32_t duration)
{
	aslmsg      m;
	char *      buf;
	char		data[256] = {0};

	m = asl_new(ASL_TYPE_MSG);
	asl_set(m, "com.apple.message.domain", domain);
	asl_set(m, "com.apple.message.type", type);
	asl_set(m, ASL_KEY_FACILITY, domain);
	asl_set(m, ASL_KEY_MSG, sessionString);
	if (caused_by_failure) {
		asl_set(m, "com.apple.message.result", CONSTSTR("failure"));	// failure
	} else {
		asl_set(m, "com.apple.message.result", CONSTSTR("success"));	// success
	}
	if (reason) {
		asl_set(m, "com.apple.message.reason", reason);
	} else {
		// reason was NULL; make sure success/failure have different signature
		if (caused_by_failure) {
			asl_set(m, "com.apple.message.reason", CONSTSTR("Internal/Server-side error"));
		} else {
			asl_set(m, "com.apple.message.reason", CONSTSTR("User/System initiated the disconnect"));
		}
	}
	
	buf = sessionTracerBucketizeTime(duration);
	
	if (established) {
		asl_set(m, "com.apple.message.connectiontime", buf);	// stuff the up time into value
		snprintf(data, sizeof(data), "SCNCController: Disconnecting.");
		asl_set(m, "com.apple.message.controller", data);
		asl_log(NULL, m, ASL_LEVEL_NOTICE, "");
	} else {
		asl_set(m, "com.apple.message.negotiatingtime", buf);	/// stuff the negoing time into value2
		snprintf(data, sizeof(data), "SCNCController: Disconnecting.");
		asl_set(m, "com.apple.message.controller", data);
		asl_log(NULL, m, ASL_LEVEL_NOTICE, "");
	}
	
	asl_free(m);
}
Exemple #8
0
void
vsyslog(int pri, const char *fmt, va_list ap)
{
	int fac;
	aslmsg facmsg;
	const char *facility;

	facmsg = NULL;
	fac = pri & LOG_FACMASK;
	if (fac != 0)
	{
		facility = asl_syslog_faciliy_num_to_name(fac);
		if (facility != NULL)
		{
			facmsg = asl_new(ASL_TYPE_MSG);
			asl_set(facmsg, ASL_KEY_FACILITY, facility);
		}
	}

	asl_vlog(_sl_asl, facmsg, LOG_PRI(pri), fmt, ap);
	if (facmsg != NULL) asl_free(facmsg);
}
Exemple #9
0
void
sessionTracerLogEstablished (struct service *serv)
{
	if (serv) {
		aslmsg      m;
		char data[256] = {0};
		const char *type = sessionGetType(serv);
		
		if (!strcmp(type, nullString)) {
			/* We do not trace VPN */
			return;
		}
		
		const char *domain	= sessionGetConnectionLessDomain();
		
		if (sessionCheckIfEstablished(serv)) {
			// already established no need to log (mostly here due to sleep-wake)
			return;
		}
		
		sessionIsEstablished(serv);
		
		m = asl_new(ASL_TYPE_MSG);
		asl_set(m, "com.apple.message.domain", domain);
		asl_set(m, "com.apple.message.type", type);
		asl_set(m, "com.apple.message.result", CONSTSTR("success"));
		asl_set(m, "com.apple.message.reason", CONSTSTR("established"));
		asl_set(m, ASL_KEY_FACILITY, domain);
		asl_set(m, ASL_KEY_MSG, sessionString);
		
		sessionTracerLogPPPInfo(m, serv);
		
		snprintf(data, sizeof(data), "SCNCController: Connected.");
		asl_set(m, "com.apple.message.controller", data);
		asl_log(NULL, m, ASL_LEVEL_NOTICE, "");
		asl_free(m);
	}
}
static CFMutableArrayRef get_log_handlers()
{
    static dispatch_once_t handlers_once;
    
    dispatch_once(&handlers_once, ^{
        sSecurityLogHandlers = CFArrayCreateMutableForCFTypes(kCFAllocatorDefault);
        
        CFArrayAppendValue(sSecurityLogHandlers, ^(const char *level, CFStringRef scope, const char *function,
                                                   const char *file, int line, CFStringRef message){
            CFStringRef logStr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ %s %@\n"), scope ? scope : CFSTR(""), function, message);
            CFStringPerformWithCString(logStr, ^(const char *logMsg) {
                aslmsg msg = asl_new(ASL_TYPE_MSG);
                if (scope) {
                    CFStringPerformWithCString(scope, ^(const char *scopeStr) {
                        asl_set(msg, ASL_KEY_FACILITY, scopeStr);
                    });
                }
                asl_set(msg, ASL_KEY_LEVEL, level);
                asl_set(msg, ASL_KEY_MSG, logMsg);
                asl_send(NULL, msg);
                asl_free(msg);
            });
            CFReleaseSafe(logStr);
        });
static bool OSX_SetCloudKeychainTraceValueForKey(CFStringRef key, int64_t value)
{
	bool result = false;
	
	if (NULL == key)
	{
		return result;
	}
	
	aslmsg mAsl = NULL;
	mAsl = asl_new(ASL_TYPE_MSG);
	if (NULL == mAsl)
	{
		return result;
	}
    
    
    CFStringRef key_str = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@%@"), gMessageTracerPrefix, key);
    if (NULL == key_str)
    {
        asl_free(mAsl);
        return result;
    }
	
	CFStringRef value_str = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%lld"), value);
    if (NULL == value_str)
    {
        asl_free(mAsl);
        CFRelease(key_str);
        return result;
    }
    
    CFIndex key_str_numBytes = CFStringGetMaximumSizeForEncoding(CFStringGetLength(key_str), kCFStringEncodingUTF8);
    key_str_numBytes += 1; // For null
    char key_buffer[key_str_numBytes];
    memset(key_buffer, 0, key_str_numBytes);
    if (!CFStringGetCString(key_str, key_buffer, key_str_numBytes, kCFStringEncodingUTF8))
    {
        asl_free(mAsl);
        CFRelease(key_str);
        CFRelease(value_str);
        return result;
    }
    CFRelease(key_str);
    
    CFIndex value_str_numBytes = CFStringGetMaximumSizeForEncoding(CFStringGetLength(value_str), kCFStringEncodingUTF8);
    value_str_numBytes += 1; // For null
    char value_buffer[value_str_numBytes];
    memset(value_buffer, 0, value_str_numBytes);
    if (!CFStringGetCString(value_str, value_buffer, value_str_numBytes, kCFStringEncodingUTF8))
    {
        asl_free(mAsl);
        CFRelease(value_str);
        return result;
    }
    CFRelease(value_str);
	
	asl_set(mAsl, key_buffer, value_buffer);
	asl_log(NULL, mAsl, ASL_LEVEL_NOTICE, "%s", gTopLevelKeyForiCloudKeychainTracing);
	asl_free(mAsl);
	return true;
}
Exemple #12
0
void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
{
#if TARGET_OS_IPHONE
   static int asl_initialized = 0;
#if !TARGET_IPHONE_SIMULATOR
static aslclient asl_client;
#endif
#else
   FILE *fp = NULL;
   (void)fp;
#endif

   if (!verbosity_is_enabled())
      return;
#if TARGET_OS_IPHONE
#if TARGET_IPHONE_SIMULATOR
   vprintf(fmt, ap);
#else
   if (!asl_initialized)
   {
      asl_client = asl_open(file_path_str(FILE_PATH_PROGRAM_NAME), "com.apple.console", ASL_OPT_STDERR | ASL_OPT_NO_DELAY);
      asl_initialized = 1;
   }
   aslmsg msg = asl_new(ASL_TYPE_MSG);
   asl_set(msg, ASL_KEY_READ_UID, "-1");
   if (tag)
      asl_log(asl_client, msg, ASL_LEVEL_NOTICE, "%s", tag);
   asl_vlog(asl_client, msg, ASL_LEVEL_NOTICE, fmt, ap);
   asl_free(msg);
#endif
#elif defined(_XBOX1)
   /* FIXME: Using arbitrary string as fmt argument is unsafe. */
   char msg_new[1024];
   char buffer[1024];

   msg_new[0] = buffer[0] = '\0';
   snprintf(msg_new, sizeof(msg_new), "%s: %s %s",
         file_path_str(FILE_PATH_PROGRAM_NAME),
         tag ? tag : "",
         fmt);
   wvsprintf(buffer, msg_new, ap);
   OutputDebugStringA(buffer);
#elif defined(ANDROID)
   int prio = ANDROID_LOG_INFO;
   if (tag)
   {
      if (string_is_equal(file_path_str(FILE_PATH_LOG_WARN), tag))
         prio = ANDROID_LOG_WARN;
      else if (string_is_equal(file_path_str(FILE_PATH_LOG_ERROR), tag))
         prio = ANDROID_LOG_ERROR;
   }
   __android_log_vprint(prio,
         file_path_str(FILE_PATH_PROGRAM_NAME),
         fmt,
         ap);
#else

#ifdef HAVE_FILE_LOGGER
   fp = (FILE*)retro_main_log_file();
#else
   fp = stderr;
#endif
   fprintf(fp, "%s %s :: ",
         file_path_str(FILE_PATH_PROGRAM_NAME),
         tag ? tag : file_path_str(FILE_PATH_LOG_INFO));
   vfprintf(fp, fmt, ap);
   fflush(fp);
#endif
}
Exemple #13
0
int
od_record_create(pam_handle_t *pamh, ODRecordRef *record, CFStringRef cfUser)
{
	int retval = PAM_SERVICE_ERR;
	const int attr_num = 5;

	ODNodeRef cfNode = NULL;
	CFErrorRef cferror = NULL;
	CFArrayRef attrs = NULL;
	CFTypeRef cfVals[attr_num];

	if (NULL == record || NULL == cfUser) {
		openpam_log(PAM_LOG_DEBUG, "NULL argument passed");
		retval = PAM_SERVICE_ERR;
		goto cleanup;
	}

#ifdef OPENDIRECTORY_CACHE
#define CFRECORDNAME_CACHE "CFRecordName"
#define CFRECORDNAME_NAME CFSTR("name")
#define CFRECORDNAME_RECORD CFSTR("record")

	CFDictionaryRef cfdict;
	CFStringRef cachedUser;

	if (pam_get_data(pamh, CFRECORDNAME_CACHE, (void *)&cfdict) == PAM_SUCCESS &&
	    (CFGetTypeID(cfdict) == CFDictionaryGetTypeID()) &&
	    (cachedUser = CFDictionaryGetValue(cfdict, CFRECORDNAME_NAME)) != NULL &&
	    CFGetTypeID(cachedUser) == CFStringGetTypeID() &&
	    CFStringCompare(cfUser, cachedUser, 0) == kCFCompareEqualTo &&
	    (*record = (ODRecordRef)CFDictionaryGetValue(cfdict, CFRECORDNAME_RECORD)) != NULL)
	{
		CFRetain(*record);
		return PAM_SUCCESS;
	}
#endif /* OPENDIRECTORY_CACHE */

	int current_iterations = 0;

	cfNode = ODNodeCreateWithNodeType(kCFAllocatorDefault,
					  kODSessionDefault,
					  eDSAuthenticationSearchNodeName,
					  &cferror);
	if (NULL == cfNode || NULL != cferror) {
		openpam_log(PAM_LOG_ERROR, "ODNodeCreateWithNodeType failed.");
		retval = PAM_SERVICE_ERR;
		goto cleanup;
	}

	cfVals[0] = kODAttributeTypeAuthenticationAuthority;
	cfVals[1] = kODAttributeTypeHomeDirectory;
	cfVals[2] = kODAttributeTypeNFSHomeDirectory;
	cfVals[3] = kODAttributeTypeUserShell;
	cfVals[4] = kODAttributeTypeUniqueID;
	attrs = CFArrayCreate(kCFAllocatorDefault, cfVals, (CFIndex)attr_num, &kCFTypeArrayCallBacks);
	if (NULL == attrs) {
		openpam_log(PAM_LOG_DEBUG, "CFArrayCreate() failed");
		retval = PAM_BUF_ERR;
		goto cleanup;
	}

	retval = PAM_SERVICE_ERR;
	while (current_iterations <= kMaxIterationCount) {
		CFIndex unreachable_count = 0;
		CFArrayRef unreachable_nodes = ODNodeCopyUnreachableSubnodeNames(cfNode, NULL);
		if (unreachable_nodes) {
			unreachable_count = CFArrayGetCount(unreachable_nodes);
			CFRelease(unreachable_nodes);
			openpam_log(PAM_LOG_DEBUG, "%lu OD nodes unreachable.", unreachable_count);
		}

		*record = ODNodeCopyRecord(cfNode, kODRecordTypeUsers, cfUser, attrs, &cferror);
		if (*record)
			break;
		if (0 == unreachable_count)
			break;

		openpam_log(PAM_LOG_DEBUG, "Waiting %d seconds for nodes to become reachable", kWaitSeconds);
		sleep(kWaitSeconds);
		++current_iterations;
	}

	if (*record) {
#ifdef OPENDIRECTORY_CACHE
		const void *keys[] = { CFRECORDNAME_NAME, CFRECORDNAME_RECORD };
		const void *values[] = { cfUser, *record };
		CFDictionaryRef dict;
		
		dict = CFDictionaryCreate(NULL, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
		if (dict)
			pam_set_data(pamh, CFRECORDNAME_CACHE, (void *)dict, cleanup_cache);
#endif /* OPENDIRECTORY_CACHE */
		retval = PAM_SUCCESS;
	} else {
		retval = PAM_USER_UNKNOWN;
	}

	if (current_iterations > 0) {
		char *wt = NULL, *found = NULL;
		int retval2;

		if (*record)
			found = "failure";
		else
			found = "success";

		retval2 = asprintf(&wt, "%d", kWaitSeconds * current_iterations);
		if (-1 == retval2) {
			openpam_log(PAM_LOG_DEBUG, "Failed to convert current wait time to string.");
			retval = PAM_BUF_ERR;
			goto cleanup;
		}


		aslmsg m = asl_new(ASL_TYPE_MSG);
		asl_set(m, "com.apple.message.domain", "com.apple.pam_modules.odAvailableWaitTime" );
		asl_set(m, "com.apple.message.signature", "wait_time");
		asl_set(m, "com.apple.message.value", wt);
		asl_set(m, "com.apple.message.result", found);
		asl_log(NULL, m, ASL_LEVEL_NOTICE, "OD nodes online delay: %ss. User record lookup: %s.", wt, found);
		asl_free(m);
		free(wt);
	}

cleanup:
	if (NULL != attrs) {
		CFRelease(attrs);
	}

	if (NULL != cferror) {
		CFRelease(cferror);
	}

	if (NULL != cfNode) {
		CFRelease(cfNode);
	}

	if (PAM_SUCCESS != retval) {
		openpam_log(PAM_LOG_ERROR, "failed: %d", retval);
		if (NULL != *record) {
			CFRelease(*record);
			*record = NULL;
		}
	}

	return retval;
}
Exemple #14
0
/* remove all messages that have an ASLExpireTime key */
static uint32_t
do_ASLExpireTime_filter(const char *name)
{
	aslmsg msg;
	asl_file_t *in, *out;
	uint32_t status;
	uint64_t mid;
	char *inpath, *outpath;
	struct stat sb;

	if (name == NULL) return ASL_STATUS_INVALID_ARG;

	in = NULL;
	inpath = NULL;
	asprintf(&inpath, "%s/%s", store_path, name);
	if (inpath == NULL) return ASL_STATUS_NO_MEMORY;

	memset(&sb, 0, sizeof(struct stat));
	if (stat(inpath, &sb) < 0)
	{
		free(inpath);
		return ASL_STATUS_INVALID_STORE;
	}

	status = asl_file_open_read(inpath, &in);
	if (status != ASL_STATUS_OK) 
	{
		free(inpath);
		return ASL_STATUS_OK;
	}

	out = NULL;
	outpath = NULL;
	asprintf(&outpath, "%s/%s", store_path, TEMP_NAME);
	if (outpath == NULL)
	{
		asl_file_close(in);
		free(inpath);
		return ASL_STATUS_NO_MEMORY;
	}

	status = asl_file_open_write(outpath, sb.st_mode, sb.st_uid, sb.st_gid, &out);
	if (status != ASL_STATUS_OK)
	{
		asl_file_close(in);
		free(inpath);
		free(outpath);
		return status;
	}

	out->flags = ASL_FILE_FLAG_PRESERVE_MSG_ID;

	msg = NULL;
	while (asl_file_fetch_next(in, &msg) == ASL_STATUS_OK)
	{
		if (msg == NULL) break;

		mid = 0;

		if (asl_get(msg, ASL_KEY_EXPIRE_TIME) == NULL) status = asl_file_save(out, msg, &mid);

		asl_free(msg);
		msg = NULL;

		if (status != ASL_STATUS_OK) break;
	}

	asl_file_close(in);
	asl_file_close(out);

	unlink(inpath);
	rename(outpath, inpath);

	free(inpath);
	free(outpath);

	return status;
}
Exemple #15
0
void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
{
#if TARGET_OS_IPHONE
#if TARGET_IPHONE_SIMULATOR
   vprintf(fmt, ap);
#else
   static aslclient asl_client;
   static int asl_initialized = 0;
   if (!asl_initialized)
   {
      asl_client      = asl_open(
            file_path_str(FILE_PATH_PROGRAM_NAME),
            "com.apple.console",
            ASL_OPT_STDERR | ASL_OPT_NO_DELAY);
      asl_initialized = 1;
   }
   aslmsg msg = asl_new(ASL_TYPE_MSG);
   asl_set(msg, ASL_KEY_READ_UID, "-1");
   if (tag)
      asl_log(asl_client, msg, ASL_LEVEL_NOTICE, "%s", tag);
   asl_vlog(asl_client, msg, ASL_LEVEL_NOTICE, fmt, ap);
   asl_free(msg);
#endif
#elif defined(_XBOX1)
   {
      /* FIXME: Using arbitrary string as fmt argument is unsafe. */
      char msg_new[1024];
      char buffer[1024];

      msg_new[0] = buffer[0] = '\0';
      snprintf(msg_new, sizeof(msg_new), "%s: %s %s",
            file_path_str(FILE_PATH_PROGRAM_NAME),
            tag ? tag : "",
            fmt);
      wvsprintf(buffer, msg_new, ap);
      OutputDebugStringA(buffer);
   }
#elif defined(ANDROID)
   {
      int prio = ANDROID_LOG_INFO;
      if (tag)
      {
         if (string_is_equal(file_path_str(FILE_PATH_LOG_WARN), tag))
            prio = ANDROID_LOG_WARN;
         else if (string_is_equal(file_path_str(FILE_PATH_LOG_ERROR), tag))
            prio = ANDROID_LOG_ERROR;
      }
      __android_log_vprint(prio,
            file_path_str(FILE_PATH_PROGRAM_NAME),
            fmt,
            ap);
   }
#else

   {
#ifdef HAVE_QT
      char buffer[1024];
#endif
#ifdef HAVE_FILE_LOGGER
      FILE *fp = (FILE*)retro_main_log_file();
#else
      FILE *fp = stderr;
#endif

#ifdef HAVE_QT
      buffer[0] = '\0';
      vsnprintf(buffer, sizeof(buffer), fmt, ap);

      if (fp)
      {
         fprintf(fp, "%s %s", tag ? tag : file_path_str(FILE_PATH_LOG_INFO), buffer);
         fflush(fp);
      }

      ui_companion_driver_log_msg(buffer);
#else
#if defined(NXLINK) && !defined(HAVE_FILE_LOGGER)
          if (nxlink_connected)
             mutexLock(&nxlink_mtx);
#endif
      if (fp)
      {
         fprintf(fp, "%s ",
               tag ? tag : file_path_str(FILE_PATH_LOG_INFO));
         vfprintf(fp, fmt, ap);
         fflush(fp);
      }
#if defined(NXLINK) && !defined(HAVE_FILE_LOGGER)
      if (nxlink_connected)
         mutexUnlock(&nxlink_mtx);
#endif

#endif
   }
#endif
}
Exemple #16
0
static void message_finalize(value v) {
  asl_free(Msg_val(v));
}