flogger 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,5 +4,6 @@
4
4
  *.gem
5
5
  .bundle
6
6
  Gemfile.lock
7
+
7
8
  pkg/*
8
9
  logs/*
@@ -1,2 +1,6 @@
1
+ *0.1.1) August 21, 2011
2
+ * added error handling when accessing log files
3
+ * changed default log directory from 'log' to 'logs'
4
+
1
5
  *0.1.0* August 20, 2011
2
6
  * initial release
@@ -1,34 +1,45 @@
1
- = FLOGGER
1
+ = FLogger
2
2
 
3
- FLogger is a real simple Ruby-based logging system that outputs to one or many log files. It was created as a learning project for myself, but also something that I could continue to develop and use with future applications.
3
+ FLogger is a really simple Ruby-based logging system that outputs to one or many log files. It was created as a learning project for myself, but also something that I could continue to develop and use with future applications.
4
4
 
5
- == Install
5
+ == Installing
6
6
 
7
- FLogger can currently be installed as a gem by downloading the source from github and executing 'rake install' within its source directory.
7
+ FLogger can be downloaded from source or installed as a gem with the command:
8
8
 
9
- == Usage
9
+ gem install flogger
10
10
 
11
- Some examples of using FLogger within a simple Ruby application are shown in the examples directory and below. Currently, FLogger can output to various predefined logs (and perhaps more in the future). I suggest checking out the docs directory for a list of methods.
11
+ == Usage and Default
12
12
 
13
- == Example
13
+ Some examples of using FLogger within a simple Ruby application are shown in the examples directory. Currently, FLogger can output to various predefined logs (and perhaps more in the future). By default, all logs are placed in the 'logs' directory within your current working directory. Currently, these are the log types available and their default location:
14
14
 
15
- Here is a simple example of how to use FLogger, but a more detailed example is shown in the examples directory:
15
+ * *Debug:* Default location is logs/debug.txt
16
+ * *Error:* Default location is logs/error.txt
17
+ * *Warning:* Default location is logs/warning.txt
18
+ * *Notice:* Default location is logs/notice.txt
19
+ * *Default:* Default location is logs/log.txt
20
+
21
+ == Examples
22
+
23
+ More detailed examples of how to use FLogger can be found in the examples directory. Still, here is a simple example of how to use FLogger to output messages to default log files:
16
24
 
17
25
  require 'flogger'
18
26
 
19
27
  log = FLogger::Log.new
20
28
 
21
- log.debug 'This message will be stored in the debug log.'
22
- log.error 'This message will be stored in the error log.'
23
- log.puts 'This message will be stored in the default log.'
29
+ log.debug 'This message will be stored in logs/debug.txt'
30
+ log.error 'This message will be stored in logs/error.txt'
31
+ log.puts 'This message will be stored in logs/log.txt'
24
32
 
25
- == Configure
26
-
27
- Here is an example that shows how easy it is to specify the location for FLogger to output log files. A more detailed example is shown in the examples directory:
33
+ This example shows how easy it is to specify a location for FLogger to output log files:
28
34
 
29
35
  log = FLogger::Log.new
30
36
 
31
37
  log.configure do |c|
32
- c.debug = 'logs/debug_log.txt'
33
- c.error = 'logs/error_log.txt'
38
+ c.debug = 'new/logs/debug_log.txt'
39
+ c.error = 'new/logs/error_log.txt'
40
+ c.default = 'new/logs/default_log.txt'
34
41
  end
42
+
43
+ log.debug 'This message will be stored in new/logs/debug_log.txt'
44
+ log.error 'This message will be stored in new/logs/error_log.txt'
45
+ log.puts 'This message will be stored in new/logs/default_log.txt'
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Andre Burdette"]
9
9
  s.email = ["andre@nerdstack.com"]
10
10
  s.homepage = "https://github.com/aburdette/flogger"
11
- s.summary = %q{Outputs log messages to one or many log files}
12
- s.description = %q{A simple Ruby-base file logging system}
11
+ s.summary = %q{A simple Ruby-based message logging system.}
12
+ s.description = %q{A simple Ruby-based message logging system that outputs to one or many log files.}
13
13
 
14
14
  s.rubyforge_project = "flogger"
15
15
 
@@ -7,11 +7,11 @@ module FLogger
7
7
 
8
8
  def initialize
9
9
  @logs = OpenStruct.new(
10
- :debug => 'log/debug.txt',
11
- :error => 'log/error.txt',
12
- :warning => 'log/warning.txt',
13
- :notice => 'log/notice.txt',
14
- :default => 'log/logs.txt'
10
+ :debug => 'logs/debug.txt',
11
+ :error => 'logs/error.txt',
12
+ :warning => 'logs/warning.txt',
13
+ :notice => 'logs/notice.txt',
14
+ :default => 'logs/log.txt'
15
15
  )
16
16
  end
17
17
 
@@ -19,22 +19,27 @@ module FLogger
19
19
  block.call(@logs)
20
20
  end
21
21
 
22
+ # output to debug log, default: logs/debug.txt
22
23
  def debug(msg)
23
24
  output open(@logs.debug), msg
24
25
  end
25
26
 
27
+ # output to error log, default: logs/error.txt
26
28
  def error(msg)
27
29
  output open(@logs.error), msg
28
30
  end
29
31
 
32
+ # output to warning log, default: logs/warning.txt
30
33
  def warning(msg)
31
34
  output open(@logs.warning), msg
32
35
  end
33
36
 
37
+ # output to notice log, default: logs/notice.txt
34
38
  def notice(msg)
35
39
  output open(@logs.notice), msg
36
40
  end
37
41
 
42
+ # output to log, default: logs/log.txt
38
43
  def puts(msg)
39
44
  output open(@logs.default), msg
40
45
  end
@@ -43,15 +48,25 @@ module FLogger
43
48
 
44
49
  # access the needed log file
45
50
  def open(log_file)
46
- log_path = File.dirname(log_file)
47
- FileUtils.mkdir_p(log_path) unless File.exists? log_file
48
- File.open(log_file, 'a')
51
+ begin
52
+ log_path = File.dirname(log_file)
53
+ FileUtils.mkdir_p(log_path) unless File.exists? log_file
54
+ File.open(log_file, 'a')
55
+ rescue Exception => e
56
+ print e.message << "\r\n"
57
+ end
49
58
  end
50
59
 
51
- # output message into log file
60
+ # output message to log file
52
61
  def output(log, msg)
53
- log.puts "[#{Time.now.asctime}] #{msg}"
54
- log.close
62
+ if log
63
+ begin
64
+ log.puts "[#{Time.now.asctime}] #{msg}"
65
+ log.close
66
+ rescue Exception => e
67
+ print e.message << "\r\n"
68
+ end
69
+ end
55
70
  end
56
71
  end
57
72
  end
@@ -1,3 +1,3 @@
1
1
  module FLogger
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,8 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2011-08-20 00:00:00.000000000Z
13
13
  dependencies: []
14
- description: A simple Ruby-base file logging system
14
+ description: A simple Ruby-based message logging system that outputs to one or many
15
+ log files.
15
16
  email:
16
17
  - andre@nerdstack.com
17
18
  executables: []
@@ -23,16 +24,6 @@ files:
23
24
  - Gemfile
24
25
  - README.rdoc
25
26
  - Rakefile
26
- - doc/CHANGELOG_rdoc.html
27
- - doc/FLogger.html
28
- - doc/FLogger/Log.html
29
- - doc/README_rdoc.html
30
- - doc/created.rid
31
- - doc/index.html
32
- - doc/lib/flogger/log_rb.html
33
- - doc/lib/flogger/version_rb.html
34
- - doc/lib/flogger_rb.html
35
- - doc/rdoc.css
36
27
  - examples/custom_output.rb
37
28
  - examples/default_output.rb
38
29
  - flogger.gemspec
@@ -62,5 +53,5 @@ rubyforge_project: flogger
62
53
  rubygems_version: 1.8.8
63
54
  signing_key:
64
55
  specification_version: 3
65
- summary: Outputs log messages to one or many log files
56
+ summary: A simple Ruby-based message logging system.
66
57
  test_files: []
@@ -1,97 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
-
5
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
- <head>
7
- <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
8
-
9
- <title>File: CHANGELOG.rdoc [RDoc Documentation]</title>
10
-
11
- <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
12
-
13
- <script src="./js/jquery.js" type="text/javascript"
14
- charset="utf-8"></script>
15
- <script src="./js/thickbox-compressed.js" type="text/javascript"
16
- charset="utf-8"></script>
17
- <script src="./js/quicksearch.js" type="text/javascript"
18
- charset="utf-8"></script>
19
- <script src="./js/darkfish.js" type="text/javascript"
20
- charset="utf-8"></script>
21
- </head>
22
-
23
- <body class="file">
24
- <div id="metadata">
25
- <div id="home-metadata">
26
- <div id="home-section" class="section">
27
- <h3 class="section-header">
28
- <a href="./index.html">Home</a>
29
- <a href="./index.html#classes">Classes</a>
30
- <a href="./index.html#methods">Methods</a>
31
- </h3>
32
- </div>
33
- </div>
34
-
35
- <div id="project-metadata">
36
-
37
-
38
- <div id="fileindex-section" class="section project-section">
39
- <h3 class="section-header">Files</h3>
40
- <ul>
41
-
42
- <li class="file"><a href="./CHANGELOG_rdoc.html">CHANGELOG.rdoc</a></li>
43
-
44
- <li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
45
-
46
- </ul>
47
- </div>
48
-
49
-
50
- <div id="classindex-section" class="section project-section">
51
- <h3 class="section-header">Class Index
52
- <span class="search-toggle"><img src="./images/find.png"
53
- height="16" width="16" alt="[+]"
54
- title="show/hide quicksearch" /></span></h3>
55
- <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
56
- <fieldset>
57
- <legend>Quicksearch</legend>
58
- <input type="text" name="quicksearch" value=""
59
- class="quicksearch-field" />
60
- </fieldset>
61
- </form>
62
-
63
- <ul class="link-list">
64
-
65
- <li><a href="./FLogger.html">FLogger</a></li>
66
-
67
- <li><a href="./FLogger/Log.html">FLogger::Log</a></li>
68
-
69
- </ul>
70
- <div id="no-class-search-results" style="display: none;">No matching classes.</div>
71
- </div>
72
-
73
-
74
- </div>
75
- </div>
76
-
77
- <div id="documentation">
78
- <p>
79
- <b>0.1.0</b> August 20, 2011
80
- </p>
81
- <ul>
82
- <li><p>
83
- initial release
84
- </p>
85
- </li>
86
- </ul>
87
-
88
- </div>
89
-
90
- <div id="validator-badges">
91
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
92
- <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
93
- Rdoc Generator</a> 1.1.6</small>.</p>
94
- </div>
95
- </body>
96
- </html>
97
-
@@ -1,168 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <head>
6
- <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
-
8
- <title>Module: FLogger</title>
9
-
10
- <link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
11
-
12
- <script src="./js/jquery.js" type="text/javascript"
13
- charset="utf-8"></script>
14
- <script src="./js/thickbox-compressed.js" type="text/javascript"
15
- charset="utf-8"></script>
16
- <script src="./js/quicksearch.js" type="text/javascript"
17
- charset="utf-8"></script>
18
- <script src="./js/darkfish.js" type="text/javascript"
19
- charset="utf-8"></script>
20
-
21
- </head>
22
- <body class="module">
23
-
24
- <div id="metadata">
25
- <div id="home-metadata">
26
- <div id="home-section" class="section">
27
- <h3 class="section-header">
28
- <a href="./index.html">Home</a>
29
- <a href="./index.html#classes">Classes</a>
30
- <a href="./index.html#methods">Methods</a>
31
- </h3>
32
- </div>
33
- </div>
34
-
35
- <div id="file-metadata">
36
- <div id="file-list-section" class="section">
37
- <h3 class="section-header">In Files</h3>
38
- <div class="section-body">
39
- <ul>
40
-
41
- <li><a href="./lib/flogger/version_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
- class="thickbox" title="lib/flogger/version.rb">lib/flogger/version.rb</a></li>
43
-
44
- <li><a href="./lib/flogger/log_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
45
- class="thickbox" title="lib/flogger/log.rb">lib/flogger/log.rb</a></li>
46
-
47
- <li><a href="./lib/flogger_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
48
- class="thickbox" title="lib/flogger.rb">lib/flogger.rb</a></li>
49
-
50
- </ul>
51
- </div>
52
- </div>
53
-
54
-
55
- </div>
56
-
57
- <div id="class-metadata">
58
-
59
- <!-- Parent Class -->
60
-
61
-
62
- <!-- Namespace Contents -->
63
-
64
- <div id="namespace-list-section" class="section">
65
- <h3 class="section-header">Namespace</h3>
66
- <ul class="link-list">
67
-
68
- <li><span class="type">CLASS</span> <a href="FLogger/Log.html">FLogger::Log</a></li>
69
-
70
- </ul>
71
- </div>
72
-
73
-
74
- <!-- Method Quickref -->
75
-
76
-
77
- <!-- Included Modules -->
78
-
79
- </div>
80
-
81
- <div id="project-metadata">
82
-
83
-
84
- <div id="fileindex-section" class="section project-section">
85
- <h3 class="section-header">Files</h3>
86
- <ul>
87
-
88
- <li class="file"><a href="./CHANGELOG_rdoc.html">CHANGELOG.rdoc</a></li>
89
-
90
- <li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
91
-
92
- </ul>
93
- </div>
94
-
95
-
96
- <div id="classindex-section" class="section project-section">
97
- <h3 class="section-header">Class Index
98
- <span class="search-toggle"><img src="./images/find.png"
99
- height="16" width="16" alt="[+]"
100
- title="show/hide quicksearch" /></span></h3>
101
- <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
102
- <fieldset>
103
- <legend>Quicksearch</legend>
104
- <input type="text" name="quicksearch" value=""
105
- class="quicksearch-field" />
106
- </fieldset>
107
- </form>
108
-
109
- <ul class="link-list">
110
-
111
- <li><a href="./FLogger.html">FLogger</a></li>
112
-
113
- <li><a href="./FLogger/Log.html">FLogger::Log</a></li>
114
-
115
- </ul>
116
- <div id="no-class-search-results" style="display: none;">No matching classes.</div>
117
- </div>
118
-
119
-
120
- </div>
121
- </div>
122
-
123
- <div id="documentation">
124
- <h1 class="module">FLogger</h1>
125
-
126
- <div id="description">
127
-
128
- </div>
129
-
130
- <!-- Constants -->
131
-
132
- <div id="constants-list" class="section">
133
- <h3 class="section-header">Constants</h3>
134
- <dl>
135
-
136
- <dt><a name="VERSION">VERSION</a></dt>
137
-
138
- <dd class="description"></dd>
139
-
140
-
141
- </dl>
142
- </div>
143
-
144
-
145
- <!-- Attributes -->
146
-
147
-
148
- <!-- Methods -->
149
-
150
-
151
- </div>
152
-
153
-
154
- <div id="rdoc-debugging-section-dump" class="debugging-section">
155
-
156
- <p>Disabled; run with --debug to generate this.</p>
157
-
158
- </div>
159
-
160
- <div id="validator-badges">
161
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
162
- <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
163
- Rdoc Generator</a> 1.1.6</small>.</p>
164
- </div>
165
-
166
- </body>
167
- </html>
168
-