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', ]
- DEFAULT_AUTO_SYNC_EXEC =
true
Class Method Summary collapse
-
.auto_sync_exec ⇒ Object
(also: auto_sync_exec?)
Returns whether Glimmer will import SWT packages into including class.
-
.auto_sync_exec=(value) ⇒ Object
Tells Glimmer to avoid automatic use of sync_exec when invoking GUI calls from another thread (default: true).
-
.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
.auto_sync_exec ⇒ Object Also known as: auto_sync_exec?
Returns whether Glimmer will import SWT packages into including class
55 56 57 58 |
# File 'lib/ext/glimmer/config.rb', line 55 def auto_sync_exec @@auto_sync_exec = DEFAULT_AUTO_SYNC_EXEC if !defined?(@@auto_sync_exec) @@auto_sync_exec end |
.auto_sync_exec=(value) ⇒ Object
Tells Glimmer to avoid automatic use of sync_exec when invoking GUI calls from another thread (default: true)
50 51 52 |
# File 'lib/ext/glimmer/config.rb', line 50 def auto_sync_exec=(value) @@auto_sync_exec = value end |
.import_swt_packages ⇒ Object
Returns whether Glimmer will import SWT packages into including class
44 45 46 47 |
# File 'lib/ext/glimmer/config.rb', line 44 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)
39 40 41 |
# File 'lib/ext/glimmer/config.rb', line 39 def import_swt_packages=(value) @@import_swt_packages = value end |
.logging_appender_options ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/ext/glimmer/config.rb', line 85 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
94 95 96 97 |
# File 'lib/ext/glimmer/config.rb', line 94 def () @@logging_appender_options = reset_logger! end |
.logging_device_file_options ⇒ Object
75 76 77 78 |
# File 'lib/ext/glimmer/config.rb', line 75 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
80 81 82 83 |
# File 'lib/ext/glimmer/config.rb', line 80 def () @@logging_device_file_options = reset_logger! end |
.logging_devices ⇒ Object
Returns Logging Devices. Default is [:stdout, :syslog]
62 63 64 65 66 67 |
# File 'lib/ext/glimmer/config.rb', line 62 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
70 71 72 73 |
# File 'lib/ext/glimmer/config.rb', line 70 def logging_devices=(devices) @@logging_devices = devices reset_logger! end |
.logging_layout ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'lib/ext/glimmer/config.rb', line 99 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
109 110 111 112 |
# File 'lib/ext/glimmer/config.rb', line 109 def logging_layout=(custom_layout) @@logging_layout = custom_layout reset_logger! end |
.reset_logger! ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/ext/glimmer/config.rb', line 114 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 |