Sha256: 94852e83842dc4f3519eb12dc25288a83877385be128343ae0d093662c023772

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

# -*- coding: utf-8 -*-
=begin rdoc
Please see README
=end

require "sixarm_ruby_ramp"

module Vital


  # Log a message with timestamp, calling class, method name, process info, etc.
  #
  # ==Example
  #   vital("hello")
  #   => logger.info 2010-12-31 class_name method_name process_info ... hello
  def vital(msg='',ops={})
    method_name = ops[:method_name]||method_name_of_caller
    logger.info [Time.stamp,self.class.name,method_name,Process.ps_tdf].join("\t")+"\t"+msg
  end


  # Log a message that is intended to open (i.e. begin) a topic.
  #
  # This simply calls _vital_ with "+" prepended to
  # the message, which is our indicator of a new topic.
  #
  # Example:
  #   vital_open("hello")
  #   => logger.info 2010-12-31 class_name method_name process_info ... +hello

  def vital_open(msg='',ops={})
    vital('+'+msg,ops.merge({:method_name=>method_name_of_caller}))
  end


  # Log a message that is intended to shut (i.e. end) a topic.
  #
  # This simply calls _vital_ with "+" prepended to
  # the message, which is our indicator of a new topic.
  #
  # Example:
  #   vital_open("hello")
  #   => logger.info 2010-12-31 class_name method_name process_info ... -hello

  def vital_shut(msg='',ops={})
    vital('-'+msg,ops.merge({:method_name=>method_name_of_caller}))
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sixarm_ruby_vital-1.0.4 lib/sixarm_ruby_vital.rb