sr_log 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5db7707c0a77a5d4bac7ed154ebd05f6bd1983df
4
- data.tar.gz: 4f7060824e0dd840c9e9f2d0e8bb5c589c27be41
3
+ metadata.gz: eb049ed242d059468cc49d95c8681f7ca3aadf7d
4
+ data.tar.gz: 3e8c6cba806e1224a6c7f32795273d39b9c0d131
5
5
  SHA512:
6
- metadata.gz: 4b8f8e4dadbfc0b5908e8f601ffc8dd179c1e6bb9c66300014d20f009f9fc8ec6fd2c6c95c9a750e6fed77ffffc1e9881bf4aa86d0f3358c498baffd9934cc61
7
- data.tar.gz: 72fb5b9b1bd642f38dde09c3f344a455cfb870a9bfd0daa7f59ab13bbf6a3514a177e6d81dd37a6b9aace7d6b625893e9716dc033ff8013250b8c3e7c70bbe1a
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 after a timestamp.
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: `: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 after the timestamp in the logfile.
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: SrLogger.new(log_path), log_month: log_month}
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)
@@ -1,3 +1,3 @@
1
1
  module SrLog
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
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.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: 2016-12-15 00:00:00.000000000 Z
11
+ date: 2017-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler