/src/wrappers/glib/library/core/glib_message_logging.e

http://github.com/tybor/Liberty · Specman e · 163 lines · 35 code · 40 blank · 88 comment · 1 complexity · d1367e635ea277195cf24640d05e3d2b MD5 · raw file

  1. indexing
  2. description: "Versatile support for logging messages with different levels of importance."
  3. copyright: "(C) 2005 Paolo Redaelli "
  4. license: "LGPL v2 or later"
  5. date: "$Date:$"
  6. revision: "$REvision:$"
  7. deferred class GLIB_MESSAGE_LOGGING
  8. -- Support for logging error messages or messages used for
  9. -- debugging. There are several built-in levels of messages,
  10. -- defined in GLogLevelFlags. These can be extended with
  11. -- user-defined levels.
  12. insert
  13. GMESSAGES_EXTERNALS
  14. WRAPPER_HANDLER
  15. feature
  16. log (a_domain, a_message: STRING; a_log_level: GLOG_LEVEL_FLAGS_ENUM) is
  17. -- Logs an error or debugging message. If `a_log_level' has been set as
  18. -- fatal, the `abort' function is called to terminate the program.
  19. -- `a_domain': the log domain; if Void `g_log_domain' is used.
  20. -- `a_log_level', either from GLogLevelFlags or a
  21. -- user-defined level.
  22. require message_not_void: a_message /= Void
  23. do
  24. g_log (null_or_string(a_domain), a_log_level.value, a_message.to_external)
  25. end
  26. message (a_message: STRING) is
  27. -- log a_message with message.
  28. require message_not_void: a_message /= Void
  29. local f: GLOG_LEVEL_FLAGS_ENUM
  30. do
  31. g_log(default_pointer,f.level_message_low_level, a_message.to_external)
  32. end
  33. warning (a_message: STRING) is
  34. -- Log a_message as a warning.
  35. require message_not_void: a_message/=Void
  36. local f: GLOG_LEVEL_FLAGS_ENUM
  37. do
  38. g_log(default_pointer,f.level_warning_low_level, a_message.to_external)
  39. end
  40. -- g_critical()
  41. -- #define g_critical(...)
  42. -- Logs a "critical warning" (G_LOG_LEVEL_CRITICAL). It's more or
  43. -- less application-defined what constitutes a critical vs. a
  44. -- regular warning. You could call g_log_set_always_fatal() to make
  45. -- critical warnings exit the program, then use g_critical() for
  46. -- fatal errors, for example. ... : format string, followed by
  47. -- parameters to insert into the format string (as with printf())
  48. error (an_error: STRING) is
  49. -- A convenience function/macro to log an error message. Error
  50. -- messages are always fatal, resulting in a call to the C function
  51. -- abort() to terminate the application. This function will result
  52. -- in a core dump; don't use it for errors you expect. Using this
  53. -- function indicates a bug in your program, i.e. an assertion
  54. -- failure.
  55. require error_not_void: an_error /= Void
  56. local f: GLOG_LEVEL_FLAGS_ENUM
  57. do
  58. g_log(default_pointer,f.level_error_low_level,an_error.to_external)
  59. end
  60. -- g_debug()
  61. -- #define g_debug(...)
  62. -- A convenience function/macro to log a debug message.
  63. -- ... : format string, followed by parameters to insert into the format string (as with printf())
  64. -- Since 2.6
  65. -- g_log_set_handler ()
  66. -- guint g_log_set_handler (const gchar *log_domain,
  67. -- GLogLevelFlags log_levels,
  68. -- GLogFunc log_func,
  69. -- gpointer user_data);
  70. -- Sets the log handler for a domain and a set of log levels. To handle fatal and recursive messages the log_levels parameter must be combined with the G_LOG_FLAG_FATAL and G_LOG_FLAG_RECURSION bit flags.
  71. -- Note that since the G_LOG_LEVEL_ERROR log level is always fatal, if you want to set a handler for this log level you must combine it with G_LOG_FLAG_FATAL.
  72. -- Example 13. Adding a log handler for all warning messages in the default (application) domain
  73. -- g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
  74. -- | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
  75. -- Example 14. Adding a log handler for all critical messages from GTK+
  76. -- g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
  77. -- | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
  78. -- Example 15. Adding a log handler for all messages from GLib
  79. -- g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
  80. -- | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
  81. -- log_domain : the log domain, or NULL for the default "" application domain.
  82. -- log_levels : the log levels to apply the log handler for. To handle fatal and recursive messages as well, combine the log levels with the G_LOG_FLAG_FATAL and G_LOG_FLAG_RECURSION bit flags.
  83. -- log_func : the log handler function.
  84. -- user_data : data passed to the log handler.
  85. -- Returns : the id of the new handler.
  86. -- g_log_remove_handler ()
  87. -- void g_log_remove_handler (const gchar *log_domain,
  88. -- guint handler_id);
  89. -- Removes the log handler.
  90. -- log_domain : the log domain.
  91. -- handler_id : the id of the handler, which was returned in g_log_set_handler().
  92. -- g_log_set_always_fatal ()
  93. -- GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
  94. -- Sets the message levels which are always fatal, in any log domain. When a message with any of these levels is logged the program terminates. You can only set the levels defined by GLib to be fatal. G_LOG_LEVEL_ERROR is always fatal.
  95. -- fatal_mask : the mask containing bits set for each level of error which is to be fatal.
  96. -- Returns : the old fatal mask.
  97. -- g_log_set_fatal_mask ()
  98. -- GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain,
  99. -- GLogLevelFlags fatal_mask);
  100. -- Sets the log levels which are fatal in the given domain. G_LOG_LEVEL_ERROR is always fatal.
  101. -- log_domain : the log domain.
  102. -- fatal_mask : the new fatal mask.
  103. -- Returns : the old fatal mask for the log domain.
  104. -- g_log_default_handler ()
  105. -- void g_log_default_handler (const gchar *log_domain,
  106. -- GLogLevelFlags log_level,
  107. -- const gchar *message,
  108. -- gpointer unused_data);
  109. -- The default log handler set up by GLib; g_log_set_default_handler() allows to install an alternate default log handler. This is used if no log handler has been set for the particular log domain and log level combination. It outputs the message to stderr or stdout and if the log level is fatal it calls abort().
  110. -- stderr is used for levels G_LOG_LEVEL_ERROR, G_LOG_LEVEL_CRITICAL, G_LOG_LEVEL_WARNING and G_LOG_LEVEL_MESSAGE. stdout is used for the rest.
  111. -- log_domain : the log domain of the message.
  112. -- log_level : the level of the message.
  113. -- message : the message.
  114. -- unused_data : data passed from g_log() which is unused.
  115. -- g_log_set_default_handler ()
  116. -- GLogFunc g_log_set_default_handler (GLogFunc log_func,
  117. -- gpointer user_data);
  118. -- Installs a default log handler which is used is used if no log handler has been set for the particular log domain and log level combination. By default, GLib uses g_log_default_handler() as default log handler.
  119. -- log_func : the log handler function.
  120. -- user_data : data passed to the log handler.
  121. -- Returns : the previous default log handler
  122. -- Since 2.6
  123. end