Line

ui/server/src/logBuffer

A small, bounded, in-memory ring buffer of recent server/command output for the cockpit's Logs tab.

Cockpit server, v0.9. Source: ui/server/src/logBuffer.mjs.

Variables#

MAX_ENTRIES#

const MAX_ENTRIES: 500 = 500

Defined in: ui/server/src/logBuffer.mjs:33


MAX_LOGINS#

const MAX_LOGINS: 32 = 32

Defined in: ui/server/src/logBuffer.mjs:36

How many logins keep a ring at once; the least recently used one beyond that is dropped.


MAX_TEXT#

const MAX_TEXT: 2000 = 2000

Defined in: ui/server/src/logBuffer.mjs:34


serverLog#

const serverLog: object

Defined in: ui/server/src/logBuffer.mjs:122

The process-wide registry used by the server: one ring per login (see the header).

Type Declaration#

clear()

clear(who?): void

Forgets who's entries (the current login's unless given).

Parameters
who?

string = ...

Returns

void

logins()

logins(): any[]

The logins that currently keep a ring (test seam).

Returns

any[]

read()

read(since?, who?): any

who's entries (the current login's unless given) with id greater than since; [] for a login that never recorded.

Parameters
since?

number = 0

who?

string = ...

Returns

any

record()

record(source, level, text, now?, who?): any

Adds one line to who's ring (the current login unless given).

Parameters
source

any

level

any

text

any

now?

number = ...

who?

string = ...

Returns

any

Functions#

createLogBuffer()#

createLogBuffer(max?, ids?): object

Defined in: ui/server/src/logBuffer.mjs:44

One ring. ids is an optional { next } counter shared with other rings so ids stay unique and increasing across all of them (the registry below); alone, ids start at 1.

Parameters#

max?

number = MAX_ENTRIES

ids?
next

number = 1

Returns#

clear()

clear(): void

Returns

void

read()

read(since?): any[]

Entries with id greater than since (all when omitted), oldest first.

Parameters
since?

number = 0

Returns

any[]

record()

record(source, level, text, now?): object

Adds one line. Text is coerced to a string and truncated; unknown levels become 'info'.

Parameters
source

any

level

any

text

any

now?

number = ...

Returns

object

at

at: number = now

id

id: number

level

level: any

source

source: string

text

text: string = clipped


createLogRegistry()#

createLogRegistry(options?): object

Defined in: ui/server/src/logBuffer.mjs:73

A registry of rings, one per login, behind the single-ring API plus an optional trailing login argument (default: the current request's login; '' outside any request). Passing a login is for code that records on behalf of a user outside that user's request context (devServer.mjs).

Parameters#

options?

login is a test seam

login?

() => string = currentLogin

max?

number = MAX_ENTRIES

maxLogins?

number = MAX_LOGINS

Returns#

clear()

clear(who?): void

Forgets who's entries (the current login's unless given).

Parameters
who?

string = ...

Returns

void

logins()

logins(): any[]

The logins that currently keep a ring (test seam).

Returns

any[]

read()

read(since?, who?): any

who's entries (the current login's unless given) with id greater than since; [] for a login that never recorded.

Parameters
since?

number = 0

who?

string = ...

Returns

any

record()

record(source, level, text, now?, who?): any

Adds one line to who's ring (the current login unless given).

Parameters
source

any

level

any

text

any

now?

number = ...

who?

string = ...

Returns

any


handleLogs()#

handleLogs(query, __namedParameters): { body: { entries?: undefined; error: string; last?: undefined; ok: boolean; }; status: number; } | { body: { entries: any; error?: undefined; last: any; ok: boolean; }; status: number; }

Defined in: ui/server/src/logBuffer.mjs:125

GET /api/logs handler core: origin-guarded, returns { ok, entries, last } for the caller's login.

Parameters#

query

any

__namedParameters
clientOrigin

any

log?

{ clear: void; logins: any[]; read: any; record: any; } = serverLog

log.clear
log.logins
log.read
log.record
origin

any

Returns#

{ body: { entries?: undefined; error: string; last?: undefined; ok: boolean; }; status: number; } | { body: { entries: any; error?: undefined; last: any; ok: boolean; }; status: number; }