db_logger 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ Session.vim
6
+ db/*.sqlite3
7
+ vendor/*
8
+ log/*.log
9
+ tmp/**/*
10
+ nbproject/*
11
+ *.swp
12
+ *.swo
13
+ *.vim
14
+ .rvmrc
15
+ .sass-cache/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## v0.0.1
2
+
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in db_logger.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (C) 2012 Gregory Silcox
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # DB Logger
2
+
3
+ Writes log messages to a database table.
4
+
5
+ ## Installation
6
+
7
+ add to your Gemfile and run the `bundle` command to install it.
8
+
9
+ ```ruby
10
+ gem "db_logger"
11
+ ```
12
+
13
+ **Requires PostgreSQL HSTORE and Rails 3.1 store.**
14
+
15
+ ## Usage
16
+ Note: this section is under construction...
17
+ 1. Add a table to the database with the right columns.
18
+ 2. Instantiate a DbLogger
19
+ 3. Log using the appropriate level, such as log.debug( "My message" ).
20
+
21
+ ## Development
22
+ Questions or problems? Please post them on the [issue tracker](https://github.com/GregSilcox/db_logger/issues). You can contribut changes by forking the project and submitting a pull requrest. You can ensure the tests are passing by running `bundle` and `rake`.
23
+
24
+ This gem is created by Greg Silcox and is under the MIT License.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new( :spec )
5
+ task default: :spec
data/db_logger.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "db_logger/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "db_logger"
7
+ s.version = DbLogger::VERSION
8
+ s.authors = ["Greg Silcox"]
9
+ s.email = ["greg.silcox@cumulsity.com"]
10
+ s.homepage = "http://github.com/GregSilcox/db_logger"
11
+ s.summary = %q{Writes log messages to a database table.}
12
+ s.description = %q{Captures sophisticated messages throughout a rails app and stores them in a postgresql hstore field.}
13
+
14
+ s.rubyforge_project = "db_logger"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency "rspec"
22
+ s.add_development_dependency "rake"
23
+ s.add_development_dependency "supermodel"
24
+ end
data/lib/db_logger.rb ADDED
@@ -0,0 +1,10 @@
1
+ require "db_logger/version"
2
+ require 'db_logger/model_additions'
3
+ require 'db_logger/railtie' if defined? Rails
4
+
5
+ module DbLogger
6
+ # Code goes here...
7
+ def self.debug message
8
+ return "Debug: #{ message }"
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module DbLogger
2
+
3
+ def self.debug message
4
+ return message
5
+ end
6
+
7
+ end
@@ -0,0 +1,12 @@
1
+ module DbLogger
2
+ module ModelAdditions
3
+ # Validations go here...
4
+ # Methods that depend on ActiveRecord go here...
5
+ def debug message
6
+ # before_validation do
7
+ # send "#{ message }=", DbLogger.debug( send message )
8
+ # true
9
+ #end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module DbLogger
2
+ class Railtie < Rails::Railtie
3
+ initializer 'db_logger.model_additions' do
4
+ ActiveSupport.on_load :active_record do
5
+ extend ModelAdditions
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module DbLogger
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ # test validations or anything depending on ActiveRecord
4
+ class Importer < SuperModel::Base
5
+ include ActiveModel::Validations::Callbacks
6
+ extend DbLogger::ModelAdditions
7
+ # debug "a class message"
8
+ end
9
+
10
+ describe DbLogger::ModelAdditions do
11
+ it "does nothing" do
12
+ Importer.create.should be_a( Importer )
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ # Test methods...
4
+ describe DbLogger do
5
+ describe "debug" do
6
+ it "adds a debug message to the table." do
7
+ DbLogger.debug( "A test message" ).should eq( "Debug: A test message" )
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,2 @@
1
+ require 'db_logger'
2
+ require 'supermodel'
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: db_logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Greg Silcox
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &77114250 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *77114250
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &77113250 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *77113250
36
+ - !ruby/object:Gem::Dependency
37
+ name: supermodel
38
+ requirement: &77112610 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *77112610
47
+ description: Captures sophisticated messages throughout a rails app and stores them
48
+ in a postgresql hstore field.
49
+ email:
50
+ - greg.silcox@cumulsity.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - .rspec
57
+ - CHANGELOG.md
58
+ - Gemfile
59
+ - LICENSE
60
+ - README.md
61
+ - Rakefile
62
+ - db_logger.gemspec
63
+ - lib/db_logger.rb
64
+ - lib/db_logger/db_logger.rb
65
+ - lib/db_logger/model_additions.rb
66
+ - lib/db_logger/railtie.rb
67
+ - lib/db_logger/version.rb
68
+ - spec/db_logger/model_additions_spec.rb
69
+ - spec/db_logger_spec.rb
70
+ - spec/spec_helper.rb
71
+ homepage: http://github.com/GregSilcox/db_logger
72
+ licenses: []
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ segments:
84
+ - 0
85
+ hash: -697232639
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ segments:
93
+ - 0
94
+ hash: -697232639
95
+ requirements: []
96
+ rubyforge_project: db_logger
97
+ rubygems_version: 1.8.15
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: Writes log messages to a database table.
101
+ test_files: []