mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-02-15 15:21:37 +00:00
Improved documentation
This commit is contained in:
parent
d01c2fb453
commit
8194bc43f4
@ -14,10 +14,10 @@ public sealed class TerminalLogger() : ConsoleFormatter(FORMATTER_NAME)
|
|||||||
|
|
||||||
private static RustService? RUST_SERVICE;
|
private static RustService? RUST_SERVICE;
|
||||||
|
|
||||||
// Buffer for early log events before RustService is available
|
// Buffer for early log events before the RustService is available:
|
||||||
private static readonly ConcurrentQueue<LogEventRequest> EARLY_LOG_BUFFER = new();
|
private static readonly ConcurrentQueue<LogEventRequest> EARLY_LOG_BUFFER = new();
|
||||||
|
|
||||||
// ANSI color codes for log levels
|
// ANSI color codes for log levels:
|
||||||
private const string ANSI_RESET = "\x1b[0m";
|
private const string ANSI_RESET = "\x1b[0m";
|
||||||
private const string ANSI_GRAY = "\x1b[90m"; // Trace, Debug
|
private const string ANSI_GRAY = "\x1b[90m"; // Trace, Debug
|
||||||
private const string ANSI_GREEN = "\x1b[32m"; // Information
|
private const string ANSI_GREEN = "\x1b[32m"; // Information
|
||||||
@ -32,7 +32,7 @@ public sealed class TerminalLogger() : ConsoleFormatter(FORMATTER_NAME)
|
|||||||
{
|
{
|
||||||
RUST_SERVICE = service;
|
RUST_SERVICE = service;
|
||||||
|
|
||||||
// Flush all buffered early log events to Rust in original order
|
// Flush all buffered early log events to Rust in the original order:
|
||||||
while (EARLY_LOG_BUFFER.TryDequeue(out var bufferedEvent))
|
while (EARLY_LOG_BUFFER.TryDequeue(out var bufferedEvent))
|
||||||
{
|
{
|
||||||
service.LogEvent(
|
service.LogEvent(
|
||||||
@ -72,15 +72,12 @@ public sealed class TerminalLogger() : ConsoleFormatter(FORMATTER_NAME)
|
|||||||
|
|
||||||
// Send log event to Rust via API (fire-and-forget):
|
// Send log event to Rust via API (fire-and-forget):
|
||||||
if (RUST_SERVICE is not null)
|
if (RUST_SERVICE is not null)
|
||||||
{
|
|
||||||
RUST_SERVICE.LogEvent(timestamp, logLevel, category, message, exceptionMessage, stackTrace);
|
RUST_SERVICE.LogEvent(timestamp, logLevel, category, message, exceptionMessage, stackTrace);
|
||||||
}
|
|
||||||
|
// Buffer early log events until the RustService is available:
|
||||||
else
|
else
|
||||||
{
|
|
||||||
// Buffer early log events until RustService is available
|
|
||||||
EARLY_LOG_BUFFER.Enqueue(new LogEventRequest(timestamp, logLevel, category, message, exceptionMessage, stackTrace));
|
EARLY_LOG_BUFFER.Enqueue(new LogEventRequest(timestamp, logLevel, category, message, exceptionMessage, stackTrace));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetColorForLogLevel(LogLevel logLevel) => logLevel switch
|
private static string GetColorForLogLevel(LogLevel logLevel) => logLevel switch
|
||||||
{
|
{
|
||||||
@ -90,6 +87,7 @@ public sealed class TerminalLogger() : ConsoleFormatter(FORMATTER_NAME)
|
|||||||
LogLevel.Warning => ANSI_YELLOW,
|
LogLevel.Warning => ANSI_YELLOW,
|
||||||
LogLevel.Error => ANSI_RED,
|
LogLevel.Error => ANSI_RED,
|
||||||
LogLevel.Critical => ANSI_RED,
|
LogLevel.Critical => ANSI_RED,
|
||||||
|
|
||||||
_ => ANSI_RESET
|
_ => ANSI_RESET
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -276,7 +276,6 @@ pub fn log_event(_token: APIToken, event: Json<LogEvent>) -> Json<LogEventRespon
|
|||||||
let message = event.message.as_str();
|
let message = event.message.as_str();
|
||||||
let category = event.category.as_str();
|
let category = event.category.as_str();
|
||||||
|
|
||||||
// Log with the parsed level
|
|
||||||
log_with_level(
|
log_with_level(
|
||||||
level,
|
level,
|
||||||
category,
|
category,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user