sr_log 1.0.0 → 1.0.1
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 +4 -2
- data/lib/sr_log/log.rb +5 -7
- data/lib/sr_log/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb049ed242d059468cc49d95c8681f7ca3aadf7d
|
4
|
+
data.tar.gz: 3e8c6cba806e1224a6c7f32795273d39b9c0d131
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6babf8045c1a3ba805effc70b83380a9501a28b2be280133d54571cac92fc72095cb190e21d8927ce3e2d13c44bfde614f0d98bbffad81baff85ccf15e5f0134
|
7
|
+
data.tar.gz: 73b14227569a53a44db82387245e9e7b503e39eb69cda77050b80875a332f4c56bd2ec78776923d469313ffa0c68480356617831dfe534803024e4a1645d125e
|
data/README.md
CHANGED
@@ -26,13 +26,15 @@ To write to a logfile, call the global `sr_log` method. For example:
|
|
26
26
|
sr_log :user_updates, "This is my message"
|
27
27
|
```
|
28
28
|
|
29
|
-
`sr_log` will create a `./log/2016_12_user_updates.log` file if one does not already exist (except that it will use current year/month for the prefix). Then it will write the line "This is my message" to the logfile
|
29
|
+
`sr_log` will create a `./log/2016_12_user_updates.log` file if one does not already exist (except that it will use current year/month for the prefix). Then it will write the line "This is my message" to the logfile.
|
30
30
|
|
31
31
|
Optionally you can pass named arguments to the `sr_log` method:
|
32
32
|
|
33
33
|
Argument: `:dir`, type: `string`. Use `:dir` to set a custom path for where the logfile is saved.
|
34
34
|
|
35
|
-
Argument: `:
|
35
|
+
Argument: `:single_spaced`, type: `boolean`. Use `:single_spaced` to avoid an extra new line between log entries.
|
36
|
+
|
37
|
+
Argument: `:current_user`, type: `Object`. Use `:current_user` to specify that the message is being logged by a use. This will add a `"Logged by user: #{current_user}"` line to the logfile before the message.
|
36
38
|
|
37
39
|
|
38
40
|
## License
|
data/lib/sr_log/log.rb
CHANGED
@@ -7,12 +7,6 @@ module SrLog
|
|
7
7
|
class Log
|
8
8
|
include Singleton
|
9
9
|
|
10
|
-
class SrLogger < Logger
|
11
|
-
def format_message severity, timestamp, progname, msg
|
12
|
-
"\n#{msg}\n"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
10
|
def log log_key, msg, opts = {}
|
17
11
|
@logfiles ||= {}
|
18
12
|
log_month = Date.today.strftime '%Y.%m'
|
@@ -31,7 +25,11 @@ module SrLog
|
|
31
25
|
File.join folder_path, filename
|
32
26
|
end
|
33
27
|
|
34
|
-
@logfiles[log_key] = {log:
|
28
|
+
@logfiles[log_key] = {log: Logger.new(log_path), log_month: log_month}
|
29
|
+
|
30
|
+
@logfiles[log_key][:log].formatter = proc do |severity, timestamp, progname, msg|
|
31
|
+
opts[:single_spaced] ? "#{msg}\n" : "\n#{msg}\n"
|
32
|
+
end
|
35
33
|
end
|
36
34
|
|
37
35
|
msg = "Logged by user: #{opts[:current_user]}\n#{msg}" if opts.has_key?(:current_user)
|
data/lib/sr_log/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sr_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Huber
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|