Module: Julewire::Core::FacadeMethods

Includes:
FacadePrivateMethods
Included in:
Julewire
Defined in:
lib/julewire/core/facade_methods.rb

Instance Method Summary collapse

Instance Method Details

#after_fork!Object



154
# File 'lib/julewire/core/facade_methods.rb', line 154

def after_fork! = runtime.after_fork!

#attributesObject



59
# File 'lib/julewire/core/facade_methods.rb', line 59

def attributes = runtime.attributes

#carryObject



60
# File 'lib/julewire/core/facade_methods.rb', line 60

def carry = runtime.carry

#close(timeout: UNSET) ⇒ Object



157
158
159
# File 'lib/julewire/core/facade_methods.rb', line 157

def close(timeout: UNSET)
  runtime.close(timeout: timeout)
end

#configObject



56
# File 'lib/julewire/core/facade_methods.rb', line 56

def config = runtime.config

#configureObject



57
# File 'lib/julewire/core/facade_methods.rb', line 57

def configure(&) = runtime.configure(&)

#contextObject



58
# File 'lib/julewire/core/facade_methods.rb', line 58

def context = runtime.context

#current_executionObject



61
# File 'lib/julewire/core/facade_methods.rb', line 61

def current_execution = runtime.current_execution

#current_execution?Boolean

Returns:

  • (Boolean)


62
# File 'lib/julewire/core/facade_methods.rb', line 62

def current_execution? = runtime.current_execution?

#debug(record = UNSET, **fields) ⇒ Object



68
69
70
# File 'lib/julewire/core/facade_methods.rb', line 68

def debug(record = UNSET, **fields, &)
  emit_with_severity(:debug, record, fields, &)
end

#dev!(name = :default, output: $stdout, color: UNSET, chaos: false, banner: chaos, tail: true) ⇒ Object

Raises:

  • (ArgumentError)


116
117
118
119
120
121
122
123
124
125
# File 'lib/julewire/core/facade_methods.rb', line 116

def dev!(name = :default, output: $stdout, color: UNSET, chaos: false, banner: chaos, tail: true)
  color = output.respond_to?(:tty?) ? output.tty? : true if color.equal?(UNSET)
  punk!(name, output: output, color: color, chaos: chaos, banner: banner)
  return unless tail

  tail_options = tail == true ? {} : tail
  raise ArgumentError, "tail must be true, false, or an options Hash" unless tail_options.is_a?(Hash)

  Tail.attach!(runtime(name), **tail_options)
end

#doctor(name = :default) ⇒ Object



104
105
106
# File 'lib/julewire/core/facade_methods.rb', line 104

def doctor(name = :default)
  Diagnostics::Doctor.call(runtime(name))
end

#emit(record = UNSET, **fields) ⇒ Object



64
65
66
# File 'lib/julewire/core/facade_methods.rb', line 64

def emit(record = UNSET, **fields, &)
  runtime.emit(record, **fields, &)
end

#error(record = UNSET, **fields) ⇒ Object



80
81
82
# File 'lib/julewire/core/facade_methods.rb', line 80

def error(record = UNSET, **fields, &)
  emit_with_severity(:error, record, fields, &)
end

#fatal(record = UNSET, **fields) ⇒ Object



84
85
86
# File 'lib/julewire/core/facade_methods.rb', line 84

def fatal(record = UNSET, **fields, &)
  emit_with_severity(:fatal, record, fields, &)
end

#fiberObject

Raises:

  • (ArgumentError)


142
143
144
145
146
147
148
149
150
151
# File 'lib/julewire/core/facade_methods.rb', line 142

def fiber(**, &)
  raise ArgumentError, "block required" unless block_given?

  envelope = Propagation.capture_local
  Fiber.new(**) do |*args|
    with_cleared_configure_guard do
      Propagation.restore(envelope, owned: true) { yield(*args) }
    end
  end
end

#flush(timeout: UNSET) ⇒ Object



92
93
94
# File 'lib/julewire/core/facade_methods.rb', line 92

def flush(timeout: UNSET)
  runtime.flush(timeout: timeout)
end

#healthObject



96
# File 'lib/julewire/core/facade_methods.rb', line 96

def health = runtime.health

#info(record = UNSET, **fields) ⇒ Object



72
73
74
# File 'lib/julewire/core/facade_methods.rb', line 72

def info(record = UNSET, **fields, &)
  emit_with_severity(:info, record, fields, &)
end

#labelsObject



153
# File 'lib/julewire/core/facade_methods.rb', line 153

def labels = runtime.labels

#measure(key) ⇒ Object



98
99
100
# File 'lib/julewire/core/facade_methods.rb', line 98

def measure(key, &)
  summary.measure(key, &)
end

#measure_start(key) ⇒ Object



102
# File 'lib/julewire/core/facade_methods.rb', line 102

def measure_start(key) = summary.measure_start(key)

#observe_self!(name = :default) ⇒ Object



112
113
114
# File 'lib/julewire/core/facade_methods.rb', line 112

def observe_self!(name = :default, **)
  Diagnostics::MetaObserver.attach!(name, **)
end

#punk!(name = :default, output: $stdout, color: true, chaos: false, banner: chaos) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/julewire/core/facade_methods.rb', line 127

def punk!(name = :default, output: $stdout, color: true, chaos: false, banner: chaos)
  output.write(punk_banner) if banner
  output = punk_chaos_output(output, chaos) if chaos

  runtime(name).configure do |config|
    config.destinations.clear
    config.destinations.use(
      :default,
      formatter: ConsoleFormatter.new,
      encoder: TextEncoder.new(color: color, theme: :punk),
      output: output
    )
  end
end

#reset!Object



155
# File 'lib/julewire/core/facade_methods.rb', line 155

def reset! = runtime.reset_facade!

#runtime(name = :default) ⇒ Object



52
53
54
# File 'lib/julewire/core/facade_methods.rb', line 52

def runtime(name = :default)
  RuntimeRegistry.fetch(name)
end

#start_execution(type:) ⇒ Object



163
164
165
# File 'lib/julewire/core/facade_methods.rb', line 163

def start_execution(type:, **)
  runtime.start_execution(type: type, **)
end

#summaryObject



161
# File 'lib/julewire/core/facade_methods.rb', line 161

def summary = runtime.summary

#tail(name = :default) ⇒ Object



108
109
110
# File 'lib/julewire/core/facade_methods.rb', line 108

def tail(name = :default, **)
  Diagnostics::Tail.attach!(runtime(name), **)
end

#threadObject

Raises:

  • (ArgumentError)


167
168
169
170
171
172
173
174
175
176
# File 'lib/julewire/core/facade_methods.rb', line 167

def thread(*, &)
  raise ArgumentError, "block required" unless block_given?

  envelope = Propagation.capture_local
  Thread.new(*) do |*thread_args|
    with_cleared_configure_guard do
      Propagation.restore(envelope, owned: true) { yield(*thread_args) }
    end
  end
end

#unknown(record = UNSET, **fields) ⇒ Object



88
89
90
# File 'lib/julewire/core/facade_methods.rb', line 88

def unknown(record = UNSET, **fields, &)
  emit_with_severity(:unknown, record, fields, &)
end

#warn(record = UNSET, **fields) ⇒ Object



76
77
78
# File 'lib/julewire/core/facade_methods.rb', line 76

def warn(record = UNSET, **fields, &)
  emit_with_severity(:warn, record, fields, &)
end

#with_execution(type:) ⇒ Object



178
179
180
# File 'lib/julewire/core/facade_methods.rb', line 178

def with_execution(type:, **, &)
  runtime.with_execution(type: type, **, &)
end