Documentation
¶
Overview ¶
Package pluginlog is the log an administrator reads on a plugin's page - an app plugin's (internal/wasmplugin) and a storage plugin's (internal/plugin) alike - and the one rule that keeps it, and the server log behind it, from drowning in a single repeated line.
⚠ ONE helper for both kinds of plugin, on purpose (issue #104, the owner's call): a storage plugin that cannot answer for a folder is asked about it again on every sync pass, every few seconds on a busy storage, and each answer is the same line. Written as it came, that line pushed everything else out of the page's 500 lines within minutes and filled the server log with copies. So:
- On the page, a line that repeats one of the last 50 is not added again: the earlier line counts it (Count) and moves to the end with the time of the latest repeat (Last). A poller asking for what is newer than its cursor gets the line once more, with the same ID, and replaces it.
- In the server log (Mirror), the same line is written at most once every ServerEvery (5 minutes), with how many times it repeated in between.
- The page keeps the newest Size lines (500): plenty to read what happened today, and a fixed amount of memory per plugin.
The log is in memory and starts empty with the process, like the app plugins' ring it replaces: it is for reading what a plugin is doing now, not an archive. What must outlive a restart goes to the audit trail.
Index ¶
Constants ¶
const ServerEvery = 5 * time.Minute
ServerEvery is the least time between two copies of the same line in the server log.
const Size = 500
Size is how many lines a log keeps.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Line ¶
type Line struct {
// ID stays the same when the line repeats: a poller replaces the line it
// already has by it.
ID int64 `json:"id"`
// Seq is the cursor (?after=): it moves on whenever the line is written or
// repeats, so a poller sees the new count.
Seq int64 `json:"seq"`
// TS is when the line was first written.
TS time.Time `json:"ts"`
// Last is when it last repeated; absent for a line written once.
Last *time.Time `json:"last,omitempty"`
// Count is how many times in a row it was written; 1 for most lines.
Count int `json:"count"`
Level string `json:"level"`
Msg string `json:"msg"`
}
Line is one entry of the page's log.
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is one plugin's log. The zero value is ready to use and mirrors nothing to the server log.