Module: PtLogger

Defined in:
lib/pt_logger/base.rb,
lib/pt_logger/config.rb,
lib/pt_logger/version.rb

Defined Under Namespace

Classes: Logger

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.log(*args) ⇒ Object

Command: log message to Pivotal Tracker.

The message to log can the result of block evaluation:

log do
  "evaluate the message to log here with implicit PT:999999 story id"
end

Or the message to log can be passed as an arguent:

log(message)

An explicit story ID can be provided in both block and args form:

log(story_id) do
  "evaluate the message to log here"
end

log(message,story_id)

If story_id is provided, logs to that story, else logs to a story ID referenced in the message itself (as #999 or PT:999).

Returns true if log was successful, else false. Supresses any StandardErrors that may occur during logging.



29
30
31
32
33
34
35
36
37
38
# File 'lib/pt_logger/base.rb', line 29

def self.log(*args)
  if pt = PtLogger::Logger.new
    message = block_given? ? yield : args.shift
    pt.append_story_note(message,args.shift)
  else
    false
  end
rescue
  false
end

.log_if(condition, *args) ⇒ Object

Command: log message to Pivotal Tracker if condition is true.

The message to log can the result of block evaluation:

log_if(condition) do
  "evaluate the message to log here with implicit PT:999999 story id"
end

Or the message to log can be passed as an arguent:

log_if(condition,message)

An explicit story ID can be provided in both block and args form:

log_if(condition,story_id) do
  "evaluate the message to log here"
end

log_if(condition,message,story_id)

If story_id is provided, logs to that story, else logs to a story ID referenced in the message itself (as #999 or PT:999).

Returns true if log was successful, else false. Supresses any StandardErrors that may occur during logging.



66
67
68
69
70
# File 'lib/pt_logger/base.rb', line 66

def self.log_if(condition,*args)
  return false unless condition
  message = block_given? ? yield : args.shift
  log(message,*args)
end

.setup {|_self| ... } ⇒ Object

Default way to setup. Yields a block that gives access to all the config variables.

Yields:

  • (_self)

Yield Parameters:

  • _self (PtLogger)

    the object that the method was called on



8
9
10
# File 'lib/pt_logger/config.rb', line 8

def self.setup
  yield self
end