PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  1indexing
  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	
  8deferred class GLIB_MESSAGE_LOGGING
  9	-- Support for logging error messages or messages used for
 10	-- debugging. There are several built-in levels of messages,
 11	-- defined in GLogLevelFlags. These can be extended with
 12	-- user-defined levels.
 13	
 14insert
 15	GMESSAGES_EXTERNALS
 16	WRAPPER_HANDLER
 17	
 18feature
 19	log (a_domain, a_message: STRING; a_log_level: GLOG_LEVEL_FLAGS_ENUM) is
 20		-- Logs an error or debugging message. If `a_log_level' has been set as
 21		-- fatal, the `abort' function is called to terminate the program.
 22	
 23		-- `a_domain': the log domain; if Void `g_log_domain' is used.
 24	
 25		-- `a_log_level', either from GLogLevelFlags or a
 26		-- user-defined level.
 27	require message_not_void: a_message /= Void
 28	do
 29		g_log (null_or_string(a_domain), a_log_level.value, a_message.to_external)
 30	end
 31	
 32	message (a_message: STRING) is
 33		-- log a_message with  message.
 34	require message_not_void: a_message /= Void
 35	local f: GLOG_LEVEL_FLAGS_ENUM
 36	do
 37		g_log(default_pointer,f.level_message_low_level, a_message.to_external)
 38	end
 39
 40	warning (a_message: STRING) is
 41		-- Log a_message as a warning.
 42	require message_not_void: a_message/=Void
 43	local f: GLOG_LEVEL_FLAGS_ENUM
 44	do 
 45		g_log(default_pointer,f.level_warning_low_level, a_message.to_external)
 46	end
 47
 48
 49	-- g_critical()
 50
 51	-- #define     g_critical(...)
 52	
 53	-- Logs a "critical warning" (G_LOG_LEVEL_CRITICAL). It's more or
 54	-- less application-defined what constitutes a critical vs. a
 55	-- regular warning. You could call g_log_set_always_fatal() to make
 56	-- critical warnings exit the program, then use g_critical() for
 57	-- fatal errors, for example.  ... : format string, followed by
 58	-- parameters to insert into the format string (as with printf())
 59	
 60	error (an_error: STRING) is
 61	-- A convenience function/macro to log an error message. Error
 62	-- messages are always fatal, resulting in a call to the C function
 63	-- abort() to terminate the application. This function will result
 64	-- in a core dump; don't use it for errors you expect. Using this
 65	-- function indicates a bug in your program, i.e. an assertion
 66	-- failure.
 67	require error_not_void: an_error /= Void
 68	local f: GLOG_LEVEL_FLAGS_ENUM
 69	do
 70		g_log(default_pointer,f.level_error_low_level,an_error.to_external)
 71
 72	end
 73	
 74-- g_debug()
 75
 76-- #define     g_debug(...)
 77
 78-- A convenience function/macro to log a debug message.
 79-- ... : 	format string, followed by parameters to insert into the format string (as with printf())
 80
 81-- Since 2.6
 82-- g_log_set_handler ()
 83
 84-- guint       g_log_set_handler               (const gchar *log_domain,
 85--                                              GLogLevelFlags log_levels,
 86--                                              GLogFunc log_func,
 87--                                              gpointer user_data);
 88
 89-- 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.
 90
 91-- 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.
 92
 93-- Example 13. Adding a log handler for all warning messages in the default (application) domain
 94
 95--   g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
 96--                      | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
 97
 98-- Example 14. Adding a log handler for all critical messages from GTK+
 99
100--   g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
101--                      | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
102
103-- Example 15. Adding a log handler for all messages from GLib
104
105--   g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
106--                      | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
107
108-- log_domain : 	the log domain, or NULL for the default "" application domain.
109-- 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.
110-- log_func : 	the log handler function.
111-- user_data : 	data passed to the log handler.
112-- Returns : 	the id of the new handler.
113-- g_log_remove_handler ()
114
115-- void        g_log_remove_handler            (const gchar *log_domain,
116--                                              guint handler_id);
117
118-- Removes the log handler.
119-- log_domain : 	the log domain.
120-- handler_id : 	the id of the handler, which was returned in g_log_set_handler().
121-- g_log_set_always_fatal ()
122
123-- GLogLevelFlags g_log_set_always_fatal       (GLogLevelFlags fatal_mask);
124
125-- 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.
126-- fatal_mask : 	the mask containing bits set for each level of error which is to be fatal.
127-- Returns : 	the old fatal mask.
128-- g_log_set_fatal_mask ()
129
130-- GLogLevelFlags g_log_set_fatal_mask         (const gchar *log_domain,
131--                                              GLogLevelFlags fatal_mask);
132
133-- Sets the log levels which are fatal in the given domain. G_LOG_LEVEL_ERROR is always fatal.
134-- log_domain : 	the log domain.
135-- fatal_mask : 	the new fatal mask.
136-- Returns : 	the old fatal mask for the log domain.
137-- g_log_default_handler ()
138
139-- void        g_log_default_handler           (const gchar *log_domain,
140--                                              GLogLevelFlags log_level,
141--                                              const gchar *message,
142--                                              gpointer unused_data);
143
144-- 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().
145
146-- 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.
147-- log_domain : 	the log domain of the message.
148-- log_level : 	the level of the message.
149-- message : 	the message.
150-- unused_data : 	data passed from g_log() which is unused.
151-- g_log_set_default_handler ()
152
153-- GLogFunc    g_log_set_default_handler       (GLogFunc log_func,
154--                                              gpointer user_data);
155
156-- 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.
157-- log_func : 	the log handler function.
158-- user_data : 	data passed to the log handler.
159-- Returns : 	the previous default log handler
160
161-- Since 2.6
162
163end