log4r-sequel 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e2df9143f88d2565644c34dd200a0c66a4d49f5
4
- data.tar.gz: c76ec6079a80db159faac195d8890e8757794e25
3
+ metadata.gz: bbcb59ef938e2f81f26cc69a2d19499eab310e5b
4
+ data.tar.gz: 1a44bf191adb4e188142e2ddc4e3002ecbc0ee97
5
5
  SHA512:
6
- metadata.gz: 6fbd50621319256bad2e8c8ca51a88e3df425c02da1abdcdfb525f0fa98474b0743aafa60427a081c4f43d503e4ad02b51abc63f27105c0cfa0655866acd3551
7
- data.tar.gz: bc46f2fd5e8ef4a268f6ff5151e8f70ca21f03656ec7c720a51d556757ab2a1c8e2298661f669bc72772e66999c8c3f58116f1aa0bf051a1e0bc7cba98f1ba30
6
+ metadata.gz: dc8530fafb4a599c17eeab549cae77f9ed055dac763b237534a8fc3d0bf0cf2cc58cfc2b1311eb2889e4fdeaa99234a50d4be5eaea1781d9f4ef772af935f3d9
7
+ data.tar.gz: c9801a3ea103a0d0a3663e30a48e524594dc21b3dddb7fb297f36ceaa7906395ee54189c42168975fb698d6f2742791c52f1707458afbd0455505fb763511650
data/Gemfile CHANGED
@@ -5,11 +5,6 @@ source 'https://rubygems.org'
5
5
 
6
6
  gem 'log4r', '~> 1.1.9', '> 1.1'
7
7
 
8
- # ugh this is so stupid - jeweler pulls in the latest version of this -
9
- # through it's own dependency, causing a hard requirement on ruby 2.3.x,
10
- # locking it down this way
11
- gem 'rack', '= 1.6.4'
12
-
13
8
  gem 'sequel', '~> 4.6', '>= 4.6.0'
14
9
 
15
10
  # making ruby 2.3.0 happy
@@ -18,6 +13,11 @@ gem 'hoe', '~> 3.15', '>= 3.15.1'
18
13
  group :development do
19
14
  gem 'jeweler', '~> 2.0', '>= 2.0.0'
20
15
  gem 'test-unit', '~> 2.0', '>= 2.0.0'
16
+
17
+ # ugh this is so stupid - jeweler pulls in the latest version of this -
18
+ # through it's own dependency, causing a hard requirement on ruby 2.3.x,
19
+ # locking it down this way
20
+ gem 'rack', '= 1.6.4'
21
21
  end
22
22
 
23
23
  group :sqlite do
@@ -8,18 +8,17 @@ GEM
8
8
  faraday (0.9.2)
9
9
  multipart-post (>= 1.2, < 3)
10
10
  git (1.3.0)
11
- github_api (0.13.1)
11
+ github_api (0.14.5)
12
12
  addressable (~> 2.4.0)
13
13
  descendants_tracker (~> 0.0.4)
14
14
  faraday (~> 0.8, < 0.10)
15
15
  hashie (>= 3.4)
16
- multi_json (>= 1.7.5, < 2.0)
17
- oauth2
18
- hashie (3.4.4)
16
+ oauth2 (~> 1.0)
17
+ hashie (3.4.6)
19
18
  highline (1.7.8)
20
19
  hoe (3.15.1)
21
20
  rake (>= 0.8, < 12.0)
22
- jeweler (2.0.1)
21
+ jeweler (2.1.1)
23
22
  builder
24
23
  bundler (>= 1.0)
25
24
  git (>= 1.2.5)
@@ -28,29 +27,33 @@ GEM
28
27
  nokogiri (>= 1.5.10)
29
28
  rake
30
29
  rdoc
30
+ semver
31
31
  json (1.8.3)
32
- jwt (1.5.1)
32
+ jwt (1.5.6)
33
33
  log4r (1.1.10)
34
- mini_portile2 (2.0.0)
34
+ mini_portile2 (2.1.0)
35
35
  multi_json (1.12.1)
