Sha256: 59da10790e67edde7856d5e32f5ea00c6afb98a1a401add303ed8d4935b7f016

Contents?: true

Size: 1.19 KB

Versions: 59

Compression:

Stored size: 1.19 KB

Contents

require 'ansi'

module Nutella

  module Framework

    module Log

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

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

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

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

      def self.error(message, code=nil)
        puts( ANSI.red + message + ANSI.reset )
        Nutella.f.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

59 entries across 59 versions & 2 rubygems

Version Path
nutella_lib-0.6.0 lib/nutella_lib/framework_log.rb
nutella_lib-0.5.0 lib/nutella_lib/framework_log.rb
nutella_framework-0.9.2 nutella_lib/framework_log.rb
nutella_framework-0.9.1 nutella_lib/framework_log.rb
nutella_framework-0.9.0 nutella_lib/framework_log.rb
nutella_framework-0.8.0 nutella_lib/framework_log.rb
nutella_framework-0.7.3 nutella_lib/framework_log.rb
nutella_framework-0.7.2 nutella_lib/framework_log.rb
nutella_framework-0.7.1 nutella_lib/framework_log.rb
nutella_framework-0.7.0 nutella_lib/framework_log.rb
nutella_framework-0.6.21 nutella_lib/framework_log.rb
nutella_framework-0.6.20 nutella_lib/framework_log.rb
nutella_framework-0.6.19 nutella_lib/framework_log.rb
nutella_framework-0.6.18 nutella_lib/framework_log.rb
nutella_framework-0.6.17 nutella_lib/framework_log.rb
nutella_framework-0.6.16 nutella_lib/framework_log.rb
nutella_framework-0.6.15 nutella_lib/framework_log.rb
nutella_framework-0.6.13 nutella_lib/framework_log.rb
nutella_framework-0.6.12 nutella_lib/framework_log.rb
nutella_framework-0.6.11 nutella_lib/framework_log.rb