modus
Menu
On this page

The entry log

A system tool: the log of the machine, as records.

Each record has a time, a process, a thread, a level and a text. The kernel writes the records in one memory object; this process maps it with the right Read, and waits on its counter. The top part counts the records of each process. The bottom part shows the last records: the color of the mark is the level, and the color of the name is the process. Each value of a text is in the color of its value kind, as the record keeps it (modus:contract/value_kinds); the head of the column of the text is the legend of the kinds. A text that starts with its process and ": " shows without that start: the column at its left already says it. The record keeps its text whole.

The process needs the grant to read the records of the log. It is also a service: records() and value_runs() give the records and their value runs as tables (exports.odin).

What it is for. The log is the one record of what the machine did: the kernel and every process write to it, and the serial port prints the same texts. This process shows the log as log records with typed fields, not as lines of text: a reader sees at once which process wrote a record, at which level, and which parts of the text are values (a number, a size, a time, a module, a version, a status: the value runs). It shows that a log is data, not text to parse again.

What a reader sees. Start it from the start menu, or with start("log") in the console. The window has:

  • a top line: the count of records read, the count gone before its start, the count lost since, and the count of each level;
  • the processes, each with its count of records, as many as two lines hold; the others count together in the last card;
  • the newest records, in 30 lines: the time in seconds, the process and the text, with the legend of the value kinds over the column of the text. A text is whole, on the lines that it needs. A log fact is the sentence of its fact template with its values, which the window writes from the module file of the boot image that the fact names; a fact whose module the image does not hold is its raw form, the line of the serial port: #, the module tag, :, the key tag and the value bytes in hexadecimal, with each run of zero bytes as a letter.

At its start it writes two records: log: the memory of the log: <count> records in <size> and log: ok, <count> records, <count> gone before its start, <count> lost since, <count> processes.

Lost records. The kernel keeps the last 2047 records in a ring of memory, and writes over the oldest one when the ring is full. The records that the kernel wrote over before this process kept its first record are gone before its start: their count says how long the machine ran before it. A reader that is slower than the writers loses records after that: this process counts them as lost since, in red when the count is not 0.

Its grants: Log_Records, the memory of the log records with the right Read; Serve, its exports; Image, the boot image read-only, in which it finds the module file of a fact. The process writes no record in the name of another process: the kernel sets the process, the thread and the time of each record.

Its exports (exports.odin): records, value_runs and fact_records: the whole log to a caller that acts for the principal, and its own records to each other caller. process_records and process_value_runs: the records of one process whose process handle the caller lends, such as a child of the caller.

connect("log")
log.records(0)
log.records(0) |> where(level = Error)

log module with an entry

Hash
4e01e926594140d5b5d60e4cdd7188065893b016554fc6c62f39a84d4fedabcd
Size
339763 bytes
Exports
5
Imports
0
Imported by
0
License
MIT

A system tool: the log of the machine, as records

FactValue
KindModules with an entry
Sourcesrc/modules/system/log
Boot imageyes: in the boot image, 339763 bytes in this build
Build settingsnone: the defaults of the source
Importsnone
Imported bynone

Neighbours

It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.

Exports

ExportWhat it does
records(after: Integer) -> Table(Record)gives the log records of the log scope of the caller from the number after on, one row each: the number, the time in microseconds, the process and its slot, the level, the count of its value runs, and the text
process_records(process: Handle(Read), after: Integer) -> Table(Record)gives the log records of one process whose process handle the caller lends, from the own number after on, one row each, as records() gives its own records to a caller
value_runs(after: Integer) -> Table(Value_Run)gives the value runs of the log records of the log scope of the caller from the number after on: for each one, the number of its record, its start and its length in bytes of the text of the record, and the name of its kind (number, size, time, module, version, status...)
process_value_runs(process: Handle(Read), after: Integer) -> Table(Value_Run)gives the value runs of the log records of one process whose process handle the caller lends, from the own number after on, as value_runs() gives the runs of its own records
fact_records(after: Integer) -> Table(Fact_Row)gives the log facts of the log scope of the caller from the number after on, one row each, with the bytes that its writer gave: the record form, the fact key, the module hash, the count of the value bytes, its part and its count of parts, and the value bytes of the record
entry()opens the window of the log and runs its loop: it shows each new log record until the process is stopped

