Sha256: 56f1a05117fa8e58d2f27f2e72820eca19afa84877e8ce5c5af2fdb5fc260261

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 Bytes

Contents

module Jlog

  class AjaxController < ActionController::Metal
    include ActionController::Rendering

    def append
      message = params[:message]
      level_pattern = /([A-Z]*) - /
      level = message.match(level_pattern)[1]
      message = 'Client Log: ' << message

      if ['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'].include? level
        Rails.logger.send(level.downcase.to_sym, message)
      else
        Rails.logger.warn('*** Attempt to log with a nonexistent level ***')
        Rails.logger.warn(message)
      end

      render text: 'ok', status: :ok
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jlog-rails-0.0.1 app/controllers/jlog/ajax_controller.rb