Sha256: dae9948cbe43b1946b7e156c2832d4b2fe7911606b7228d90ee1e93d0114b885

Contents?: true

Size: 1.2 KB

Versions: 29

Compression:

Stored size: 1.2 KB

Contents

require 'ansi'

module Nutella

  module App

    module Log

      def self.debug(message, code=nil)
        puts( ANSI.cyan + message + ANSI.reset )
        Nutella.app.net.publish( 'logging', log_to_json(message, code, __method__) )
        code
      end

      def self.info(message, code=nil)
        puts( message )
        Nutella.app.net.publish( 'logging', log_to_json(message, code, __method__) )
        code
      end

      def self.success(message, code=nil)
        puts( ANSI.green + message + ANSI.reset )
        Nutella.app.net.publish( 'logging', log_to_json(message, code, __method__) )
        code
      end

      def self.warn(message, code=nil)
        puts( ANSI.yellow + message + ANSI.reset )
        Nutella.app.net.publish( 'logging', log_to_json(message, code, __method__) )
        code
      end

      def self.error(message, code=nil)
        puts( ANSI.red + message + ANSI.reset )
        Nutella.app.net.publish( 'logging', log_to_json(message, code, __method__) )
        code
      end

      private

      def self.log_to_json( message, code, level)
        code.nil? ? {level: level, message: message} : {level: level, message: message, code: code}
      end

    end

  end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
nutella_lib-0.6.0 lib/nutella_lib/app_log.rb
nutella_lib-0.5.0 lib/nutella_lib/app_log.rb
nutella_lib-0.4.27 lib/nutella_lib/app_log.rb
nutella_lib-0.4.26 lib/nutella_lib/app_log.rb
nutella_lib-0.4.25 lib/nutella_lib/app_log.rb
nutella_lib-0.4.24 lib/nutella_lib/app_log.rb
nutella_lib-0.4.23 lib/nutella_lib/app_log.rb
nutella_lib-0.4.22 lib/nutella_lib/app_log.rb
nutella_lib-0.4.21 lib/nutella_lib/app_log.rb
nutella_lib-0.4.20 lib/nutella_lib/app_log.rb
nutella_lib-0.4.19 lib/nutella_lib/app_log.rb
nutella_lib-0.4.18 lib/nutella_lib/app_log.rb
nutella_lib-0.4.17 lib/nutella_lib/app_log.rb
nutella_lib-0.4.16 lib/nutella_lib/app_log.rb
nutella_lib-0.4.15 lib/nutella_lib/app_log.rb
nutella_lib-0.4.14 lib/nutella_lib/app_log.rb
nutella_lib-0.4.13 lib/nutella_lib/app_log.rb
nutella_lib-0.4.12 lib/nutella_lib/app_log.rb
nutella_lib-0.4.11 lib/nutella_lib/app_log.rb
nutella_lib-0.4.10 lib/nutella_lib/app_log.rb