log 1.0.1 → 1.0.2

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.
Files changed (3) hide show
  1. data/lib/log.rb +12 -5
  2. data/lib/log/version.rb +1 -1
  3. metadata +2 -2
data/lib/log.rb CHANGED
@@ -28,7 +28,9 @@ module Log
28
28
  Params.boolean('log_write_to_file', true , \
29
29
  'If true then the logger will write the messages to a file.')
30
30
  Params.path('log_file_name', "~/.bbfs/log/#{Log.executable_name}.log4r" , \
31
- 'Default log file name: ~/.bbfs/log/<executable_name>.log')
31
+ 'log file name: ~/.bbfs/log/<executable_name>.log')
32
+ Params.integer('log_rotation_size',1000000 , \
33
+ 'max log file size. when reaching this size, a new file is created for rest of log')
32
34
  Params.boolean('log_write_to_console', false , \
33
35
  'If true then the logger will write the messages to the console.')
34
36
  Params.boolean('log_write_to_email', false , \
@@ -61,12 +63,17 @@ module Log
61
63
  #file setup
62
64
  if Params['log_write_to_file']
63
65
  if File.exist?(Params['log_file_name'])
64
- File.delete Params['log_file_name']
66
+ File.delete(Params['log_file_name'])
65
67
  else
66
68
  dir_name = File.dirname(Params['log_file_name'])
67
69
  FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name)
68
70
  end
69
- file_outputter = Log4r::FileOutputter.new('file_log', :filename => Params['log_file_name'])
71
+ file_config = {
72
+ "filename" => Params['log_file_name'],
73
+ "maxsize" => Params['log_rotation_size'],
74
+ "trunc" => true
75
+ }
76
+ file_outputter = Log4r::RollingFileOutputter.new("file_log", file_config)
70
77
  file_outputter.level = log4r_level
71
78
  file_outputter.formatter = formatter
72
79
  @log4r.outputters << file_outputter
@@ -100,10 +107,10 @@ module Log
100
107
  # print params
101
108
  if Params['print_params_to_stdout']
102
109
  Params.get_init_messages().each { |msg|
103
- @log4r.info(msg)
110
+ Log.info(msg)
104
111
  }
105
112
  else
106
- @log4r.info("Not printing executable parameters since param:'print_params_to_stdout' is false")
113
+ Log.info("Not printing executable parameters since param:'print_params_to_stdout' is false")
107
114
  end
108
115
  end
109
116
 
@@ -1,3 +1,3 @@
1
1
  module Log
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-25 00:00:00.000000000 Z
12
+ date: 2013-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: params