36
36
  multi_xml (0.5.5)
37
37
  multipart-post (2.0.0)
38
- nokogiri (1.6.7.2)
39
- mini_portile2 (~> 2.0.0.rc2)
40
- oauth2 (1.1.0)
38
+ nokogiri (1.6.8)
39
+ mini_portile2 (~> 2.1.0)
40
+ pkg-config (~> 1.1.7)
41
+ oauth2 (1.2.0)
41
42
  faraday (>= 0.8, < 0.10)
42
- jwt (~> 1.0, < 1.5.2)
43
+ jwt (~> 1.0)
43
44
  multi_json (~> 1.3)
44
45
  multi_xml (~> 0.5)
45
46
  rack (>= 1.2, < 3)
46
47
  pg (0.18.4)
48
+ pkg-config (1.1.7)
47
49
  rack (1.6.4)
48
50
  rake (11.2.2)
49
51
  rdoc (4.2.2)
50
52
  json (~> 1.4)
51
- sequel (4.37.0)
53
+ semver (1.0.1)
54
+ sequel (4.38.0)
52
55
  sqlite3 (1.3.11)
53
- test-unit (2.0.0.0)
56
+ test-unit (2.5.5)
54
57
  thread_safe (0.3.5)
55
58
 
56
59
  PLATFORMS
