Module: Snails::Logger::Context

Defined in:
runtime/snails/logger/context.rbs,
runtime/snails/logger/context.rb

Class Method Summary collapse

Class Method Details

.action ⇒ String

the action the router matched, or "".

Returns:

  • (String) —

    the matched action name



53
# File 'runtime/snails/logger/context.rb', line 53

def self.action: () -> String

.action=(name) ⇒ String

record the matched action.

Parameters:

  • name (String) —

    the action name

Returns:

  • (String) —

    the assigned name



61
# File 'runtime/snails/logger/context.rb', line 61

def self.action=: (String name) -> String

.add_db_us(microseconds) ⇒ void

add one statement's elapsed time to the current request or job. A call outside both is a no-op: boot and non-job DB work has no record to report it on.

Parameters:

  • microseconds (Integer) —

    the statement's elapsed time



105
# File 'runtime/snails/logger/context.rb', line 105

def self.add_db_us: (Integer microseconds) -> void

.begin_job(name, id, attempt) ⇒ void

set the job values a worker loop carries while it runs one job, and reset the DB accumulator. The job's ensure calls end_job so a reused worker thread never leaks the previous job's identity or DB time. A process-local job has no row id or attempt, so both may be nil; the logger then omits those fields.

Parameters:

  • name (String) —

    the job's class name

  • id (Integer, nil) —

    the job id

  • attempt (Integer, nil) —

    the attempt number



178
# File 'runtime/snails/logger/context.rb', line 178

def self.begin_job: (String name, Integer? id, Integer? attempt) -> void

.begin_request ⇒ String

start a new request: mint the id, clear the matched and job fields, and reset the DB accumulator. The id is short on purpose: it only has to separate lines within one log stream, and the pid already separates workers.

Returns:

  • (String) —

    the new request id



201
# File 'runtime/snails/logger/context.rb', line 201

def self.begin_request: () -> String

.controller ⇒ String

the controller class name the router matched, or "" when no controller ran (a 404, a 400, or an app-owned dispatch).

Returns:

  • (String) —

    the matched controller name



38
# File 'runtime/snails/logger/context.rb', line 38

def self.controller: () -> String

.controller=(name) ⇒ String

record the matched controller for the request line.

Parameters:

  • name (String) —

    the controller class name

Returns:

  • (String) —

    the assigned name



46
# File 'runtime/snails/logger/context.rb', line 46

def self.controller=: (String name) -> String

.db_us ⇒ Integer

the DB time accumulated for this request or job, or 0 outside both. The value is a subset of the request or job duration, not the remainder: routing, JSON rendering, and the SQLite connection lease sit outside the DB adapter's statement entries.

Returns:

  • (Integer) —

    microseconds spent inside the DB adapter



95
# File 'runtime/snails/logger/context.rb', line 95

def self.db_us: () -> Integer

.end_job ⇒ void

clear the job values and the DB accumulator after a run.



188
# File 'runtime/snails/logger/context.rb', line 188

def self.end_job: () -> void

.format ⇒ String

the request format (json by default), or "".

Returns:

  • (String) —

    the request format



68
# File 'runtime/snails/logger/context.rb', line 68

def self.format: () -> String

.format=(name) ⇒ String

record the request format.

Parameters:

  • name (String) —

    the format name

Returns:

  • (String) —

    the assigned name



76
# File 'runtime/snails/logger/context.rb', line 76

def self.format=: (String name) -> String

.job_attempt ⇒ Integer?

the running job's attempt number, or nil.

Returns:

  • (Integer, nil) —

    the attempt number



145
# File 'runtime/snails/logger/context.rb', line 145

def self.job_attempt: () -> Integer?

.job_attempt=(attempt) ⇒ Integer?

record the running job's attempt number.

Parameters:

  • attempt (Integer, nil) —

    the attempt number

Returns:

  • (Integer, nil) —

    the assigned attempt



164
# File 'runtime/snails/logger/context.rb', line 164

def self.job_attempt=: (Integer? attempt) -> Integer?

.job_events_suppressed? ⇒ Boolean

whether the job running on this thread must not have its job.started/job.finished/job.failed records written. The log delivery job is the one job that answers yes: those records would be delivered by the very transport that enqueues it, so each run would feed the next one. A thread outside a job answers no.

Returns:

  • (Boolean) —

    true when the running job's events stay unwritten



156
# File 'runtime/snails/logger/context.rb', line 156

def self.job_events_suppressed?: () -> bool

.job_id ⇒ Integer?

the running job's id, or nil.

Returns:



130
# File 'runtime/snails/logger/context.rb', line 130

def self.job_id: () -> Integer?

.job_id=(id) ⇒ Integer?

record the running job's id.

Parameters:

Returns:

  • (Integer, nil) —

    the assigned id



138
# File 'runtime/snails/logger/context.rb', line 138

def self.job_id=: (Integer? id) -> Integer?

.job_name ⇒ String?

the job running on this thread, or nil.

Returns:

  • (String, nil) —

    the job's class name



115
# File 'runtime/snails/logger/context.rb', line 115

def self.job_name: () -> String?

.job_name=(name) ⇒ String?

record the running job's class name.

Parameters:

  • name (String, nil) —

    the job's class name

Returns:

  • (String, nil) —

    the assigned name



123
# File 'runtime/snails/logger/context.rb', line 123

def self.job_name=: (String? name) -> String?

.now_us ⇒ Integer

one reading of the monotonic clock in microseconds. Tep::App measures the request duration with the same clock, so the summary fields are comparable.

Returns:

  • (Integer) —

    microseconds since an unspecified fixed point



85
# File 'runtime/snails/logger/context.rb', line 85

def self.now_us: () -> Integer

.request_id ⇒ String?

the id of the request this thread is serving, or nil outside a request.

Returns:

  • (String, nil) —

    the current request id



30
# File 'runtime/snails/logger/context.rb', line 30

def self.request_id: () -> String?