records

records(after: ) -> ()

records gives the log records of the log scope of the caller from the number after on, one row each: the number, the time in microseconds, the process and its slot, the level, the count of its value runs, and the text. A row says when its text or its fact goes on in the next record. The first row also gives the records that the kernel wrote over before this call read them. The result is the count of the rows of the scope from after to the last record.

What it is for. A reader of the log checks the process and the level of a record as fields, not by a search in a line of text. The machine test reads the log this way, through the remote service. A process reads its own records back, with their times, levels and value runs.

Parameter: after, the number of the first record to give, from 0. A negative number is 0. A number past the last record gives no row.

A row (Record): number, the number of the record in the whole log, or for a reader of its own records its own number: the count of the records of its process before it; time, microseconds since the start of the machine; process, its name or kernel; slot, its process slot, 0 for the kernel; level, a member of Log_Level: Info, Debug, Warning or ; form, Text, or for a log fact, whose text is empty and whose values fact_records gives; lost, in the first row only; continues, 1 when the text, or the fact of several records, goes on in the next row; runs, the count of its value runs; text, at most 168 bytes.

The result counts the rows of the scope from after to the last record, also the ones that do not fit in the table of the caller: a caller that gets a result larger than its table calls again with after set past its last row. A reader can copy the last 2046 records only: lost in the first row counts the records after after that the kernel wrote over before the read, and the rows start after them. For a reader of its own records, after, number and lost count its own records only: no number or count of the records of other processes. Its rows come from the own log ring of its process, which keeps its last 64 records and which the records of others never fill . A reader whose records are all gone receives no row, so no lost either. A record whose form or level byte names no member gives no row, counts in lost, and is not in the result.

Grant: the log scope of the connection. A caller that acts for the principal receives the whole log: the records are facts of all the processes. Each other caller receives its own records only: the records that the kernel wrote for its process, which the root service names in the grant of the connection by its process slot and its process serial.

connect("log")
log.records(0)
log.records(0) |> where(process = "console") |> where(level = Warning)

See: The own log ring of a process in the repository

Parameters
  • after:
Result
()
Source
src/modules/system/log/exports.odin:243

process_records

process_records(process: (Read), after: ) -> ()

process_records gives the log records of one process whose process handle the caller lends, from the own number after on, one row each, as records() gives its own records to a caller. A starter reads what its children wrote this way. The result is the count of the rows of that process from after to the last record.

What it is for. A process that starts processes, such as a test, shows what each child wrote, with no right to read the whole log. The handle that it received when it started the child is the proof that it may see that child.

Parameters: process, the process handle of the child, lent with the right Read; after, the own number of the first record to give, from 0.

A row (Record): as for records. number is the own number of the record among the records of that process; lost in the first row counts the records of that process after after that its own log ring no longer keeps. The rows come from that ring, which keeps the last 64 records of the process, also after its stop while a handle names it; the records of other processes never fill it.

Grant: the lent handle. Each caller with a connection to the log service receives the records of the process of the handle only, also a caller that acts for the principal. The records of a grandchild need its handle, which only the child holds and can give.

Errors: Handle_Kind for a handle that names no process.

Parameters
  • process: (Read)
  • after:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/log/exports.odin:271

value_runs

value_runs(after: ) -> ()

value_runs gives the value runs of the log records of the log scope of the caller from the number after on: for each one, the number of its record, its start and its length in bytes of the text of the record, and the name of its kind (number, size, time, module, version, status...). The rows of one record are in the order of its text. The result is the count of the runs of the scope from after to the last record.

What it is for. A value run says that a part of the text of a record is a value of a known kind. A reader joins these rows to the rows of records by number, and finds each value without a parse of the text: the window of the log draws each run in the color of its kind.

Parameter: after, the number of the first record, as for records. The records that the kernel wrote over are skipped.

