"Fossies" - the Fresh Open Source Software Archive

Member "mono-6.12.0.122/mono/utils/mono-log-darwin.c" (22 Feb 2021, 2728 Bytes) of package /linux/misc/mono-sources/mono/mono-6.12.0.122.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "mono-log-darwin.c": 6.12.0.107_vs_6.12.0.122.

    1 /**
    2  * \file
    3  * Darwin-specific interface to the logger
    4  *
    5  */
    6 #include <config.h>
    7 
    8 #if (defined(HOST_WATCHOS) && (__WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_3_0)) || defined(HOST_MACCAT)
    9 /* emitted by clang:
   10  *   > /Users/lewurm/work/mono-watch4/mono/utils/mono-log-darwin.c:35:2: error: 'asl_log' is \
   11  *   > deprecated: first deprecated in watchOS 3.0 - os_log(3) has replaced \
   12  *   > asl(3) [-Werror,-Wdeprecated-declarations]
   13  */
   14 
   15 /* untested stuff: */
   16 #include <os/log.h>
   17 #include "mono-logger-internals.h"
   18 void
   19 mono_log_open_asl (const char *path, void *userData)
   20 {
   21 }
   22 
   23 void
   24 mono_log_write_asl (const char *log_domain, GLogLevelFlags level, mono_bool hdr, const char *message)
   25 {
   26     switch (level & G_LOG_LEVEL_MASK)
   27     {
   28         case G_LOG_LEVEL_MESSAGE:
   29             os_log (OS_LOG_DEFAULT, "%s%s%s\n",
   30                 log_domain != NULL ? log_domain : "",
   31                 log_domain != NULL ? ": " : "",
   32                 message);
   33             break;
   34         case G_LOG_LEVEL_INFO:
   35             os_log_info (OS_LOG_DEFAULT, "%s%s%s\n",
   36                 log_domain != NULL ? log_domain : "",
   37                 log_domain != NULL ? ": " : "",
   38                 message);
   39             break;
   40         case G_LOG_LEVEL_DEBUG:
   41             os_log_debug (OS_LOG_DEFAULT, "%s%s%s\n",
   42                 log_domain != NULL ? log_domain : "",
   43                 log_domain != NULL ? ": " : "",
   44                 message);
   45             break;
   46         case G_LOG_LEVEL_ERROR:
   47         case G_LOG_LEVEL_WARNING:
   48             os_log_error (OS_LOG_DEFAULT, "%s%s%s\n",
   49                 log_domain != NULL ? log_domain : "",
   50                 log_domain != NULL ? ": " : "",
   51                 message);
   52         case G_LOG_LEVEL_CRITICAL:
   53         default:
   54             os_log_fault (OS_LOG_DEFAULT, "%s%s%s\n",
   55                 log_domain != NULL ? log_domain : "",
   56                 log_domain != NULL ? ": " : "",
   57                 message);
   58             break;
   59     }
   60 
   61     if (level & G_LOG_LEVEL_ERROR)
   62         abort();
   63 }
   64 
   65 void
   66 mono_log_close_asl ()
   67 {
   68 }
   69 
   70 #elif defined(HOST_IOS)
   71 
   72 #include <asl.h>
   73 #include "mono-logger-internals.h"
   74 static int
   75 to_asl_priority (GLogLevelFlags log_level)
   76 {
   77     switch (log_level & G_LOG_LEVEL_MASK)
   78     {
   79         case G_LOG_LEVEL_ERROR:     return ASL_LEVEL_CRIT;
   80         case G_LOG_LEVEL_CRITICAL:  return ASL_LEVEL_ERR;
   81         case G_LOG_LEVEL_WARNING:   return ASL_LEVEL_WARNING;
   82         case G_LOG_LEVEL_MESSAGE:   return ASL_LEVEL_NOTICE;
   83         case G_LOG_LEVEL_INFO:      return ASL_LEVEL_INFO;
   84         case G_LOG_LEVEL_DEBUG:     return ASL_LEVEL_DEBUG;
   85     }
   86     return ASL_LEVEL_ERR;
   87 }
   88 
   89 void
   90 mono_log_open_asl (const char *path, void *userData)
   91 {
   92 }
   93 
   94 void
   95 mono_log_write_asl (const char *log_domain, GLogLevelFlags level, mono_bool hdr, const char *message)
   96 {
   97     asl_log (NULL, NULL, to_asl_priority (level), "%s%s%s\n",
   98         log_domain != NULL ? log_domain : "",
   99         log_domain != NULL ? ": " : "",
  100         message);
  101 
  102     if (level & G_LOG_LEVEL_ERROR)
  103         g_assert_abort ();
  104 }
  105 
  106 void
  107 mono_log_close_asl ()
  108 {
  109 }
  110 
  111 #else
  112 
  113 #include <mono/utils/mono-compiler.h>
  114 
  115 MONO_EMPTY_SOURCE_FILE (mono_log_darwin);
  116 
  117 #endif