Module: GLib::Log

Defined in:
glib2/lib/glib2.rb

Constant Summary collapse

DOMAIN =
"Ruby/GLib"
LEVELS =
{
  LEVEL_ERROR => "ERROR",
  LEVEL_CRITICAL => "CRITICAL",
  LEVEL_WARNING => "WARNING",
  LEVEL_MESSAGE => "MESSAGE",
  LEVEL_INFO => "INFO",
  LEVEL_DEBUG => "DEBUG"
}

Class Method Summary collapse

Class Method Details

.critical(str) ⇒ Object



280
281
282
# File 'glib2/lib/glib2.rb', line 280

def critical(str)
  log(DOMAIN, LEVEL_CRITICAL, caller(1)[0] << ": " << str)
end

.error(str) ⇒ Object



274
275
276
# File 'glib2/lib/glib2.rb', line 274

def error(str)
  log(DOMAIN, LEVEL_ERROR, caller(1)[0] << ": " << str)
end

.message(str) ⇒ Object



277
278
279
# File 'glib2/lib/glib2.rb', line 277

def message(str)
  log(DOMAIN, LEVEL_MESSAGE, caller(1)[0] << ": " << str)
end

.set_log_domain(domain) ⇒ Object



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'glib2/lib/glib2.rb', line 287

def set_log_domain(domain)
  level =
    FLAG_RECURSION |
    FLAG_FATAL |
    LEVEL_ERROR |
    LEVEL_CRITICAL |
    LEVEL_WARNING
  if $VERBOSE or $DEBUG
    level |=
      LEVEL_MESSAGE |
      LEVEL_INFO
  end
  if $DEBUG
    level |= LEVEL_DEBUG
  end
  GLib::Log.set_handler(domain, level)
end

.warning(str) ⇒ Object



283
284
285
# File 'glib2/lib/glib2.rb', line 283

def warning(str)
  log(DOMAIN, LEVEL_WARNING, caller(1)[0] << ": " << str)
end