rails_objects_logger 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,9 @@ require "rails_objects_logger/version"
2
2
 
3
3
  module RailsObjectsLogger
4
4
  def self.log(level, class_name, message)
5
- Rails.logger.send(level, "#{level.to_s.capitalize}##{class_name}: #{message}")
5
+ filename, line_number = caller[2].scan(/\/([\w\.]+)\:(\d+)/).flatten
6
+ extra_info = (filename == (class_name.gsub(/(.)([A-Z])/,'\1_\2').downcase + ".rb")) ? "" : "(from #{filename})"
7
+ Rails.logger.send(level, "#{level.to_s.capitalize}##{class_name}:#{line_number}#{extra_info}: #{message}")
6
8
  end
7
9
  end
8
10
 
@@ -1,3 +1,3 @@
1
1
  module RailsObjectsLogger
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -14,8 +14,8 @@ describe RailsObjectsLogger do
14
14
  describe "Class Methods" do
15
15
  describe "#log" do
16
16
  context "passing level debug, class name \"Citaskit\" and message \"My awesome debug message that will make me understand what is going wrong.\"" do
17
- it "should call Rails.logger.debug and log \"Debug#Citaskit: My awesome debug message that will make me understand what is going wrong.\"" do
18
- Rails.logger.should_receive(:debug).with("Debug#Citaskit: My awesome debug message that will make me understand what is going wrong.")
17
+ it "should call Rails.logger.debug and log \"Debug#Citaskit:114(from example.rb): My awesome debug message that will make me understand what is going wrong.\"" do
18
+ Rails.logger.should_receive(:debug).with("Debug#Citaskit:114(from example.rb): My awesome debug message that will make me understand what is going wrong.")
19
19
  RailsObjectsLogger.log(
20
20
  :debug,
21
21
  "Citaskit",
@@ -24,8 +24,8 @@ describe RailsObjectsLogger do
24
24
  end
25
25
  end
26
26
  context "passing level info, class name \"Citaskit\" and message \"This information message help to know the current state of the application.\"" do
27
- it "should call Rails.logger.info and log \"Info#Citaskit: This information message help to know the current state of the application.\"" do
28
- Rails.logger.should_receive(:info).with("Info#Citaskit: This information message help to know the current state of the application.")
27
+ it "should call Rails.logger.info and log \"Info#Citaskit:114(from example.rb): This information message help to know the current state of the application.\"" do
28
+ Rails.logger.should_receive(:info).with("Info#Citaskit:114(from example.rb): This information message help to know the current state of the application.")
29
29
  RailsObjectsLogger.log(
30
30
  :info,
31
31
  "Citaskit",
@@ -34,8 +34,8 @@ describe RailsObjectsLogger do
34
34
  end
35
35
  end
36
36
  context "passing level warn, class name \"Citaskit\" and message \"Achtung! This message is important!\"" do
37
- it "should call Rails.logger.warn and log \"Warn#Citaskit: Achtung! This message is important!\"" do
38
- Rails.logger.should_receive(:warn).with("Warn#Citaskit: Achtung! This message is important!")
37
+ it "should call Rails.logger.warn and log \"Warn#Citaskit:114(from example.rb): Achtung! This message is important!\"" do
38
+ Rails.logger.should_receive(:warn).with("Warn#Citaskit:114(from example.rb): Achtung! This message is important!")
39
39
  RailsObjectsLogger.log(
40
40
  :warn,
41
41
  "Citaskit",
@@ -44,8 +44,8 @@ describe RailsObjectsLogger do
44
44
  end
45
45
  end
46
46
  context "passing level error, class name \"Citaskit\" and message \"CRITICAL ERROR! YOUR APP IS DEAD!\"" do
47
- it "should call Rails.logger.error and log \"Error#Citaskit: CRITICAL ERROR! YOUR APP IS DEAD!\"" do
48
- Rails.logger.should_receive(:error).with("Error#Citaskit: CRITICAL ERROR! YOUR APP IS DEAD!")
47
+ it "should call Rails.logger.error and log \"Error#Citaskit:114(from example.rb): CRITICAL ERROR! YOUR APP IS DEAD!\"" do
48
+ Rails.logger.should_receive(:error).with("Error#Citaskit:114(from example.rb): CRITICAL ERROR! YOUR APP IS DEAD!")
49
49
  RailsObjectsLogger.log(
50
50
  :error,
51
51
  "Citaskit",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_objects_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-25 00:00:00.000000000 Z
12
+ date: 2012-12-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
63
  version: '0'
64
64
  segments:
65
65
  - 0
66
- hash: -2819341135527539488
66
+ hash: -3512945045103427101
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  none: false
69
69
  requirements:
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  version: '0'
73
73
  segments:
74
74
  - 0
75
- hash: -2819341135527539488
75
+ hash: -3512945045103427101
76
76
  requirements: []
77
77
  rubyforge_project:
78
78
  rubygems_version: 1.8.24