loggability 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,4 +1,9 @@
1
- == v0.0.1 [2012-04-06] Michael Granger <ged@FaerieMUD.org>
1
+ == v0.0.2 [2012-05-07] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Fix escaping of the 'progname' in the HTML formatter.
4
+
5
+
6
+ == v0.0.1 [2012-05-06] Michael Granger <ged@FaerieMUD.org>
2
7
 
3
8
  First release.
4
9
 
data/README.rdoc CHANGED
@@ -16,17 +16,33 @@ severity, and in which format.
16
16
 
17
17
  An example:
18
18
 
19
- # Load a bunch of libraries
20
- require 'strelka'
21
- require 'inversion'
22
- require 'treequel'
23
- require 'loggability'
24
-
19
+ # Load a bunch of libraries that use Loggability
20
+ require 'strelka'
21
+ require 'inversion'
22
+ require 'treequel'
23
+ require 'loggability'
24
+
25
+ # Set up our own library
26
+ module MyProject
27
+ extend Loggability
28
+ log_as :my_project
29
+
30
+ class Server
31
+ extend Loggability
32
+ log_to :my_project
33
+
34
+ def initialize
35
+ self.log.debug "Listening."
36
+ end
37
+ end
38
+
39
+ end
40
+
25
41
  # Now tell everything that's using Loggability to log to an HTML
26
- # log file at INFO level
27
- Loggability.write_to( '/usr/local/www/htdocs/log.html' )
28
- Loggability.format_as( :html )
29
- Loggability.level = :info
42
+ # log file at INFO level
43
+ Loggability.write_to( '/usr/local/www/htdocs/log.html' )
44
+ Loggability.format_as( :html )
45
+ Loggability.level = :info
30
46
 
31
47
 
32
48
  == Prerequisites
@@ -39,6 +39,12 @@ class Loggability::Formatter::HTML < Loggability::Formatter
39
39
  end
40
40
 
41
41
 
42
+ ### Format the +message+; Overridden to escape the +progname+.
43
+ def call( severity, time, progname, message )
44
+ super( severity, time, escape_html(progname), message )
45
+ end
46
+
47
+
42
48
  #########
43
49
  protected
44
50
  #########
@@ -66,6 +72,7 @@ class Loggability::Formatter::HTML < Loggability::Formatter
66
72
 
67
73
  ### Escape any HTML special characters in +string+.
68
74
  def escape_html( string )
75
+ return string unless string.respond_to?( :gsub )
69
76
  return string.
70
77
  gsub( '&', '&amp;' ).
71
78
  gsub( '<', '&lt;' ).
data/lib/loggability.rb CHANGED
@@ -10,10 +10,10 @@ require 'date'
10
10
  module Loggability
11
11
 
12
12
  # Package version constant
13
- VERSION = '0.0.1'
13
+ VERSION = '0.0.2'
14
14
 
15
15
  # VCS revision
16
- REVISION = %q$Revision: 7b3fcf97718a $
16
+ REVISION = %q$Revision: 1099204b229f $
17
17
 
18
18
  # The key for the global logger (Loggability's own logger)
19
19
  GLOBAL_KEY = :__global__
data/spec/lib/helpers.rb CHANGED
@@ -28,8 +28,6 @@ require 'loggability' unless defined?( Loggability )
28
28
  #
29
29
  module Loggability::SpecHelpers
30
30
 
31
-
32
-
33
31
  end # Loggability::SpecHelpers
34
32
 
35
33
 
@@ -19,8 +19,8 @@ describe Loggability::Formatter::HTML do
19
19
  subject { described_class.new }
20
20
 
21
21
  it "formats messages as HTML" do
22
- subject.call( 'INFO', Time.at(1336286481), nil, "Foom." ).should =~
23
- %r{<span class="log-message-text">Foom.</span>}i
22
+ subject.call( 'INFO', Time.at(1336286481), nil, "Foom." ).
23
+ should =~ %r{<span class="log-message-text">Foom.</span>}i
24
24
  end
