Remove logger
Joel AZEMAR
committed Apr 14, 2014
commit 001fb25c381b181c3cd37b26698690a8565031f8
Showing 15
changed files with
27 additions
and 75 deletions
.gitignore
+2
-0
| @@ | @@ -19,3 +19,5 @@ doc/ |
| .rspec | |
| spec/fixtures/default/log/* | |
| + | |
| + | .ruby-* |
example/server.rb
+11
-6
| @@ | @@ -1,15 +1,18 @@ |
| #!/usr/bin/env ruby | |
| + | require 'rubygems' |
| + | require 'bundler/setup' |
| + | |
| require 'thin' | |
| - | DIR = File.expand_path(File.dirname(__FILE__)) |
| + | require_relative '../lib/steam' |
| + | require_relative '../lib/locomotive/steam/server' |
| + | require_relative '../lib/locomotive/steam/initializers' |
| + | |
| + | path = File.join(File.expand_path(File.dirname(__FILE__)), '../spec/fixtures/default') |
| - | require File.join(DIR, '../lib/steam') |
| - | require File.join(DIR, '../lib/locomotive/steam/server') |
| - | require File.join(DIR, '../lib/locomotive/steam/initializers') |
| + | Locomotive::Common::Logger.setup(path + '/log/steam.log') |
| - | path = File.join(DIR, '../spec/fixtures/default') |
| - | Locomotive::Steam::Logger.setup(path, false) |
| reader = Locomotive::Mounter::Reader::FileSystem.instance | |
| reader.run!(path: path) | |
| @@ | @@ -19,4 +22,6 @@ app = Locomotive::Steam::Server.new(reader, { |
| server = Thin::Server.new('localhost', '3333', app) | |
| server.threaded = true | |
| + | |
| + | Locomotive::Common::Logger.info 'Server started...' |
| server.start | |
| \ No newline at end of file | |
locomotive/steam/exceptions.rb b/lib/locomotive/steam/exceptions.rb
+2
-2
| @@ | @@ -15,7 +15,7 @@ module Locomotive |
| full_error_message = "#{parent_exception.message}\n\t" | |
| full_error_message += parent_exception.backtrace.join("\n\t") | |
| full_error_message += "\n\n" | |
| - | Locomotive::Steam::Logger.fatal full_error_message |
| + | Locomotive::Common::Logger.fatal full_error_message |
| end | |
| end | |
| @@ | @@ -40,7 +40,7 @@ module Locomotive |
| message = "#{self.template.filepath}:#{line}:in `#{self.name}'" | |
| - | Locomotive::Steam::Logger.fatal "[ERROR] #{exception.message} - #{message}\n".red |
| + | Locomotive::Common::Logger.fatal "[ERROR] #{exception.message} - #{message}\n".red |
| exception.backtrace.unshift message | |
| end | |
locomotive/steam/initializers/dragonfly.rb b/lib/locomotive/steam/initializers/dragonfly.rb
+1
-1
| @@ | @@ -15,4 +15,4 @@ Dragonfly.app(:steam).configure do |
| fetch_url_whitelist /.+/ | |
| end | |
| - | Dragonfly.logger = Locomotive::Steam::Logger.instance |
| \ No newline at end of file | |
| + | Dragonfly.logger = Locomotive::Common::Logger.instance |
| \ No newline at end of file | |
locomotive/steam/liquid/scopeable.rb b/lib/locomotive/steam/liquid/scopeable.rb
+2
-2
| @@ | @@ -13,7 +13,7 @@ module Locomotive |
| # build the chains of conditions | |
| conditions = _conditions.map { |name, value| Condition.new(name, value) } | |
| - | Locomotive::Steam::Logger.info "[with_scope] conditions: #{conditions.map(&:to_s).join(', ')}" |
| + | Locomotive::Common::Logger.info "[with_scope] conditions: #{conditions.map(&:to_s).join(', ')}" |
| # get only the entries matching ALL the conditions | |
| _entries = entries.find_all do |content| | |
| @@ | @@ -38,7 +38,7 @@ module Locomotive |
| name, direction = order_by.split.map(&:to_sym) | |
| - | Locomotive::Steam::Logger.info "[with_scope] order_by #{name} #{direction || 'asc'}" |
| + | Locomotive::Common::Logger.info "[with_scope] order_by #{name} #{direction || 'asc'}" |
| if direction == :asc || direction.nil? | |
| entries.sort { |a, b| a.send(name) <=> b.send(name) } | |
locomotive/steam/liquid/tags/editable/short_text.rb b/lib/locomotive/steam/liquid/tags/editable/short_text.rb
+1
-1
| @@ | @@ -6,7 +6,7 @@ module Locomotive |
| class ShortText < Base | |
| def render(context) | |
| - | Locomotive::Steam::Logger.warn " [#{self.current_block_name(context)}/#{@slug}] The editable_{short|long}_text tags are deprecated. Use editable_text instead.".colorize(:orange) |
| + | Locomotive::Common::Logger.warn " [#{self.current_block_name(context)}/#{@slug}] The editable_{short|long}_text tags are deprecated. Use editable_text instead.".colorize(:orange) |
| super(context) | |
| end | |
locomotive/steam/liquid/tags/snippet.rb b/lib/locomotive/steam/liquid/tags/snippet.rb
+1
-1
| @@ | @@ -30,7 +30,7 @@ module Locomotive |
| partial.render(context) | |
| end) | |
| - | Locomotive::Steam::Logger.info " Steamed snippet #{name}" |
| + | Locomotive::Common::Logger.info " Steamed snippet #{name}" |
| output | |
| end | |
locomotive/steam/logger.rb b/lib/locomotive/steam/logger.rb
+0
-54
| @@ | @@ -1,54 +0,0 @@ |
| - | module Locomotive |
| - | module Steam |
| - | |
| - | class Logger |
| - | |
| - | attr_accessor :logger, :logfile_path, :stdout |
| - | |
| - | def initialize |
| - | self.logger = nil |
| - | end |
| - | |
| - | # Setup the single instance of the ruby logger. |
| - | # |
| - | # @param [ String ] path The path to the log file (default: log/steam.log) |
| - | # @param [ Boolean ] stdout Instead of having a file, log to the standard output |
| - | # |
| - | def setup(path, stdout = false) |
| - | require 'logger' |
| - | |
| - | self.stdout = stdout |
| - | |
| - | self.logfile_path = File.expand_path(File.join(path, 'log', 'steam.log')) |
| - | FileUtils.mkdir_p(File.dirname(logfile_path)) |
| - | |
| - | out = self.stdout ? STDOUT : self.logfile_path |
| - | |
| - | self.logger = ::Logger.new(out).tap do |log| |
| - | log.level = ::Logger::DEBUG |
| - | log.formatter = proc do |severity, datetime, progname, msg| |
| - | "#{msg}\n" |
| - | end |
| - | end |
| - | end |
| - | |
| - | def self.instance |
| - | @@instance ||= self.new |
| - | end |
| - | |
| - | def self.setup(path, stdout = false) |
| - | self.instance.setup(path, stdout) |
| - | end |
| - | |
| - | class << self |
| - | %w(debug info warn error fatal unknown).each do |name| |
| - | define_method(name) do |message| |
| - | self.instance.logger.send(name.to_sym, message) |
| - | end |
| - | end |
| - | end |
| - | |
| - | end |
| - | |
| - | end |
| - | end |
| \ No newline at end of file | |
locomotive/steam/middlewares/base.rb b/lib/locomotive/steam/middlewares/base.rb
+1
-1
| @@ | @@ -54,7 +54,7 @@ module Locomotive::Steam |
| end | |
| def log(msg) | |
| - | Locomotive::Steam::Logger.info msg |
| + | Locomotive::Common::Logger.info msg |
| end | |
| end | |
locomotive/steam/middlewares/renderer.rb b/lib/locomotive/steam/middlewares/renderer.rb
+1
-1
| @@ | @@ -109,7 +109,7 @@ module Locomotive::Steam |
| mounting_point: self.mounting_point, | |
| services: self.services, | |
| inline_editor: false, | |
| - | logger: Locomotive::Steam::Logger |
| + | logger: Locomotive::Common::Logger |
| } | |
| end | |
locomotive/steam/services/dragonfly.rb b/lib/locomotive/steam/services/dragonfly.rb
+1
-1
| @@ | @@ -16,7 +16,7 @@ module Locomotive |
| def resize_url(source, resize_string) | |
| image = (case url_or_path = get_url_or_path(source) | |
| when '', nil | |
| - | Locomotive::Steam::Logger.error "Unable to resize on the fly: #{source.inspect}" |
| + | Locomotive::Common::Logger.error "Unable to resize on the fly: #{source.inspect}" |
| nil | |
| when /^http:\/\// | |
| app.fetch_url(url_or_path) | |
locomotive/steam/services/external_api.rb b/lib/locomotive/steam/services/external_api.rb
+2
-2
| @@ | @@ -22,7 +22,7 @@ module Locomotive |
| path ||= '/' | |
| - | # Locomotive::Steam::Logger.debug "[WebService] consuming #{path}, #{options.inspect}" |
| + | # Locomotive::Common::Logger.debug "[WebService] consuming #{path}, #{options.inspect}" |
| response = self.class.get(path, options) | |
| @@ | @@ -34,7 +34,7 @@ module Locomotive |
| _response.collect(&:underscore_keys) | |
| end | |
| else | |
| - | Locomotive::Steam::Logger.error "[WebService] consumed #{path}, #{options.inspect}, response = #{response.inspect}" |
| + | Locomotive::Common::Logger.error "[WebService] consumed #{path}, #{options.inspect}, response = #{response.inspect}" |
| nil | |
| end | |
locomotive/steam/standalone_server.rb b/lib/locomotive/steam/standalone_server.rb
+1
-1
| @@ | @@ -12,7 +12,7 @@ module Locomotive |
| class StandaloneServer < Server | |
| def initialize(path) | |
| - | Locomotive::Steam::Logger.setup(path, false) |
| + | Locomotive::Common::Logger.setup(path, false) |
| # get the reader | |
| reader = Locomotive::Mounter::Reader::FileSystem.instance | |
steam.rb b/lib/steam.rb
+0
-1
| @@ | @@ -1,4 +1,3 @@ |
| require_relative 'locomotive/steam/version' | |
| - | require_relative 'locomotive/steam/logger' |
| require_relative 'locomotive/steam/exceptions' | |
spec/support/helpers.rb
+1
-1
| @@ | @@ -11,7 +11,7 @@ module Spec |
| def run_server | |
| path = 'spec/fixtures/default' | |
| - | Locomotive::Steam::Logger.setup(path, false) |
| + | Locomotive::Common::Logger.setup(path, false) |
| reader = Locomotive::Mounter::Reader::FileSystem.instance | |
| reader.run!(path: path) | |