eucalypt 0.4.0 → 0.4.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
  SHA256:
3
- metadata.gz: 6c60fdfe8acbb3fc20522a15ba2b2ae84ae44e0bf38cac367e0cb8e68ca27d93
4
- data.tar.gz: 44a5f0030d260eed36904ff8b25d5604b37168dec7bdc6e0da7a65ef6c4d5838
3
+ metadata.gz: 30f59d26df1bd25928ccbc4f6ffed978bf3d3fc9387928d100ad3dbb21c419ae
4
+ data.tar.gz: 21e246723e17aa247f0c263018ad81864f65bb5184419f1f8d2ad2d27db80f5c
5
5
  SHA512:
6
- metadata.gz: 4327801d427b9edf24794acac2cf0dc27149aacefdc93c3a2819395237c93fc78dc180119c34cbc9397f7d2730ee2b6b5377f38b81c87d6219ce2abb4e72ef79
7
- data.tar.gz: c365dc1bf0e21686501762fb4bb7408e6a1873eec45285fd930f214e1e94501c2b017512c6e10b9a1e9a9726fed6c35f1558abd457074a16e48a7d38b1a62771
6
+ metadata.gz: 678240c6a339075aeab896c6eb08f1193581cd667d034a996d1041be4462a064d2d4a87179bb78bd5533cf1deaf4499acb04d5a1c4727602f03822a392f0243e
7
+ data.tar.gz: 491dccc27711788d533a81aeee63edbb4ee619575d6f9c52c76f251b8f96cff0e8488afaa8251461ab2533abf426aba0f17a2e8db905420a8e6bd042f78260a8
@@ -0,0 +1,48 @@
1
+ class ApplicationController < Sinatra::Base
2
+ LOGGER = if (settings.logging == !!settings.logging)
3
+ Lumberjack::Logger.new $stdout
4
+ else
5
+ Lumberjack::Logger.new $stdout, level: settings.logging
6
+ end
7
+
8
+ set :logger, LOGGER
9
+
10
+ class DummyLogger
11
+ def initialize(silence = false, stdout = nil)
12
+ @silence = silence
13
+ @stdout = stdout
14
+ end
15
+
16
+ def method_missing(m, *args, &block)
17
+ LOGGER.send(m, *args, &block)
18
+ $stdout.reopen(@stdout) if @silence
19
+ end
20
+ end
21
+
22
+ helpers do
23
+ def logger()
24
+ if settings.logging
25
+ return DummyLogger.new
26
+ else
27
+ stdout = $stdout.clone
28
+ $stdout.reopen IO::NULL
29
+ return DummyLogger.new(true, stdout)
30
+ end
31
+ end
32
+ end
33
+
34
+ private_constant :DummyLogger
35
+
36
+ if settings.log_file
37
+ time = Time.now.strftime settings.log_directory_format # Sanitize time!
38
+ path = Eucalypt.path('logs', time)
39
+
40
+ require 'fileutils'
41
+ FileUtils.mkdir_p path
42
+
43
+ $stderr.reopen File.new(File.join(path, "#{settings.environment}.stderr.log"), 'a+')
44
+ $stderr.sync = true
45
+ $stdout.reopen File.new(File.join(path, "#{settings.environment}.stdout.log"), 'a+')
46
+ $stdout.sync = true
47
+ end
48
+ end
@@ -1,29 +1,24 @@
1
- require 'fileutils'
2
1
  class ApplicationController < Sinatra::Base
3
- set :logger, Lumberjack::Logger.new
4
- helpers { def logger() settings.logger end }
2
+ configure :test do
3
+ disable :logging
4
+ disable :log_file
5
+ end
5
6
 
6
- configure(:test) { disable :logging }
7
- configure(:development) { enable :logging }
7
+ configure :development do
8
+ enable :logging
9
+ disable :log_file
10
+ end
8
11
 
9
- # Environments where STDOUT should be redirected to log file
10
- %i[production].each do |app_env|
11
- configure app_env do
12
- enable :logging
13
- use Rack::CommonLogger, $stdout
12
+ configure :production do
13
+ set :logging, Lumberjack::Severity::UNKNOWN
14
+ enable :log_file
15
+ end
14
16
 
15
- time = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
16
- log_path = Eucalypt.path 'log', time.sub(/_\+/, ?p).sub(/_\-/, ?m)
17
- FileUtils.mkdir_p log_path
17
+ set :log_directory_format, "%Y-%m-%d_%H-%M-%S"
18
18
 
19
- $stderr.reopen File.new(File.join(log_path, "#{app_env}.stderr.log"), 'a+')
20
- $stderr.sync = true
21
- $stdout.reopen File.new(File.join(log_path, "#{app_env}.stdout.log"), 'a+')
22
- $stdout.sync = true
23
- end
24
- end
19
+ require 'eucalypt/core/helpers/logging'
25
20
 
26
21
  # ActiveRecord logging
27
22
  ActiveRecord::Base.logger = Logger.new STDOUT
28
- ActiveRecord::Migration.verbose = true # Set to false for quieter logging
23
+ ActiveRecord::Migration.verbose = true
29
24
  end
@@ -1,3 +1,3 @@
1
1
  module Eucalypt
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eucalypt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edwin Onuonga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-22 00:00:00.000000000 Z
11
+ date: 2018-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -233,6 +233,7 @@ files:
233
233
  - lib/eucalypt/core/cli/rake.rb
234
234
  - lib/eucalypt/core/cli/test.rb
235
235
  - lib/eucalypt/core/cli/version.rb
236
+ - lib/eucalypt/core/helpers/logging.rb
236
237
  - lib/eucalypt/core/helpers/manifest.rb
237
238
  - lib/eucalypt/core/helpers/partial.rb
238
239
  - lib/eucalypt/core/templates/Gemfile.tt
@@ -259,7 +260,7 @@ files:
259
260
  - lib/eucalypt/core/templates/eucalypt/config/database.yml
260
261
  - lib/eucalypt/core/templates/eucalypt/config/initializers/.empty_directory
261
262
  - lib/eucalypt/core/templates/eucalypt/config/logging.rb
262
- - lib/eucalypt/core/templates/eucalypt/log/.empty_directory
263
+ - lib/eucalypt/core/templates/eucalypt/logs/.empty_directory
263
264
  - lib/eucalypt/core/templates/eucalypt/spec/controllers/application_controller_spec.rb
264
265
  - lib/eucalypt/core/templates/eucalypt/spec/helpers/application_helper_spec.rb
265
266
  - lib/eucalypt/core/templates/eucalypt/spec/models/.empty_directory