A row (Value_Run): number, the record; start and length, in bytes of its text; kind, the name of the value kind. A run that does not fit in the text of its record gives no row.

The result counts all the runs from after on, also the ones that do not fit in the table of the caller.

Grant: the log scope of the connection, as for records: the whole log for a caller that acts for the principal, else the runs of its own records only.

connect("log")
join(log.records(0), log.value_runs(0), "number")
Parameters
  • after:
Result
()
Source
src/modules/system/log/exports.odin:368

process_value_runs

process_value_runs(process: (Read), after: ) -> ()

process_value_runs gives the value runs of the log records of one process whose process handle the caller lends, from the own number after on, as value_runs() gives the runs of its own records. The result is the count of the runs of that process from after to the last record.

What it is for. A starter joins these rows to the rows of process_records of the same child by number.

Parameters: process, the process handle, lent with the right Read; after, as for process_records.

Grant: the lent handle, as for process_records.

Errors: Handle_Kind for a handle that names no process.

Parameters
  • process: (Read)
  • after:
Result
()
When it fails
a negative result, and the error record
Source
src/modules/system/log/exports.odin:384

fact_records

fact_records(after: ) -> ()

fact_records gives the log facts of the log scope of the caller from the number after on, one row each, with the bytes that its writer gave: the record form, the fact key, the module hash, the count of the value bytes, its part and its count of parts, and the value bytes of the record. The result is the count of the facts of the scope from after to the last record.

What it is for. A log fact is a record with no text: its row in records has its number, its time, its process and its level, and an empty text. A reader joins these rows to the rows of records by number. log_reader checks with them what the kernel wrote for each fact that it gave to Log.

Parameter: after, the number of the first record, as for records.

A row (Fact_Row): number, the record; form, , a member of as in a row of records; continues, its byte more; key; module_hash; value_count; part, from 0, and part_count, the records of its fact ; values, the 144 value bytes of the record, with 0 past value_count.

Grant: the log scope of the connection, as for records.

The console reads these rows for facts(...), which gives the fields of one fact type as columns.

connect("log")
join(log.records(0), log.fact_records(0), "number")
log.records(0) |> facts(log_reader.Fact_Probe)

See: Log facts: typed records in place of formatted lines: A fact of several records in the repository

Parameters
  • after:
Result
()
Source
src/modules/system/log/exports.odin:491

entry

entry()

entry opens the window of the log and runs its loop: it shows each new log record until the process is stopped.

What it sets up: a window, the reader of the log records (the memory of the records that the grant Log_Records gives, mapped read-only), and the service ring of its exports, which read the same memory.

The loop. One wait covers the window, the counter of the log and the service ring. After each wake it takes every new record (take): the counts of each level and of each process, and the last 30 records. It adds the records that the kernel wrote over before the read to the count gone before its start while it kept no record, and to the count lost since after that. It draws the window again only when a record came. At the first turn it writes two records of its own: the records that the ring keeps and the size of the memory of the log, then log: ok, <count> records, <count> gone before its start, <count> lost since, <count> processes. Then it runs the calls of its exports.

The stop: with no window, it stops with Failed. With no grant of the log records, it writes log: cannot read the records of the log: status <status> at the level error, and stops with Failed. Else it never returns.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/system/log/main.odin:773

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

What the root service gives it

WhatValueAs the root service says
GrantsIt serves records(): the whole log to a caller that acts for the principal, its own records to each other caller. The boot image is the catalog in which its window finds the module file of a log fact, to write the sentence of the fact. See: Log facts: typed records in place of formatted lines: The reader path in the repository
Other terms of its start grant setnone
Budget that it asks for
  • working memory pages 1524
  • pages of its threads 72
  • pages of the pictures of its window 4189
  • pages of the module and its imports from the files of the build
  • processes the least
  • threads the least
The least budget of 2048 pages, in which it ran before it stated its window, less that window at the scale 1 (1048 pages): its module, its stack, its tables and its glyph memory. And the picture of the logical size in which it draws by hand (interface.Hand_Picture): 944 x 568 pixels of 4 bytes, 524 pages. 1000 + 524 = 1524. The tool counts the window at the largest scale. See: Module contract: The budget that a module asks for

