Module: Glimmer::Config
- Defined in:
- lib/ext/glimmer/config.rb
Constant Summary collapse
- DEFAULT_IMPORT_SWT_PACKAGES =
[ 'org.eclipse.swt', 'org.eclipse.swt.widgets', 'org.eclipse.swt.layout', 'org.eclipse.swt.graphics', 'org.eclipse.swt.browser', 'org.eclipse.swt.custom', 'org.eclipse.swt.dnd', ]
Class Method Summary collapse
-
.import_swt_packages ⇒ Object
Returns whether Glimmer will import SWT packages into including class.
-
.import_swt_packages=(value) ⇒ Object
Tells Glimmer to import SWT packages into including class (default: true).
- .logging_appender_options ⇒ Object
- .logging_appender_options=(custom_options) ⇒ Object
- .logging_device_file_options ⇒ Object
- .logging_device_file_options=(custom_options) ⇒ Object
-
.logging_devices ⇒ Object
Returns Logging Devices.
-
.logging_devices=(devices) ⇒ Object
Logging Devices is an array of these possible values: :stdout (default), :stderr, :file, :syslog (default), :stringio.
- .logging_layout ⇒ Object
- .logging_layout=(custom_layout) ⇒ Object
- .reset_logger! ⇒ Object
Class Method Details
.import_swt_packages ⇒ Object
Returns whether Glimmer will import SWT packages into including class
43 44 45 46 |
# File 'lib/ext/glimmer/config.rb', line 43 def import_swt_packages @@import_swt_packages = DEFAULT_IMPORT_SWT_PACKAGES if !defined?(@@import_swt_packages) || (defined?(@@import_swt_packages) && @@import_swt_packages == true) @@import_swt_packages end |
.import_swt_packages=(value) ⇒ Object
Tells Glimmer to import SWT packages into including class (default: true)
38 39 40 |
# File 'lib/ext/glimmer/config.rb', line 38 def import_swt_packages=(value) @@import_swt_packages = value end |
.logging_appender_options ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/ext/glimmer/config.rb', line 72 def @@logging_appender_options = {async: true, auto_flushing: 500, write_size: 500, flush_period: 60, immediate_at: [:error, :fatal], layout: logging_layout} unless defined? @@logging_appender_options # TODO make this a glimmer command option if ENV['GLIMMER_LOGGER_ASYNC'].to_s.downcase == 'false' @@logging_appender_options.merge!(async: false, auto_flushing: 1, immediate_at: [:debug, :info, :warn, :error, :fatal]) end @@logging_appender_options end |
.logging_appender_options=(custom_options) ⇒ Object
81 82 83 84 |
# File 'lib/ext/glimmer/config.rb', line 81 def () @@logging_appender_options = reset_logger! end |
.logging_device_file_options ⇒ Object
62 63 64 65 |
# File 'lib/ext/glimmer/config.rb', line 62 def @@logging_device_file_options = {size: 1_000_000, age: 'daily', roll_by: 'number'} unless defined? @@logging_device_file_options @@logging_device_file_options end |
.logging_device_file_options=(custom_options) ⇒ Object
67 68 69 70 |
# File 'lib/ext/glimmer/config.rb', line 67 def () @@logging_device_file_options = reset_logger! end |
.logging_devices ⇒ Object
Returns Logging Devices. Default is [:stdout, :syslog]
49 50 51 52 53 54 |
# File 'lib/ext/glimmer/config.rb', line 49 def logging_devices unless defined? @@logging_devices @@logging_devices = [:stdout, :syslog] end @@logging_devices end |
.logging_devices=(devices) ⇒ Object
Logging Devices is an array of these possible values: :stdout (default), :stderr, :file, :syslog (default), :stringio
57 58 59 60 |
# File 'lib/ext/glimmer/config.rb', line 57 def logging_devices=(devices) @@logging_devices = devices reset_logger! end |
.logging_layout ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/ext/glimmer/config.rb', line 86 def logging_layout unless defined? @@logging_layout @@logging_layout = Logging.layouts.pattern( pattern: '[%d] %-5l %c: %m\n', date_pattern: '%Y-%m-%d %H:%M:%S' ) end @@logging_layout end |
.logging_layout=(custom_layout) ⇒ Object
96 97 98 99 |
# File 'lib/ext/glimmer/config.rb', line 96 def logging_layout=(custom_layout) @@logging_layout = custom_layout reset_logger! end |
.reset_logger! ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/ext/glimmer/config.rb', line 101 def reset_logger! @first_time = !defined?(@@logger) old_level = logger.level unless @first_time self.logger = Logging.logger['glimmer'].tap do |logger| logger.level = old_level || :error appenders = [] appenders << Logging.appenders.stdout() if logging_devices.include?(:stdout) appenders << Logging.appenders.stderr() if logging_devices.include?(:stderr) if logging_devices.include?(:file) require 'fileutils' FileUtils.mkdir_p('log') appenders << Logging.appenders.rolling_file('log/glimmer.log', .merge()) if logging_devices.include?(:file) end if Object.const_defined?(:Syslog) && logging_devices.include?(:syslog) Syslog.close if Syslog.opened? appenders << Logging.appenders.syslog('glimmer', ) end logger.appenders = appenders end end |