data/README.md CHANGED
@@ -6,9 +6,9 @@ Log4r outputter to a Sequel database handle
6
6
  - [from-source installation (latest)](#from-source-installation-latest)
7
7
  - [demo](#demo)
8
8
  - [supported databases](#supported-databases)
9
- - [TODO](#todo)
9
+ - [notes](#notes)
10
10
 
11
- the de-facto standard library for logging in Ruby, [log4r](https://github.com/colbygk/log4r) works very well for a wide array of logging targets:
11
+ the de-facto standard library for logging in Ruby, [log4r](https://github.com/colbygk/log4r), works very well for a wide array of logging targets:
12
12
  * STDOUT / STDERR
13
13
  * file
14
14
  * email
@@ -16,6 +16,8 @@ the de-facto standard library for logging in Ruby, [log4r](https://github.com/co
16
16
 
17
17
  and so on, but didn't have a way to output directly to a database - enter `log4r-sequel`
18
18
 
19
+ this project was inspired/motivated by the fact that [chainsaw](http://log4r.rubyforge.org/manual.html#chainsaw) isn't supported on recent versions of OSX.
20
+
19
21
  ## usage
20
22
 
21
23
  ### pre-built gem installation (stable)
@@ -51,7 +53,7 @@ irb(main):001:0> require 'log4r/outputter/sequeloutputter'
51
53
  ### demo
52
54
 
53
55
  ```
54
- $ ruby example/log2postgres.rb
56
+ $ ruby example/log2sqlite.rb
55
57
  2016/08/27 17:08.1472342938 | bar | DEBUG | this is a debug message
56
58
  2016/08/27 17:08.1472342938 | bar | INFO | this is an info message
57
59
  2016/08/27 17:08.1472342938 | bar | WARN | this is a warning
@@ -73,11 +75,6 @@ sqlite>
73
75
  * sqlite3
74
76
  * Postgres
75
77
 
76
- ## TODO
77
- * tests
78
- * unit tests
79
-
80
-
81
78
  ## notes
82
79
  * `:database`, `:table`, and `:file` options are passed through `Time.now.strftime(%s)`
83
80
  * sqlite filenames cannot contain underscores (`the scheme sqlite does not accept registry part`)
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ Jeweler::Tasks.new do |gem|
15
15
  gem.authors = ['Conor Horan-Kates']
16
16
  gem.licenses = 'MIT'
17
17
 
18
- gem.files.exclude 'examples/*'
18
+ gem.files.exclude 'example/*'
19
19
  gem.files.exclude 'pkg/*'
20
20
  end
21
21
  Jeweler::RubygemsDotOrgTasks.new
@@ -26,9 +26,16 @@ namespace :test do
26
26
  t.name = 'functional'
27
27
  t.libs << 'lib'
28
28
  t.test_files = FileList['test/functional/**/test_*.rb']
29
- #t.verbose = true
29
+ t.verbose = false
30
+ end
31
+
32
+ Rake::TestTask.new do |t|
33
+ t.name = 'unit'
34
+ t.libs << 'lib'
35
+ t.test_files = FileList['test/unit/**/test_*.rb']
36
+ t.verbose = false
30
37
  end
31
38
 
32
39
  end
33
40
  desc 'run all tests'
34
- task :test => ['clean', 'test:functional'] do; end
41
+ task :test => ['clean', 'test:functional', 'test:unit'] do; end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -3,18 +3,6 @@ require 'log4r/yamlconfigurator'
3
3
  require 'sequel'
4
4
  require 'yaml'
5
5
 
6
- class Log4r::Logger
7
-
8
- # no parameters, returns the first Log4r::Outputter::Sequel object
9
- def get_outputter
10
- self.outputters.each do |op|
11
- next unless op.is_a?(SequelOutputter)
12
- return op
13
- end
14
- end
15
-
16
- end
17
-
18
6
  class SequelOutputter < Log4r::Outputter
19
7
 
20
8
  KNOWN_ENGINES = [
@@ -51,6 +39,8 @@ class SequelOutputter < Log4r::Outputter
51
39
 
52
40
  {
53
41
  :delimiter => @delimiter,
42
+ :engine => @engine,
43
+ :formatter => config[:formatter], # feels a bit weird mixing instance variables and referencing the hash directly
54
44
  :map => @map,
55
45
  :table => @table,
56
46
  }.each_pair do |key, value|
@@ -108,6 +98,7 @@ class SequelOutputter < Log4r::Outputter
108
98
 
109
99
  def initialize_db
110
100
  map = @map # we're in a different class in the block below, can't access
101
+ # TODO would be better to check to see if the DB is good rather than just throw an exception here
111
102
  @dbh.create_table? @table do
112
103
  primary_key :id
113
104
  map.values.each do |v|
@@ -0,0 +1,69 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: log4r-sequel 0.0.3 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "log4r-sequel"
9
+ s.version = "0.0.3"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Conor Horan-Kates"]
14
+ s.date = "2016-09-20"
15
+ s.description = "Log4r::Outputter that writes to a Sequel database"
16
+ s.email = ["conor.code@gmail.com"]
17
+ s.extra_rdoc_files = [
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ ".travis.yml",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/log4r/outputter/sequeloutputter.rb",
28
+ "log4r-sequel.gemspec",
29
+ "test/config/log4r-postgres.yaml",
30
+ "test/config/log4r-sqlite.yaml",
31
+ "test/functional/test_postgres.rb",
32
+ "test/functional/test_sqlite.rb",
33
+ "test/helper.rb",
34
+ "test/unit/test_postgres.rb",
35
+ "test/unit/test_sqlite.rb"
36
+ ]
37
+ s.homepage = "http://github.com/chorankates/log4r-sequel"
38
+ s.licenses = ["MIT"]
39
+ s.rubygems_version = "2.4.8"
40
+ s.summary = "Log4r::Outputter::Sequel"
41
+
42
+ if s.respond_to? :specification_version then
43
+ s.specification_version = 4
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<log4r>, ["> 1.1", "~> 1.1.9"])
47
+ s.add_runtime_dependency(%q<sequel>, [">= 4.6.0", "~> 4.6"])
48
+ s.add_runtime_dependency(%q<hoe>, [">= 3.15.1", "~> 3.15"])
49
+ s.add_development_dependency(%q<jeweler>, [">= 2.0.0", "~> 2.0"])
50
+ s.add_development_dependency(%q<test-unit>, [">= 2.0.0", "~> 2.0"])
51
+ s.add_development_dependency(%q<rack>, ["= 1.6.4"])
52
+ else
53
+ s.add_dependency(%q<log4r>, ["> 1.1", "~> 1.1.9"])
54
+ s.add_dependency(%q<sequel>, [">= 4.6.0", "~> 4.6"])
55
+ s.add_dependency(%q<hoe>, [">= 3.15.1", "~> 3.15"])
56
+ s.add_dependency(%q<jeweler>, [">= 2.0.0", "~> 2.0"])
57
+ s.add_dependency(%q<test-unit>, [">= 2.0.0", "~> 2.0"])
58
+ s.add_dependency(%q<rack>, ["= 1.6.4"])
59
+ end
60
+ else
61
+ s.add_dependency(%q<log4r>, ["> 1.1", "~> 1.1.9"])
62
+ s.add_dependency(%q<sequel>, [">= 4.6.0", "~> 4.6"])
63
+ s.add_dependency(%q<hoe>, [">= 3.15.1", "~> 3.15"])
64
+ s.add_dependency(%q<jeweler>, [">= 2.0.0", "~> 2.0"])
65
+ s.add_dependency(%q<test-unit>, [">= 2.0.0", "~> 2.0"])
66
+ s.add_dependency(%q<rack>, ["= 1.6.4"])
67
+ end
68
+ end
69
+
@@ -32,4 +32,4 @@ log4r_config:
32
32
  0: 'date'
33
33
  1: 'level'
34
34
  2: 'class'
35
- 3: 'message'
35
+ 3: 'message'
@@ -1,12 +1,12 @@
1
- $LOAD_PATH << sprintf('%s/../../lib', File.dirname(__FILE__))
2
- require 'log4r/outputter/sequeloutputter'
1
+ $LOAD_PATH << sprintf('%s/../', File.dirname(__FILE__))
3
2
 
4
- require 'test/unit'
3
+ require 'helper'
5
4
 
6
5
  class TestPostgres < Test::Unit::TestCase
7
6
 
8
7
  def setup
9
- @good_config = sprintf('%s/../log4r-postgres_test.yaml', File.expand_path(File.dirname(__FILE__)))
8
+ # TODO move this to a helper class - or a function that returns one based on .. criteria
9
+ @good_config = sprintf('%s/../config/log4r-postgres.yaml', File.expand_path(File.dirname(__FILE__)))
10
10
  @table = Time.now.strftime('logs-%Y/%m/%d-%H:%M').to_sym
11
11
 
12
12
  begin
@@ -44,10 +44,6 @@ class TestPostgres < Test::Unit::TestCase
44
44
 
45
45
  end
46
46
 
47
- def test_sad_yaml
48
- # TODO pass in bad configs as hashes
49
- end
50
-
51
47
  def test_happy_hash
52
48
  logger = nil
53
49
 
@@ -1,12 +1,12 @@
1
- $LOAD_PATH << sprintf('%s/../../lib', File.dirname(__FILE__))
2
- require 'log4r/outputter/sequeloutputter'
1
+ $LOAD_PATH << sprintf('%s/../', File.dirname(__FILE__))
2
+
3
+ require 'helper'
3
4
 
4
- require 'test/unit'
5
5
 
6
6
  class TestSqlite < Test::Unit::TestCase
7
7
 
8
8
  def setup
9
- @good_config = sprintf('%s/../log4r-sqlite_test.yaml', File.expand_path(File.dirname(__FILE__)))
9
+ @good_config = sprintf('%s/../config/log4r-sqlite.yaml', File.expand_path(File.dirname(__FILE__)))
10
10
  @table = :logs
11
11
 
12
12
  begin
@@ -20,7 +20,6 @@ class TestSqlite < Test::Unit::TestCase
20
20
  # TODO remove the database.. assume it's just '*.sqlite' in this path?
21
21
  end
22
22
 
23
-
24
23
  def test_happy_yaml
25
24
  file = @good_config
26
25
  Log4r::YamlConfigurator.load_yaml_file(file)
@@ -46,10 +45,6 @@ class TestSqlite < Test::Unit::TestCase
46
45
 
47
46
  end
48
47
 
49
- def test_sad_yaml
50
- # TODO pass in bad configs as hashes
51
- end
52
-
53
48
  def test_happy_hash
54
49
  logger = nil
55
50
 
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ ## helper.rb sets up pathing and common requires for tests
3
+
4
+ $LOAD_PATH << sprintf('%s/../lib', File.dirname(__FILE__))
5
+ require 'log4r/outputter/sequeloutputter'
6
+
7
+ require 'test/unit'
8
+
9
+ class Log4r::Logger
10
+
11
+ # no parameters, returns the first SequelOutputter object
12
+ def get_outputter
13
+ self.outputters.each do |op|
14
+ next unless op.is_a?(SequelOutputter)
15
+ return op
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,119 @@
1
+ $LOAD_PATH << sprintf('%s/../', File.dirname(__FILE__))
2
+
3
+ require 'helper'
4
+
5
+ class TestPostgresUnit < Test::Unit::TestCase
6
+
7
+ def setup
8
+ # TODO should this be a constant?
9
+ @good_config = File.expand_path(sprintf('%s/../config/log4r-postgres.yaml', File.dirname(__FILE__)))
10
+ @good_loggername = :test.to_s
11
+ @table = :logs
12
+
13
+ begin
14
+ require 'sqlite3'
15
+ rescue LoadError
16
+ omit('[sqlite3] not installed/configured') # TODO this really needs to omit the entire test
17
+ end
18
+ end
19
+
20
+ def teardown
21
+ # TODO decide what we're doing here
22
+ end
23
+
24
+ def test_happy_yaml
25
+ file = @good_config
26
+ Log4r::YamlConfigurator.load_yaml_file(file)
27
+
28
+ logger = nil
29
+
30
+ assert_nothing_raised do
31
+ logger = Log4r::Logger.get(@good_loggername)
32
+ end
33
+
34
+ assert_not_nil(logger)
35
+ end
36
+
37
+ def test_sad_yaml
38
+ good_yaml = YAML.load_file(@good_config)
39
+ sad_yamls = Hash.new
40
+
41
+ # delete vital keys here and create an array of sad yamls, but cheating a little to find our config
42
+ fail(sprintf('invalid input to generate sad yaml[%s]', good_yaml)) unless good_yaml.has_key?('log4r_config') and
43
+ good_yaml['log4r_config'].has_key?('outputters') and
44
+ good_yaml['log4r_config']['outputters'].last['type'].eql?('SequelOutputter')
45
+
46
+ {
47
+ :formatter.to_s => Hash.new.class,
48
+ :map.to_s => Hash.new.class,
49
+
50
+ :delimiter.to_s => String.new.class,
51
+ :engine.to_s => String.new.class,
52
+ :table.to_s => String.new.class,
53
+ }.each_pair do |key, _klass|
54
+ candidate = Marshal.load(Marshal.dump(good_yaml))
55
+ candidate['log4r_config']['outputters'].last.delete(key)
56
+ sad_yamls[key] = candidate
57
+ end
58
+
59
+ sad_yamls.each_pair do |name, config|
60
+
61
+ logger = nil
62
+
63
+ e = assert_raises Log4r::ConfigError do
64
+ Log4r::YamlConfigurator.load_yaml_string(config.to_yaml) # it's valid YAML, just missing required options
65
+ logger = Log4r::Logger.get(@good_loggername)
66
+ end
67
+
68
+ assert_match(Regexp.new(sprintf('[%s]', name)), e.message)
69
+ assert_nil(logger)
70
+
71
+ end
72
+
73
+ end
74
+
75
+ def test_happy_hash
76
+ logger = Log4r::Logger.new(@good_loggername)
77
+
78
+ table = 'logs-%Y/%m/%d-%H:%M'
79
+ fmt_table = Time.now.strftime(table)
80
+
81
+ hash = {
82
+ :type => 'SequelOutputter',
83
+ :name => 'sequel',
84
+ :formatter => Log4r::Formatter.new({
85
+ :type => 'PatternFormatter',
86
+ :date_pattern => '%Y/%m/%d %H:%M.%s',
87
+ :pattern => '%d!@#$%C!@#$%l!@#$%m',
88
+ }),
89
+
90
+ :engine => 'postgres',
91
+ :server => 'localhost',
92
+ :port => 5432,
93
+ :database => 'logs',
94
+ :table => table,
95
+ :username => 'postgres',
96
+ :password => 'postgres',
97
+
98
+ :delimiter => '!@#$',
99
+ :map => {
100
+ 0 => 'date',
101
+ 1 => 'level',
102
+ 2 => 'class',
103
+ 3 => 'message',
104
+ },
105
+ }
106
+
107
+ assert_nothing_raised do
108
+ outputter = Log4r::Outputter::SequelOutputter.new(
109
+ 'sequel',
110
+ hash,
111
+ )
112
+ logger.add(outputter)
113
+ end
114
+
115
+ assert_not_equal(hash[:file], logger.get_outputter.file)
116
+ assert_not_equal(hash[:table], logger.get_outputter.table)
117
+ end
118
+
119
+ end
@@ -0,0 +1,111 @@
1
+ $LOAD_PATH << sprintf('%s/../', File.dirname(__FILE__))
2
+
3
+ require 'helper'
4
+
5
+ class TestSqliteUnit < Test::Unit::TestCase
6
+
7
+ def setup
8
+ # TODO should this be a constant?
9
+ @good_config = File.expand_path(sprintf('%s/../config/log4r-sqlite.yaml', File.dirname(__FILE__)))
10
+ @good_loggername = :test.to_s
11
+ @table = :logs
12
+
13
+ begin
14
+ require 'sqlite3'
15
+ rescue LoadError
16
+ omit('[sqlite3] not installed/configured') # TODO this really needs to omit the entire test
17
+ end
18
+ end
19
+
20
+ def teardown
21
+ # TODO remove the database.. assume it's just '*.sqlite' in this path?
22
+ end
23
+
24
+ def test_happy_yaml
25
+ file = @good_config
26
+ Log4r::YamlConfigurator.load_yaml_file(file)
27
+
28
+ logger = nil
29
+
30
+ assert_nothing_raised do
31
+ logger = Log4r::Logger.get(@good_loggername)
32
+ end
33
+
34
+ assert_not_nil(logger)
35
+ end
36
+
37
+ def test_sad_yaml
38
+ good_yaml = YAML.load_file(@good_config)
39
+ sad_yamls = Hash.new
40
+
41
+ # delete vital keys here and create an array of sad yamls, but cheating a little to find our config
42
+ fail(sprintf('invalid input to generate sad yaml[%s]', good_yaml)) unless good_yaml.has_key?('log4r_config') and
43
+ good_yaml['log4r_config'].has_key?('outputters') and
44
+ good_yaml['log4r_config']['outputters'].last['type'].eql?('SequelOutputter')
45
+
46
+ {
47
+ :formatter.to_s => Hash.new.class,
48
+ :map.to_s => Hash.new.class,
49
+
50
+ :delimiter.to_s => String.new.class,
51
+ :engine.to_s => String.new.class,
52
+ :table.to_s => String.new.class,
53
+ }.each_pair do |key, _klass|
54
+ candidate = Marshal.load(Marshal.dump(good_yaml))
55
+ candidate['log4r_config']['outputters'].last.delete(key)
56
+ sad_yamls[key] = candidate
57
+ end
58
+
59
+ sad_yamls.each_pair do |name, config|
60
+
61
+ logger = nil
62
+
63
+ e = assert_raises Log4r::ConfigError do
64
+ Log4r::YamlConfigurator.load_yaml_string(config.to_yaml) # it's valid YAML, just missing required options
65
+ logger = Log4r::Logger.get(@good_loggername)
66
+ end
67
+
68
+ assert_match(Regexp.new(sprintf('[%s]', name)), e.message)
69
+ assert_nil(logger)
70
+
71
+ end
72
+
73
+ end
74
+
75
+ def test_happy_hash
76
+ logger = Log4r::Logger.new(@good_loggername)
77
+
78
+ hash = {
79
+ :type => 'SequelOutputter',
80
+ :name => 'sequel',
81
+ :formatter => Log4r::Formatter.new({
82
+ :type => 'PatternFormatter',
83
+ :date_pattern => '%Y/%m/%d %H:%M.%s',
84
+ :pattern => '%d!@#$%C!@#$%l!@#$%m',
85
+ }),
86
+
87
+ :engine => 'sqlite',
88
+ :file => 'log-%y-%m-%d-%H-%M.sqlite',
89
+ :table => 'logs_%y-%m-%d', # use the non-strftimed format here
90
+ :delimiter => '!@#$',
91
+ :map => {
92
+ 0 => 'date',
93
+ 1 => 'level',
94
+ 2 => 'class',
95
+ 3 => 'message',
96
+ },
97
+ }
98
+
99
+ assert_nothing_raised do
100
+ outputter = Log4r::Outputter::SequelOutputter.new(
101
+ 'sequel',
102
+ hash,
103
+ )
104
+ logger.add(outputter)
105
+ end
106
+
107
+ assert_not_equal(hash[:file], logger.get_outputter.file)
108
+ assert_not_equal(hash[:table], logger.get_outputter.table)
109
+ end
110
+
111
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log4r-sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conor Horan-Kates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-14 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: log4r
@@ -30,20 +30,6 @@ dependencies:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.1.9
33
- - !ruby/object:Gem::Dependency
34
- name: rack
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - '='
38
- - !ruby/object:Gem::Version
39
- version: 1.6.4
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - '='
45
- - !ruby/object:Gem::Version
46
- version: 1.6.4
47
33
  - !ruby/object:Gem::Dependency
48
34
  name: sequel
49
35
  requirement: !ruby/object:Gem::Requirement
@@ -124,6 +110,20 @@ dependencies:
124
110
  - - ~>
125
111
  - !ruby/object:Gem::Version
126
112
  version: '2.0'
113
+ - !ruby/object:Gem::Dependency
114
+ name: rack
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '='
118
+ - !ruby/object:Gem::Version
119
+ version: 1.6.4
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '='
125
+ - !ruby/object:Gem::Version
126
+ version: 1.6.4
127
127
  description: Log4r::Outputter that writes to a Sequel database
128
128
  email:
129
129
  - conor.code@gmail.com
@@ -138,15 +138,15 @@ files:
138
138
  - README.md
139
139
  - Rakefile
140
140
  - VERSION
141
- - example/log2postgres.rb
142
- - example/log2sqlite.rb
143
- - example/log4r-postgres.yaml
144
- - example/log4r-sqlite.yaml
145
141
  - lib/log4r/outputter/sequeloutputter.rb
142
+ - log4r-sequel.gemspec
143
+ - test/config/log4r-postgres.yaml
144
+ - test/config/log4r-sqlite.yaml
146
145
  - test/functional/test_postgres.rb
147
146
  - test/functional/test_sqlite.rb
148
- - test/log4r-postgres_test.yaml
149
- - test/log4r-sqlite_test.yaml
147
+ - test/helper.rb
148
+ - test/unit/test_postgres.rb
149
+ - test/unit/test_sqlite.rb
150
150
  homepage: http://github.com/chorankates/log4r-sequel
151
151
  licenses:
152
152
  - MIT
@@ -1,18 +0,0 @@
1
- $LOAD_PATH << sprintf('%s/../lib', File.dirname(__FILE__))
2
- require 'log4r/outputter/sequeloutputter'
3
-
4
- require 'pg'
5
-
6
- file = sprintf('%s/log4r-postgres.yaml', File.dirname(__FILE__))
7
- Log4r::YamlConfigurator.load_yaml_file(file)
8
-
9
- logger = Log4r::Logger.get('bar')
10
-
11
- [logger].each do |l|
12
- ## log some garbage
13
- l.debug('this is a debug message')
14
- l.info('this is an info message')
15
- l.warn('this is a warning')
16
- l.error('this is an error')
17
- l.fatal('this is a fatal')
18
- end
@@ -1,19 +0,0 @@
1
- $LOAD_PATH << sprintf('%s/../lib', File.dirname(__FILE__))
2
- require 'log4r/outputter/sequeloutputter'
3
-
4
- require 'sqlite3'
5
-
6
- ## instantiate a logger following the log4r pattern
7
- file = sprintf('%s/log4r-sqlite.yaml', File.dirname(__FILE__))
8
- Log4r::YamlConfigurator.load_yaml_file(file)
9
-
10
- logger = Log4r::Logger.get('foo')
11
-
12
- [logger].each do |l|
13
- ## log some garbage
14
- l.debug('this is a debug message')
15
- l.info('this is an info message')
16
- l.warn('this is a warning')
17
- l.error('this is an error')
18
- l.fatal('this is a fatal')
19
- end
@@ -1,53 +0,0 @@
1
- ---
2
- log4r_config:
3
- loggers:
4
- - name: 'bar'
5
- outputters:
6
- - sequel
7
- - stdout
8
- outputters:
9
- # not needed, but feedback is useful
10
- - type: StdoutOutputter
11
- name: stdout
12
- formatter:
13
- type: PatternFormatter
14
- date_pattern: '%Y/%m/%d %H:%M.%s'
15
- pattern: '%d | %C | %l | %m'
16
-
17
- - type: SequelOutputter
18
- # traditional Log4r settings
19
- name: sequel
20
- level: DEBUG
21
- formatter:
22
- type: PatternFormatter
23
- date_pattern: '%Y/%m/%d %H:%M.%s'
24
- pattern: '%d!@#$%l!@#$%C!@#$%c!@#$%h!@#$%p!@#$%m' # kitchen sink
25
- # log4r-sequel settings
26
- engine: postgres
27
- server: localhost
28
- port: 5432
29
- database: logs
30
- table: logs-%Y/%m/%d-%H:%M.%s
31
- username: postgres
32
- password: postgres
33
- delimiter: '!@#$' # this is used to determine columns needed based on log4 configuration
34
- map:
35
- 0: 'date'
36
- 1: 'level'
37
- 2: 'class'
38
- 3: 'relative_class'
39
- 4: 'thread'
40
- 5: 'pid'
41
- 6: 'message'
42
-
43
- # truncated map from http://log4r.rubyforge.org/rdoc/Log4r/PatternFormatter.html
44
- # %c - event short name
45
- # %C - event fullname
46
- # %d - date
47
- # %g - Global Diagnostic Context (GDC)
48
- # %t - trace
49
- # %m - message
50
- # %h - thread name
51
- # %p - process ID aka PID
52
- # %M - formatted message
53
- # %l - Level in string form
@@ -1,46 +0,0 @@
1
- ---
2
- log4r_config:
3
- loggers:
4
- - name: 'foo'
5
- outputters:
6
- - sequel
7
- - stdout
8
- outputters:
9
- # not needed, but feedback is useful
10
- - type: StdoutOutputter
11
- name: stdout
12
- formatter:
13
- type: PatternFormatter
14
- date_pattern: '%Y/%m/%d %H:%M.%s'
15
- pattern: '%d | %C | %l | %m'
16
-
17
- - type: SequelOutputter
18
- # traditional Log4r settings
19
- name: sequel
20
- level: DEBUG
21
- formatter:
22
- type: PatternFormatter
23
- date_pattern: '%Y/%m/%d %H:%M.%s'
24
- pattern: '%d!@#$%C!@#$%l!@#$%m' # date|level|event/class fullname|message
25
- # log4r-sequel settings
26
- engine: sqlite
27
- file: log-%Y-%m-%d-%H-%M-%s.sqlite
28
- table: logs
29
- delimiter: '!@#$' # this is used to determine columns needed based on log4 configuration
30
- map:
31
- 0: 'date'
32
- 1: 'level'
33
- 2: 'class'
34
- 3: 'message'
35
-
36
- # truncated map from http://log4r.rubyforge.org/rdoc/Log4r/PatternFormatter.html
37
- # %c - event short name
38
- # %C - event fullname
39
- # %d - date
40
- # %g - Global Diagnostic Context (GDC)
41
- # %t - trace
42
- # %m - message
43
- # %h - thread name
44
- # %p - process ID aka PID
45
- # %M - formatted message
46
- # %l - Level in string form