Implements Phases 1-8 of the TFTSR implementation plan. Rust backend (Tauri 2.x, src-tauri/): - Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama - PII detection engine: 11 regex patterns with overlap resolution - SQLCipher AES-256 encrypted database with 10 versioned migrations - 28 Tauri IPC commands for triage, analysis, document, and system ops - Ollama: hardware probe, model recommendations, pull/delete with events - RCA and blameless post-mortem Markdown document generators - PDF export via printpdf - Audit log: SHA-256 hash of every external data send - Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2) Frontend (React 18 + TypeScript + Vite, src/): - 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings - 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives - 3 Zustand stores: session, settings (persisted), history - Type-safe tauriCommands.ts matching Rust backend types exactly - 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs) DevOps: - .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push - .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload Verified: - cargo check: zero errors - tsc --noEmit: zero errors - vitest run: 13/13 unit tests passing Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
5.5 KiB
loglevel-plugin-prefix
Plugin for loglevel message prefixing.
Installation
npm install loglevel-plugin-prefix
API
This plugin is under active development and should be considered as an unstable. No guarantees regarding API stability are made. Backward compatibility is guaranteed only by path releases.
reg(loglevel)
This method registers plugin for loglevel. This method must be called at least once before any call to the apply method. Repeated calls to this method are ignored.
Parameters
loglevel - the root logger, imported from loglevel module
apply(logger, options)
This method applies the plugin to the logger. Before using this method, the reg method must be called, otherwise a warning will be logged. From the next release, the call apply before reg will throw an error.
Parameters
logger - any logger of loglevel
options - an optional configuration object
var defaults = {
template: '[%t] %l:',
levelFormatter: function (level) {
return level.toUpperCase();
},
nameFormatter: function (name) {
return name || 'root';
},
timestampFormatter: function (date) {
return date.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, '$1');
},
format: undefined
};
Plugin formats the prefix using template option as a printf-like format. The template is a string containing zero or more placeholder tokens. Each placeholder token is replaced with the value from loglevel messages parameters. Supported placeholders are:
%l- level of message%n- name of logger%t- timestamp of message
The levelFormatter, nameFormatter and timestampFormatter is a functions for formatting corresponding values.
Alternatively, you can use format option. This is a function that receives formatted values (level, name, timestamp) and should returns a prefix string.
If both format and template are present in the configuration, the template parameter is ignored. When both these parameters are missing in the configuration, the inherited behavior is used.
Usage
Browser directly
<script src="https://unpkg.com/loglevel/dist/loglevel.min.js"></script>
<script src="https://unpkg.com/loglevel-plugin-prefix@^0.8/dist/loglevel-plugin-prefix.min.js"></script>
<script>
var logger = log.noConflict();
var prefixer = prefix.noConflict();
prefixer.reg(logger);
prefixer.apply(logger);
logger.warn('prefixed message');
</script>
Output
[16:53:46] WARN: prefixed message
Node
const chalk = require('chalk');
const log = require('loglevel');
const prefix = require('loglevel-plugin-prefix');
const colors = {
TRACE: chalk.magenta,
DEBUG: chalk.cyan,
INFO: chalk.blue,
WARN: chalk.yellow,
ERROR: chalk.red,
};
prefix.reg(log);
log.enableAll();
prefix.apply(log, {
format(level, name, timestamp) {
return `${chalk.gray(`[${timestamp}]`)} ${colors[level.toUpperCase()](level)} ${chalk.green(`${name}:`)}`;
},
});
prefix.apply(log.getLogger('critical'), {
format(level, name, timestamp) {
return chalk.red.bold(`[${timestamp}] ${level} ${name}:`);
},
});
log.trace('trace');
log.debug('debug');
log.getLogger('critical').info('Something significant happened');
log.log('log');
log.info('info');
log.warn('warn');
log.error('error');
Output
Custom options
const log = require('loglevel');
const prefix = require('loglevel-plugin-prefix');
prefix.reg(log);
log.enableAll();
prefix.apply(log, {
template: '[%t] %l (%n) static text:',
levelFormatter(level) {
return level.toUpperCase();
},
nameFormatter(name) {
return name || 'global';
},
timestampFormatter(date) {
return date.toISOString();
},
});
log.info('%s prefix', 'template');
const fn = (level, name, timestamp) => `[${timestamp}] ${level} (${name}) static text:`;
prefix.apply(log, { format: fn });
log.info('%s prefix', 'functional');
prefix.apply(log, { template: '[%t] %l (%n) static text:' });
log.info('again %s prefix', 'template');
Output
[2017-05-29T12:53:46.000Z] INFO (global) static text: template prefix
[2017-05-29T12:53:46.000Z] INFO (global) static text: functional prefix
[2017-05-29T12:53:46.000Z] INFO (global) static text: again template prefix
Option inheritance
const log = require('loglevel');
const prefix = require('loglevel-plugin-prefix');
prefix.reg(log);
log.enableAll();
log.info('root');
const chicken = log.getLogger('chicken');
chicken.info('chicken');
prefix.apply(chicken, { template: '%l (%n):' });
chicken.info('chicken');
prefix.apply(log);
log.info('root');
const egg = log.getLogger('egg');
egg.info('egg');
const fn = (level, name) => `${level} (${name}):`;
prefix.apply(egg, { format: fn });
egg.info('egg');
prefix.apply(egg, {
levelFormatter(level) {
return level.toLowerCase();
},
});
egg.info('egg');
chicken.info('chicken');
log.info('root');
Output
root
chicken
INFO (chicken): chicken
[16:53:46] INFO: root
[16:53:46] INFO: egg
INFO (egg): egg
info (egg): egg
INFO (chicken): chicken
[16:53:46] INFO: root
