GunnyLog 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +81 -62
- data/lib/GunnyLog.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20fd49a5983b4fedb2278ba64e8e3ed75f80fde7
|
4
|
+
data.tar.gz: 642920643fa21c3251a999f4bac4d7fe5888cce3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50009f7ffbfa47e57c724f0d3cb6b383f85a9892f958b014a59894d51f32371357cbbab56f3642eb2ead110c4dc4d99ac3e01bd33378fa5670bc3fb0c15e5b93
|
7
|
+
data.tar.gz: 649b1698678f24ef37470fd6d4e788e892dcc8ad2525adecd14568025ce9b72342bf2c3dfac61269006fc593d9ff6045fc9e0895194c74e13f7f9b69573b5524
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Ruby logfile class
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
```
|
9
|
+
```
|
10
10
|
gem 'GunnyLog'
|
11
11
|
```
|
12
12
|
|
@@ -26,98 +26,117 @@ require 'GunnyLog'
|
|
26
26
|
### Example of screen logging, one liners
|
27
27
|
|
28
28
|
#### Sample code
|
29
|
-
|
30
|
-
GunnyLog.instance.
|
29
|
+
```
|
30
|
+
GunnyLog.instance.message('Main:Runloop', 'Error loading preferences')
|
31
|
+
GunnyLog.instance.message('Another Error loading preferences')
|
32
|
+
|
33
|
+
GunnyLog.instance.message_formatted('TestClass:GetUrl', 'Error number = %d', errno)
|
34
|
+
GunnyLog.instance.message_formatted('Error number = %d', errno2)
|
35
|
+
```
|
31
36
|
|
32
37
|
#### Sample output
|
33
|
-
|
34
|
-
09/
|
38
|
+
```
|
39
|
+
09/16/2014|01:27:30PM|testapp01.rb|Main:Runloop|Error loading preferences
|
40
|
+
09/16/2014|01:27:30PM|testapp01.rb|Main:Runloop|Another Error loading preferences
|
41
|
+
09/16/2014|01:27:30PM|testapp01.rb|TestClass:GetUrl|Error number = 44
|
42
|
+
09/16/2014|01:27:30PM|testapp01.rb|TestClass:GetUrl|Error number = 22
|
43
|
+
```
|
35
44
|
|
36
45
|
### Example of screen logging
|
37
46
|
|
38
47
|
#### Sample code
|
39
|
-
|
48
|
+
```
|
49
|
+
logs = GunnyLog.instance
|
40
50
|
|
41
|
-
logs.message('Testing GunnyScreenLog 01')
|
42
|
-
logs.set_logging_enabled(false)
|
43
|
-
logs.message('Testing GunnyScreenLog 02 OFF')
|
44
|
-
logs.set_logging_enabled(true)
|
51
|
+
logs.message('SomeMethod','Testing GunnyScreenLog 01')
|
52
|
+
logs.set_logging_enabled(false)
|
53
|
+
logs.message('Testing GunnyScreenLog 02 OFF')
|
54
|
+
logs.set_logging_enabled(true)
|
45
55
|
|
46
|
-
logs.set_message_location('init')
|
47
|
-
logs.message('Testing GunnyScreenLog 01')
|
48
|
-
logs.set_message_location('destroy')
|
49
|
-
logs.message('Testing GunnyScreenLog 02')
|
56
|
+
logs.set_message_location('init')
|
57
|
+
logs.message('Testing GunnyScreenLog 01')
|
58
|
+
logs.set_message_location('destroy')
|
59
|
+
logs.message('Testing GunnyScreenLog 02')
|
50
60
|
|
51
|
-
logs.message('read','Testing GunnyScreenLog 02')
|
52
|
-
logs.message('
|
61
|
+
logs.message('read','Testing GunnyScreenLog 02')
|
62
|
+
logs.message('Testing GunnyScreenLog 03')
|
53
63
|
|
54
|
-
logs.message_formatted('name: %s, age: %d, job: %s', ['Gunny',
|
55
|
-
logs.message_formatted_vars(nil, 'name: %s, age: %d, job: %s', 'Gunny',
|
64
|
+
logs.message_formatted('sort','name: %s, age: %d, job: %s', ['Gunny', errno, 'Developer'])
|
65
|
+
logs.message_formatted_vars(nil, 'name: %s, age: %d, job: %s', 'Gunny', errno2, 'Developer')
|
66
|
+
```
|
56
67
|
|
57
68
|
#### Sample output
|
58
|
-
|
59
|
-
09/
|
60
|
-
09/
|
61
|
-
09/
|
62
|
-
09/
|
63
|
-
09/
|
64
|
-
09/
|
65
|
-
|
69
|
+
```
|
70
|
+
09/16/2014|01:43:35PM|testapp01.rb|SomeMethod|Testing GunnyScreenLog 01
|
71
|
+
09/16/2014|01:43:35PM|testapp01.rb|init|Testing GunnyScreenLog 01
|
72
|
+
09/16/2014|01:43:35PM|testapp01.rb|destroy|Testing GunnyScreenLog 02
|
73
|
+
09/16/2014|01:43:35PM|testapp01.rb|read|Testing GunnyScreenLog 02
|
74
|
+
09/16/2014|01:43:35PM|testapp01.rb|read|Testing GunnyScreenLog 03
|
75
|
+
09/16/2014|01:43:35PM|testapp01.rb|sort|name: Gunny, age: 42, job: Developer
|
76
|
+
09/16/2014|01:43:35PM|testapp01.rb|sort|name: Gunny, age: 22, job: Developer
|
77
|
+
```
|
66
78
|
|
67
79
|
### Example of file logging
|
68
80
|
|
69
81
|
#### Sample code
|
70
|
-
|
71
|
-
logf.
|
82
|
+
```
|
83
|
+
logf = GunnyLog.instance
|
84
|
+
logf.open('testapp.log')
|
72
85
|
|
73
|
-
logf.message('Testing GunnyFileLog 01')
|
74
|
-
logf.set_logging_enabled(false)
|
75
|
-
logf.message('Testing GunnyFileLog 02 OFF')
|
76
|
-
logf.set_logging_enabled(true)
|
86
|
+
logf.message('init', 'Testing GunnyFileLog 01')
|
87
|
+
logf.set_logging_enabled(false)
|
88
|
+
logf.message('Testing GunnyFileLog 02 OFF')
|
89
|
+
logf.set_logging_enabled(true)
|
77
90
|
|
78
|
-
logf.set_message_location('
|
79
|
-
logf.message('Testing GunnyFileLog 01')
|
80
|
-
logf.set_message_location('destroy')
|
81
|
-
logf.message('Testing GunnyFileLog 02')
|
91
|
+
logf.set_message_location('setup')
|
92
|
+
logf.message('Testing GunnyFileLog 01')
|
93
|
+
logf.set_message_location('destroy')
|
94
|
+
logf.message('Testing GunnyFileLog 02')
|
82
95
|
|
83
|
-
logf.message('read','Testing GunnyFileLog 02')
|
84
|
-
logf.message('
|
96
|
+
logf.message('read','Testing GunnyFileLog 02')
|
97
|
+
logf.message('Testing GunnyFileLog 03')
|
85
98
|
|
86
|
-
logf.message_formatted('name: %s, age: %d, job: %s', ['Gunny',
|
87
|
-
logf.message_formatted_vars(nil, 'name: %s, age: %d, job: %s', 'Gunny',
|
99
|
+
logf.message_formatted('sort', 'name: %s, age: %d, job: %s', ['Gunny', errno, 'Developer'])
|
100
|
+
logf.message_formatted_vars(nil, 'name: %s, age: %d, job: %s', 'Gunny', errno2, 'Developer')
|
88
101
|
|
89
|
-
logf.close
|
102
|
+
logf.close
|
103
|
+
```
|
90
104
|
|
91
105
|
#### Sample output
|
92
|
-
|
93
|
-
09/
|
94
|
-
09/
|
95
|
-
09/
|
96
|
-
09/
|
97
|
-
09/
|
98
|
-
09/
|
99
|
-
|
106
|
+
```
|
107
|
+
09/16/2014|01:45:59PM|testapp01.rb|init|Testing GunnyFileLog 01
|
108
|
+
09/16/2014|01:45:59PM|testapp01.rb|setup|Testing GunnyFileLog 01
|
109
|
+
09/16/2014|01:45:59PM|testapp01.rb|destroy|Testing GunnyFileLog 02
|
110
|
+
09/16/2014|01:45:59PM|testapp01.rb|read|Testing GunnyFileLog 02
|
111
|
+
09/16/2014|01:45:59PM|testapp01.rb|read|Testing GunnyFileLog 03
|
112
|
+
09/16/2014|01:45:59PM|testapp01.rb|sort|name: Gunny, age: 42, job: Developer
|
113
|
+
09/16/2014|01:45:59PM|testapp01.rb|sort|name: Gunny, age: 22, job: Developer
|
114
|
+
```
|
100
115
|
|
101
116
|
### Example of logging with logging level
|
102
117
|
|
103
118
|
#### Sample code
|
104
|
-
|
119
|
+
```
|
120
|
+
g = GunnyLog.instance
|
105
121
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
122
|
+
g.set_logging_level(GunnyLog::ERROR)
|
123
|
+
g.log_fatal('init', 'error message 1')
|
124
|
+
g.log_error('pref', 'error message 2')
|
125
|
+
g.log_info('main', 'error message 3')
|
110
126
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
127
|
+
g.set_logging_level(GunnyLog::WARNING)
|
128
|
+
g.log_warning('getdb', 'error message 4')
|
129
|
+
g.log_unknown('main', 'error message 5')
|
130
|
+
g.log_debug('genreport', 'error message 6')
|
131
|
+
```
|
115
132
|
|
116
133
|
#### Sample output
|
117
|
-
|
118
|
-
09/
|
119
|
-
09/
|
120
|
-
09/
|
134
|
+
```
|
135
|
+
09/16/2014|01:48:16PM|testapp01.rb|FATAL|init|error message 1
|
136
|
+
09/16/2014|01:48:16PM|testapp01.rb|ERROR|pref|error message 2
|
137
|
+
09/16/2014|01:48:16PM|testapp01.rb|WARNING|getdb|error message 4
|
138
|
+
09/16/2014|01:48:16PM|testapp01.rb|UNKNOWN|main|error message 5
|
139
|
+
```
|
121
140
|
|
122
141
|
## Documentation
|
123
142
|
|
data/lib/GunnyLog.rb
CHANGED
@@ -154,7 +154,8 @@ class GunnyLog
|
|
154
154
|
# Write exception to logfile
|
155
155
|
# @param exc [exception] exception to log
|
156
156
|
def msg_exception(exc)
|
157
|
-
write_msg(@logging_file, @logging_location, exc.message)
|
157
|
+
#write_msg(@logging_file, @logging_location, exc.message)
|
158
|
+
message_exception(nil, exc)
|
158
159
|
end
|
159
160
|
|
160
161
|
# Write exception to logfile
|