Module: Julewire::Core::FacadeMethods

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

Instance Method Summary collapse

Instance Method Details

#after_fork!Object



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

def after_fork! = runtime.after_fork!

#attributesObject



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

def attributes = runtime.attributes

#carryObject



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

def carry = runtime.carry

#close(timeout: Core::UNSET) ⇒ Object



119
120
121
# File 'lib/julewire/core/facade_methods.rb', line 119

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

#configObject



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

def config = runtime.config

#configureObject



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

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

#contextObject



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

def context = runtime.context

#current_executionObject



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

def current_execution = runtime.current_execution

#current_execution?Boolean

Returns:

  • (Boolean)


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

def current_execution? = runtime.current_execution?

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



28
29
30
# File 'lib/julewire/core/facade_methods.rb', line 28

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

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

Raises:

  • (ArgumentError)


76
77
78
79
80
81
82
83
84
85
# File 'lib/julewire/core/facade_methods.rb', line 76

def dev!(name = :default, output: $stdout, color: Core::UNSET, chaos: false, banner: chaos, tail: true)
  color = output.respond_to?(:tty?) ? output.tty? : true if color.equal?(Core::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)

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

#doctor(name = :default) ⇒ Object



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

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

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



24
25
26
# File 'lib/julewire/core/facade_methods.rb', line 24

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

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



40
41
42
# File 'lib/julewire/core/facade_methods.rb', line 40

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

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



44
45
46
# File 'lib/julewire/core/facade_methods.rb', line 44

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

#fiberObject

Raises:

  • (ArgumentError)


102
103
104
105
106
107
108
109
110
111
# File 'lib/julewire/core/facade_methods.rb', line 102

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

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

#flush(timeout: Core::UNSET) ⇒ Object



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

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

#healthObject



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

def health = runtime.health

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



32
33
34
# File 'lib/julewire/core/facade_methods.rb', line 32

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

#labelsObject



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

def labels = runtime.labels

#measure(key) ⇒ Object



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

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

#measure_start(key) ⇒ Object



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

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

#observe_self!(name = :default) ⇒ Object



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

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

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



87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/julewire/core/facade_methods.rb', line 87

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



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

def reset! = runtime.reset!

#runtime(name = :default) ⇒ Object



6
7
8
# File 'lib/julewire/core/facade_methods.rb', line 6

def runtime(name = :default)
  Core::RuntimeRegistry.fetch(name, current: Core::RuntimeLocator.current)
end

#start_execution(type:) ⇒ Object



125
126
127
# File 'lib/julewire/core/facade_methods.rb', line 125

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

#summaryObject



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

def summary = runtime.summary

#tail(name = :default) ⇒ Object



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

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

#threadObject

Raises:

  • (ArgumentError)


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

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

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

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



48
49
50
# File 'lib/julewire/core/facade_methods.rb', line 48

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

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



36
37
38
# File 'lib/julewire/core/facade_methods.rb', line 36

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

#with_execution(type:) ⇒ Object



140
141
142
# File 'lib/julewire/core/facade_methods.rb', line 140

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