logutils 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 49dac3b0882a6385641bf48274d8bbaa3f41bedf
4
+ data.tar.gz: 2092e1ec751febf3ba8db807dbb41dc9834d0d14
5
+ SHA512:
6
+ metadata.gz: 592d2d7225ff076cea8e38b5286dbcd2d89666689a1cf1ccf98872fe9727aa12732cab9181dbf6c41be60d7ea109bda3f14303bc05ada7789698e66e811f70d1
7
+ data.tar.gz: 8ce12bdfd53d2ae653d5dd0b183d634f3604d65bba6b5cd319b3c686171e7fb8cf7ec1299c3e723e0fbe0bbdca1fa33a8730c01a9856550d16a7acd5c0028d85
@@ -3,16 +3,7 @@ Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
5
  lib/logutils.rb
6
- lib/logutils/db.rb
7
- lib/logutils/db/deleter.rb
8
- lib/logutils/db/models.rb
9
- lib/logutils/db/schema.rb
10
6
  lib/logutils/logger.rb
11
- lib/logutils/server.rb
12
- lib/logutils/server/public/style.css
13
- lib/logutils/server/views/_version.erb
14
- lib/logutils/server/views/index.erb
15
- lib/logutils/server/views/layout.erb
16
7
  lib/logutils/version.rb
17
8
  test/helper.rb
