mirror of
https://github.com/plashchynski/crono.git
synced 2026-07-06 21:05:19 +02:00
Add custom Logger
This commit is contained in:
@@ -3,6 +3,7 @@ end
|
|||||||
|
|
||||||
require "active_support/all"
|
require "active_support/all"
|
||||||
require "crono/version.rb"
|
require "crono/version.rb"
|
||||||
|
require "crono/logger.rb"
|
||||||
require "crono/period.rb"
|
require "crono/period.rb"
|
||||||
require "crono/schedule.rb"
|
require "crono/schedule.rb"
|
||||||
require "crono/config.rb"
|
require "crono/config.rb"
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
module Crono
|
||||||
|
class Logger < ::Logger
|
||||||
|
include Singleton
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
super(Crono.config.daemonize ? Crono.config.logfile : STDOUT)
|
||||||
|
self.level = Logger::DEBUG
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.logger
|
||||||
|
Logger.instance
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
module Crono
|
|
||||||
end
|
|
||||||
@@ -38,5 +38,10 @@ describe Crono::CLI do
|
|||||||
cli.send(:parse_options, ["--logfile", "log/crono.log"])
|
cli.send(:parse_options, ["--logfile", "log/crono.log"])
|
||||||
expect(Crono.config.logfile).to be_eql "log/crono.log"
|
expect(Crono.config.logfile).to be_eql "log/crono.log"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should set daemonize" do
|
||||||
|
cli.send(:parse_options, ["--daemonize"])
|
||||||
|
expect(Crono.config.daemonize).to be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
describe Crono::Logger do
|
||||||
|
describe "#initialize" do
|
||||||
|
it "should initialize logger" do
|
||||||
|
expect {
|
||||||
|
Crono.logger.info("Test")
|
||||||
|
}.to_not raise_error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user