25
25
 
26
26
  it "formats exceptions into useful messages" do
@@ -38,8 +38,15 @@ describe Loggability::Formatter::HTML do
38
38
  end
39
39
 
40
40
  it "formats regular objects into useful messages" do
41
- subject.call( 'INFO', Time.at(1336286481), nil, Object.new ).should =~
42
- %r{<span class=\"log-message-text\">#&lt;Object:0x\p{XDigit}+&gt;</span>}
41
+ subject.call( 'INFO', Time.at(1336286481), nil, Object.new ).
42
+ should =~ %r{<span class=\"log-message-text\">#&lt;Object:0x\p{XDigit}+&gt;</span>}
43
43
  end
44
+
45
+ it "escapes the 'progname' part of log messages" do
46
+ progname = "#<Class:0x007f9efa153d08>:0x7f9efa153c18"
47
+ subject.call( 'DEBUG', Time.at(1336286481), progname, Object.new ).
48
+ should =~ %r{#&lt;Class:0x0}
49
+ end
50
+
44
51
  end
45
52
 
data.tar.gz.sig CHANGED
@@ -1,4 +1,2 @@
1
- ���t̛AJ&ڷ��qIi5=QJ5ء��� ��Q �����47y�/�m�& ��GNŒQS9�[�P��}
2
- ��-���؃y��e}BZ�n�s���tp�>����˗zE(���8�����iG���Ibv�P=1v���ȴ�gt
3
- &̿�!�����]��� ��\3F�[�4���ݬ�m�7�;rw�{y� �Aӧ"��bNQ�]���
4
- :2T���av]'hu������&
1
+ _���E��O���p7��.t�"�M0zMU���@��*WZJLI��#4-l[~�˩lH(�u��:gP�n+��f��ۜ|�{M+ �k��u��l����.��eʔ�lzX���B��.�<�ʳ�C<��h�Q�2g#
2
+ ��ssY�7
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggability
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
37
37
  Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
38
38
  cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2012-05-06 00:00:00.000000000 Z
39
+ date: 2012-05-07 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pluginfactory
@@ -153,11 +153,15 @@ dependencies:
153
153
  description: ! "A composable logging system built on the standard Logger library.\n\nYou
154
154
  can add Loggability to large libraries and systems, then hook everything\nup later
155
155
  when you know where you want logs to be written, at what level of\nseverity, and
156
- in which format.\n\nAn example:\n\n # Load a bunch of libraries\n\trequire 'strelka'\n\trequire
157
- 'inversion'\n\trequire 'treequel'\n\trequire 'loggability'\n\n # Now tell everything
158
- that's using Loggability to log to an HTML\n\t# log file at INFO level\n\tLoggability.write_to(
159
- '/usr/local/www/htdocs/log.html' )\n\tLoggability.format_as( :html )\n\tLoggability.level
160
- = :info"
156
+ in which format.\n\nAn example:\n\n # Load a bunch of libraries that use Loggability\n
157
+ \ require 'strelka'\n require 'inversion'\n require 'treequel'\n require
158
+ 'loggability'\n \n # Set up our own library\n module MyProject\n extend
159
+ Loggability\n log_as :my_project\n \n class Server\n extend
160
+ Loggability\n log_to :my_project\n \n def initialize\n
161
+ \ self.log.debug \"Listening.\"\n end\n end\n \n
162
+ \ end\n \n # Now tell everything that's using Loggability to log to an HTML\n
163
+ \ # log file at INFO level\n Loggability.write_to( '/usr/local/www/htdocs/log.html'
164
+ )\n Loggability.format_as( :html )\n Loggability.level = :info"
161
165
  email:
162
166
  - ged@FaerieMUD.org
163
167
  executables:
metadata.gz.sig CHANGED
Binary file