Exemplo n.º 1
0
static int gx_logger_net(struct _reent *r, int fd, const char *ptr, size_t len)
{
#ifdef HAVE_LOGGER
   static char temp[4000];
   size_t l = (len >= 4000) ? 3999 : len - 1;
   memcpy(temp, ptr, l);
   temp[l] = 0;
   logger_send("%s", temp);
#elif defined(HAVE_FILE_LOGGER)
   fwrite(ptr, 1, len, retro_main_log_file());
#endif
   return len;
}
Exemplo n.º 2
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
}
Exemplo n.º 3
0
int gx_logger_file(struct _reent *r, int fd, const char *ptr, size_t len)
{
   fwrite(ptr, 1, len, retro_main_log_file());
   return len;
}
Exemplo n.º 4
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
}