Class: Gearman::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/gearman/util.rb

Overview

Util

Description

Static helper methods and data used by other classes.

Constant Summary collapse

@@debug =
false

Class Method Summary collapse

Class Method Details

.ability_name_with_prefix(prefix, name) ⇒ Object Also known as: ability_name_for_perl



42
43
44
# File 'lib/gearman/util.rb', line 42

def Util.ability_name_with_prefix(prefix,name)
  "#{prefix}\t#{name}"
end

.debug=(v) ⇒ Object

Enable or disable debugging output (off by default).

Parameters:

  • v

    print debugging output



22
23
24
# File 'lib/gearman/util.rb', line 22

def Util.debug=(v)
  @@debug = v
end

.err(str) ⇒ Object

Log a message no matter what.

Parameters:

  • str

    message to log



38
39
40
# File 'lib/gearman/util.rb', line 38

def Util.err(str)
  log(str, true)
end

.log(str, force = false) ⇒ Object

Log a message if debugging is enabled.

Parameters:

  • str

    message to log



30
31
32
# File 'lib/gearman/util.rb', line 30

def Util.log(str, force=false)
  puts "#{Time.now.strftime '%Y-%m-%d %H:%M:%S'} #{str}" if force or @@debug
end