logjam_logger 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README +6 -2
- data/lib/logjam_logger/formatter.rb +3 -3
- data/logjam_logger.gemspec +1 -1
- metadata +1 -1
data/LICENSE
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010 David Anderson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
This gem provides syslog-compatible logging for rails applications.
|
1
|
+
This gem provides syslog-compatible logging for rails applications. Just add it to your application and you are good to go -- no other changes are required. (But to really take your logging to the next level, also add time_bandits.)
|
2
|
+
|
3
|
+
config.gem 'logjam_logger'
|
2
4
|
|
3
5
|
User ids are logged via a global variable, $user_id. You can use a before_filter in your application_controller to set it, eg:
|
4
6
|
|
5
7
|
before_filter { |controller| $user_id = controller.session[:user_id] || 0 }
|
6
8
|
|
7
|
-
If you wish to change the format of the logged output, you can set LOGJAM_FORMATTER_CLASS to your own formatter
|
9
|
+
If you wish to change the format of the logged output, you can set LOGJAM_FORMATTER_CLASS to your own formatter after loading the gem. For a simple example, see LogjamLogger::SimpleFormatter in lib/logjam_logger/simple_formatter.rb.
|
8
10
|
|
11
|
+
config.gem 'logjam_logger'
|
12
|
+
LOGJAM_FORMATTER_CLASS = MyCustomFormatter
|
@@ -6,12 +6,12 @@ module LogjamLogger
|
|
6
6
|
|
7
7
|
private
|
8
8
|
|
9
|
-
# Logging user_ids via a global
|
9
|
+
# Logging user_ids via a global hash, $user_ids.
|
10
10
|
# You can use a before_filter in your application_controller to set it, eg:
|
11
11
|
#
|
12
|
-
# before_filter { |controller| $
|
12
|
+
# before_filter { |controller| ($user_ids ||= {})[Thread.current] = controller.session[:user_id] || 0 }
|
13
13
|
def user_id
|
14
|
-
defined?($
|
14
|
+
defined?($user_ids) ? " user[#{$user_ids[Thread.current]}]" : ''
|
15
15
|
end
|
16
16
|
|
17
17
|
# Note: If you are using FastCGI you may need to hard-code the hostname here instead of using Socket.gethostname
|
data/logjam_logger.gemspec
CHANGED