18
9
  test/test_logger.rb
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # logutils - Another Logger in Ruby
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/geraldb/logutils.png?branch=master)](http://travis-ci.org/geraldb/logutils)
4
3
 
5
- * home :: [github.com/geraldb/logutils](https://github.com/geraldb/logutils)
6
- * bugs :: [github.com/geraldb/logutils/issues](https://github.com/geraldb/logutils)
4
+ * home :: [github.com/rubylibs/logutils](https://github.com/rubylibs/logutils)
5
+ * bugs :: [github.com/rubylibs/logutils/issues](https://github.com/rubylibs/logutils)
7
6
  * gem :: [rubygems.org/gems/logutils](https://rubygems.org/gems/logutils)
8
7
  * rdoc :: [rubydoc.info/gems/logutils](http://rubydoc.info/gems/logutils)
9
8
 
@@ -73,62 +72,19 @@ Example:
73
72
  end
74
73
 
75
74
 
76
- ### Log to the database using `LogDb`
75
+ ### Addons / Plugins / Extensions
77
76
 
78
- NB: To use the `LogDb` machinery require the module, that is, issue:
77
+ [logutils-activerecord](https://github.com/rubylibs/logutils-activerecord) - add LogDb, Log Models, etc.
79
78
 
80
- require 'logutils/db'
81
-
82
- To create the database tables use:
83
-
84
- LogDb.create
85
-
86
- To start logging to the database (established connection required) use:
87
-
88
- LogDb.setup
89
-
90
- To clean out all log records from the database use:
91
-
92
- LogDb.delete!
93
-
94
-
95
- ### All together now
96
-
97
- require 'logutils'
98
-
99
- include LogUtils # lets you use Logger instead of LogUtils::Logger
100
-
101
- logger = Logger[ 'Test' ]
102
- logger.info 'hello LogUtils'
103
-
104
-
105
- require 'logutils/db' # nb: will also require 'active_record'
106
-
107
- LOG_DB_CONFIG = {
108
- :adapter => 'sqlite3',
109
- :database => './log.db'
110
- }
111
-
112
- pp LOG_DB_CONFIG
113
- ActiveRecord::Base.establish_connection( LOG_DB_CONFIG )
114
-
115
- LogDb.create
116
- LogDb.setup
117
-
118
- logger.info 'hola LogUtils'
119
- logger.warn 'servus LogUtils'
120
-
121
-
122
- That's it.
123
79
 
124
80
 
125
81
  ## Real World Usage
126
82
 
127
- [world.db.ruby](https://github.com/geraldb/world.db.ruby) - `world.db` Command Line Tool
83
+ [world.db.ruby](https://github.com/worlddb/world.db.ruby) - `world.db` Command Line Tool
128
84
 
129
- [sport.db.ruby](https://github.com/geraldb/sport.db.ruby) - `sport.db` Command Line Tool
85
+ [sport.db.ruby](https://github.com/sportdb/sport.db.ruby) - `sport.db` Command Line Tool
130
86
 
131
- [Sportbook](http://geraldb.github.com/sportbook) - A free, open source sports betting pool
87
+ [Sportbook](https://github.com/openbookie) - A free, open source sports betting pool
132
88
  in Ruby on Rails (version 3.2 and up).
133
89
 
134
90
 
@@ -149,4 +105,4 @@ in Ruby on Rails (version 3.2 and up).
149
105
  ## License
150
106
 
151
107
  The `logutils` scripts are dedicated to the public domain.
152
- Use it as you please with no restrictions whatsoever.
108
+ Use it as you please with no restrictions whatsoever.
data/Rakefile CHANGED
@@ -3,26 +3,26 @@ require './lib/logutils/version.rb'
3
3
 
4
4
 
5
5
  Hoe.spec 'logutils' do
6
-
6
+
7
7
  self.version = LogKernel::VERSION
8
-
8
+
9
9
  self.summary = 'Another Logger'
10
10
  self.description = summary
11
11
 
12
- self.urls = ['https://github.com/geraldb/logutils']
13
-
12
+ self.urls = ['https://github.com/rubylibs/logutils']
13
+
14
14
  self.author = 'Gerald Bauer'
15
15
  self.email = 'opensport@googlegroups.com'
16
-
16
+
17
17
  # switch extension to .markdown for gihub formatting
18
18
  # -- NB: auto-changed when included in manifest
19
19
  self.readme_file = 'README.md'
20
20
  self.history_file = 'History.md'
21
-
21
+
22
22
  self.licenses = ['Public Domain']
23
23
 
24
24
  self.spec_extras = {
25
- :required_ruby_version => '>= 1.9.2'
25
+ required_ruby_version: '>= 1.9.2'
26
26
  }
27
-
27
+
28
28
  end
@@ -15,17 +15,12 @@ require 'fileutils'
15
15
 
16
16
  # our own code
17
17
 
18
- require 'logutils/version'
19
-
18
+ require 'logutils/version' # NOTE: let version always go first
20
19
  require 'logutils/logger'
21
20
 
22
21
 
23
22
  module LogKernel
24
23
 
25
- def self.root
26
- "#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
27
- end
28
-
29
24
  =begin # not needed for now; keep it for later
30
25
  def self.config_path
31
26
  "#{root}/config"
@@ -81,3 +76,7 @@ module LogUtils
81
76
  end
82
77
 
83
78
  end # module LogUtils
79
+
80
+
81
+ ## say hello
82
+ puts LogKernel.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
 
2
3
  module LogKernel
3
4
 
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
 
2
3
  module LogUtils
3
4
  # NB: keep LogUtils namespace clean
@@ -5,6 +6,25 @@ module LogUtils
5
6
  # move all non public code/apis to LogKernel (including VERSION)
6
7
  end
7
8
 
9
+
8
10
  module LogKernel
9
- VERSION = '0.6.0'
10
- end
11
+
12
+ MAJOR = 0 ## todo: namespace inside version or something - why? why not??
13
+ MINOR = 6
14
+ PATCH = 1
15
+ VERSION = [MAJOR,MINOR,PATCH].join('.')
16
+
17
+ def self.version
18
+ VERSION
19
+ end
20
+
21
+ def self.banner
22
+ "logutils/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
23
+ end
24
+
25
+ def self.root
26
+ "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
27
+ end
28
+
29
+
30
+ end # module LogKernel
@@ -4,11 +4,8 @@
4
4
 
5
5
  ## minitest setup
6
6
 
7
- # require 'minitest/unit'
8
7
  require 'minitest/autorun'
9
8
 
10
- # include MiniTest::Unit # lets us use TestCase instead of MiniTest::Unit::TestCase
11
-
12
9
 
13
10
  ## our own code
14
11
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  require 'helper'
8
8
 
9
- class TestLogger < MiniTest::Unit::TestCase
9
+ class TestLogger < MiniTest::Test
10
10
  include LogUtils # lets us use Logger instead of LogUtils::Logger
11
11
 
12
12
  ####
metadata CHANGED
@@ -1,90 +1,87 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
5
- prerelease:
4
+ version: 0.6.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gerald Bauer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-01 00:00:00.000000000 Z
11
+ date: 2014-12-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rdoc
16
- requirement: &84286280 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '3.10'
19
+ version: '4.0'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *84286280
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: hoe
27
- requirement: &84286030 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ~>
31
+ - - "~>"
31
32
  - !ruby/object:Gem::Version
32
- version: '3.3'
33
+ version: '3.13'
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *84286030
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.13'
36
41
  description: Another Logger
37
42
  email: opensport@googlegroups.com
38
43
  executables: []
39
44
  extensions: []
40
45
  extra_rdoc_files:
46
+ - History.md
41
47
  - Manifest.txt
48
+ - README.md
42
49
  files:
50
+ - ".gemtest"
43
51
  - History.md
44
52
  - Manifest.txt
45
53
  - README.md
46
54
  - Rakefile
47
55
  - lib/logutils.rb
48
- - lib/logutils/db.rb
49
- - lib/logutils/db/deleter.rb
50
- - lib/logutils/db/models.rb
51
- - lib/logutils/db/schema.rb
52
56
  - lib/logutils/logger.rb
53
- - lib/logutils/server.rb
54
- - lib/logutils/server/public/style.css
55
- - lib/logutils/server/views/_version.erb
56
- - lib/logutils/server/views/index.erb
57
- - lib/logutils/server/views/layout.erb
58
57
  - lib/logutils/version.rb
59
58
  - test/helper.rb
60
59
  - test/test_logger.rb
61
- - .gemtest
62
- homepage: https://github.com/geraldb/logutils
60
+ homepage: https://github.com/rubylibs/logutils
63
61
  licenses:
64
62
  - Public Domain
63
+ metadata: {}
65
64
  post_install_message:
66
65
  rdoc_options:
67
- - --main
66
+ - "--main"
68
67
  - README.md
69
68
  require_paths:
70
69
  - lib
71
70
  required_ruby_version: !ruby/object:Gem::Requirement
72
- none: false
73
71
  requirements:
74
- - - ! '>='
72
+ - - ">="
75
73
  - !ruby/object:Gem::Version
76
74
  version: 1.9.2
77
75
  required_rubygems_version: !ruby/object:Gem::Requirement
78
- none: false
79
76
  requirements:
80
- - - ! '>='
77
+ - - ">="
81
78
  - !ruby/object:Gem::Version
82
79
  version: '0'
83
80
  requirements: []
84
- rubyforge_project: logutils
85
- rubygems_version: 1.8.17
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.2
86
83
  signing_key:
87
- specification_version: 3
84
+ specification_version: 4
88
85
  summary: Another Logger
89
86
  test_files:
90
87
  - test/test_logger.rb
@@ -1,77 +0,0 @@
1
-
2
- #########################################
3
- # NB: only load on demand
4
- # we do NOT want to pull in activerecord gem/dep for simple scripts
5
-
6
- # rubygems / 3rd party libs
7
-
8
- require 'active_record' ## todo: add sqlite3? etc.
9
-
10
- # our own code
11
-
12
- require 'logutils/db/models'
13
- require 'logutils/db/schema'
14
- require 'logutils/db/deleter'
15
-
16
-
17
- module LogDb
18
-
19
- include LogKernel # NB: will also include VERSION constant e.g. LogDB::VERSION == LogUtils::Kernel::VERSION
20
-
21
- def self.banner
22
- "logdb #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
23
- end
24
-
25
- end
26
-
27
- ###########################################3
28
- ## fix: remove old alias for LogDb
29
-
30
- LogDB = LogDb
31
-
32
-
33
-
34
- ###########################
35
-
36
- module LogDb
37
-
38
- class DbHandler
39
- include LogDb::Models
40
-
41
- def write( ev )
42
- if( ev.fatal? || ev.error? || ev.warn? || ev.unknown? )
43
- ## create log entry in db table (logs)
44
- Log.create!( level: ev.level, msg: ev.msg, pid: ev.pid, tid: ev.tid, ts: ev.ts )
45
- end
46
- end # method write
47
- end # class DbHandler
48
-
49
- def self.create
50
- CreateDb.up
51
- end
52
-
53
- # delete ALL records (use with care!)
54
- def self.delete!
55
- puts '*** deleting log table records/data...'
56
- Deleter.new.run
57
- end # method delete!
58
-
59
-
60
- def self.stats
61
- # to be done
62
- end
63
-
64
-
65
- STDDBHANDLER = DbHandler.new # default/standard db handler
66
-
67
- def self.setup # check: use different name? e.g. configure or connect ?? why or why not?
68
- # turn on logging to db - assumes active connection
69
- STDLOGGER.handlers << STDDBHANDLER
70
- end
71
-
72
-
73
- end # module LogDb
74
-
75
-
76
- # say hello
77
- puts LogDb.banner
@@ -1,15 +0,0 @@
1
-
2
- module LogDb
3
-
4
- class Deleter
5
- include LogDb::Models
6
-
7
- def run
8
- # for now delete all tables
9
-
10
- Log.delete_all
11
- end
12
-
13
- end # class Deleter
14
-
15
- end # module LogDb
@@ -1,13 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module LogDb
4
- module Models
5
-
6
-
7
- class Log < ActiveRecord::Base
8
-
9
- end # class Log
10
-
11
-
12
- end # module Models
13
- end # module LogDb
@@ -1,44 +0,0 @@
1
-
2
- module LogDb
3
-
4
- class CreateDb ## fix/todo: change to ActiveRecord::Migration why? why not?
5
-
6
- def self.up
7
-
8
- ActiveRecord::Schema.define do
9
-
10
- create_table :logs do |t|
11
- t.string :msg, :null => false
12
- t.string :level, :null => false # e.g. fatal, error, warn, info, debug
13
- t.string :app
14
- t.string :tag # e.g. class name w/ namespace e.g. SportDB.Reader etc. # NB: change to name?
15
- t.integer :pid
16
- t.integer :tid
17
- t.string :ts # timestamp - change to datetime?
18
- # add filename, line, method ??
19
- t.timestamps
20
- end
21
-
22
- #####################################
23
- # todo: add more fields ?? e.g.
24
- #
25
- # %m : The message to be logged
26
- # %d : The ISO8601 Timestamp
27
- # %L : The log level, e.g INFO, WARN
28
- # %l : The log level (short), e.g. I, W
29
- # %p : The PID of the process from where the log event occured
30
- # %t : The Thread ID from where the log event occured
31
- # %h : The hostname of the machine from where the log event occured
32
- # %f : The filename from where the log event occured
33
- # %n : The line number of the file from where the log event occured
34
- # %F : The filename with path from where the log event occured
35
- # %M : The method where the log event occured
36
-
37
-
38
- end # block Schema.define
39
-
40
- end # method up
41
-
42
- end # class CreateDb
43
-
44
- end # module LogDb
@@ -1,57 +0,0 @@
1
- ######
2
- # NB: use rackup to startup Sinatra service (see config.ru)
3
- #
4
- # e.g. config.ru:
5
- # require './boot'
6
- # run LogDb::Server
7
-
8
-
9
- # 3rd party libs/gems
10
-
11
- require 'sinatra/base'
12
-
13
- # our own code
14
-
15
- require 'logutils'
16
- require 'logutils/db'
17
-
18
-
19
-
20
- module LogDb
21
-
22
- class Server < Sinatra::Base
23
-
24
- def self.banner
25
- "logdb-server #{LogKernel::VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] on Sinatra/#{Sinatra::VERSION} (#{ENV['RACK_ENV']})"
26
- end
27
-
28
- PUBLIC_FOLDER = "#{LogKernel.root}/lib/logutils/server/public"
29
- VIEWS_FOLDER = "#{LogKernel.root}/lib/logutils/server/views"
30
-
31
- puts "setting public folder to: #{PUBLIC_FOLDER}"
32
- puts "setting views folder to: #{VIEWS_FOLDER}"
33
-
34
- set :public_folder, PUBLIC_FOLDER # set up the static dir (with images/js/css inside)
35
- set :views, VIEWS_FOLDER # set up the views dir
36
-
37
- set :static, true # set up static file routing
38
-
39
-
40
- #####################
41
- # Models
42
-
43
- include LogDb::Models
44
-
45
- ##############################################
46
- # Controllers / Routing / Request Handlers
47
-
48
- get '/' do
49
- erb :index
50
- end
51
-
52
- end # class Server
53
- end # module LogDb
54
-
55
-
56
- # say hello
57
- puts LogDb::Server.banner
@@ -1,49 +0,0 @@
1
-
2
-
3
- body { font-family: arial,verdana,helvetica; }
4
-
5
- .log-id,
6
- .log-pid,
7
- .log-created-at { font-size: 60%; color: grey; }
8
-
9
- .log-id { text-align: right; }
10
-
11
- .log-level,
12
- .log-msg { font-size: 80%; }
13
-
14
- .log-created-at,
15
- .log-pid,
16
- .log-msg { white-space: nowrap; }
17
-
18
- .log-level { font-weight: bold; }
19
-
20
- .log-msg.warn { font-weight: bold; }
21
-
22
-
23
- /****
24
- * links
25
- */
26
-
27
- a {
28
- color: black;
29
- text-decoration: none; }
30
- a:hover {
31
- color: black;
32
- background-color: aqua;
33
- text-decoration: underline; }
34
- a:visited {
35
- color: black; }
36
-
37
-
38
-
39
- /**********
40
- * version / powered by
41
- */
42
-
43
- .version {
44
- text-align: center;
45
- margin-top: 10px;
46
- color: grey; }
47
- .version a, .version span {
48
- font-size: 12px;
49
- color: grey; }
@@ -1,5 +0,0 @@
1
- <div class='version'>
2
- <a href="https://github.com/geraldb/logutils">log.db/<%= LogKernel::VERSION %></a> -
3
- <span>Ruby/<%= "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}/#{RUBY_PLATFORM})" %> on</span>
4
- <span>Sinatra/<%= Sinatra::VERSION %> (<%= ENV['RACK_ENV'] %>)</span>
5
- </div>
@@ -1,26 +0,0 @@
1
-
2
- <h3><%= Log.count %> Logs</h3>
3
-
4
- <!-- todo:
5
- add filter for FATAL,ERROR,WARN,etc.
6
- add log count per kind? (e.g. 20 errors, 5 warns, etc.)
7
-
8
- css: use colors
9
-
10
- - error/fatal - red?
11
- - warn - // bold or organge?
12
- - info - normal
13
- - debug - light grey??
14
- -->
15
-
16
- <table>
17
- <% Log.all.each do |log| %>
18
- <tr>
19
- <td class='log-id'><%= log.id %>.</td>
20
- <td class='log-level <%= log.level %>'>[<%= log.level %>]</td>
21
- <td class='log-msg <%= log.level %>'><%= log.msg %></td>
22
- <td class='log-pid'><%= "#{log.pid}.#{log.tid}" %></td>
23
- <td class='log-created-at' <%= log.level %>'><%= log.created_at %></td>
24
- </tr>
25
- <% end %>
26
- </table>
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset='UTF-8'>
5
- <title>Logs</title>
6
- <link href="<%= url('/style.css') %>" rel='stylesheet'>
7
- </head>
8
- <body>
9
-
10
- <%= yield %>
11
-
12
- <%= erb :'_version' %>
13
-
14
- </body>
15
- </html>