The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).

Integer wire form

A wire form of the module contract: one word of a call. A signed integer of 64 bits, in a register.

Table wire form

A wire form of the module contract: one word of a call. Records of one description that follow each other (a table).

Record record of a module

A record of the module log: 256 bytes, aligned on 8 bytes, 6 bytes of padding.

  • numberi6408 bytes
  • timei6488 bytes
  • processText(32)1632 bytes
  • sloti64488 bytes
  • levelLog_Level561 bytes
  • formLog_Record_Form571 bytes
  • padding586 bytes
  • losti64648 bytes
  • continuesi64728 bytes

and 2 more

Error enum

An enum of the package module on u32: 4 bytes, 16 members. What is not valid in a module file: the result of header, validate and rebase, and Load_Error.file_error at the stage Read.

  • None0
  • Too_Small1
  • Bad_Magic2
  • Unknown_Version3
  • Unknown_Feature4
  • Unknown_Machine5
  • Bad_Table6
  • Bad_Segment7

and 8 more

Fact struct

A struct of the package module: 32 bytes, aligned on 8 bytes, 0 bytes of padding. One row of the table Facts: one fact type that the module writes.

  • keyu6408 bytes
  • recordu3284 bytes
  • template_offsetu32124 bytes
  • template_countu32164 bytes
  • package_offsetu32204 bytes
  • package_countu32244 bytes
  • reservedu32284 bytes

Handle wire form

A wire form of the module contract: one word of a call. A handle that the caller lends for the time of the call, in a register.

Error_Record record of a module

A record of the module log: 56 bytes, aligned on 8 bytes, 0 bytes of padding.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

Value_Run record of a module

A record of the module log: 40 bytes, aligned on 8 bytes, 0 bytes of padding.

  • numberi6408 bytes
  • starti6488 bytes
  • lengthi64168 bytes
  • kindText(16)2416 bytes

Fact_Row record of a module

A record of the module log: 224 bytes, aligned on 8 bytes, 7 bytes of padding.

  • numberi6408 bytes
  • formLog_Record_Form81 bytes
  • padding97 bytes
  • continuesi64168 bytes
  • keyhexadecimal u64248 bytes
  • module_hashHash(32)3232 bytes
  • value_counti64648 bytes
  • partu32724 bytes
  • part_countu32764 bytes

and 1 more

Log_Record_Form enum

An enum of the package operation on u8: 1 bytes, 2 members. The form of a log record: what its bytes after the name of the process hold.

  • Text0
  • Fact1

Error_Record struct

A struct of the package errors: 56 bytes, aligned on 8 bytes, 0 bytes of padding. The error record: what a call that failed says about why, as seven integers.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

value_runs procedure of the package log

value_runs :: proc "c" (after: i64, result: ^[]Value_Run) -> i64

value_runs gives the value runs of the log records of the log scope of the caller from the number after on: for each one, the number of its record, its start and its length in bytes of the text of the record, and the name of its kind (number, size, time, module, version, status...).

src/modules/system/log/exports.odin:368

fact_records procedure of the package log

fact_records :: proc "c" (after: i64, result: ^[]Fact_Row) -> i64

fact_records gives the log facts of the log scope of the caller from the number after on, one row each, with the bytes that its writer gave: the record form, the fact key, the module hash, the count of the value bytes, its part and its count of parts, and the value bytes of the record.

src/modules/system/log/exports.odin:491

process_value_runs procedure of the package log

process_value_runs :: proc "c" (process: system.Lent({.Read}), after: i64, result: ^[]Value_Run, error: ^errors.) -> i64

process_value_runs gives the value runs of the log records of one process whose process handle the caller lends, from the own number after on, as value_runs() gives the runs of its own records.

src/modules/system/log/exports.odin:384

module_hash global variable of the package cryptography_vectors

module_hash: blake3.Hash

A global variable with no comment in its source.

src/modules/demonstrations/cryptography_vectors/main.odin:89