mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 15:42:25 +00:00
235 lines
6.6 KiB
MoonBit
235 lines
6.6 KiB
MoonBit
pub(all) suberror AsyncLoggerClosed {
|
|
AsyncLoggerClosed
|
|
}
|
|
|
|
pub(all) enum AsyncOverflowPolicy {
|
|
Blocking
|
|
DropOldest
|
|
DropNewest
|
|
}
|
|
|
|
pub(all) enum AsyncFlushPolicy {
|
|
Never
|
|
Batch
|
|
Shutdown
|
|
}
|
|
|
|
pub struct AsyncLoggerConfig {
|
|
max_pending : Int
|
|
overflow : AsyncOverflowPolicy
|
|
max_batch : Int
|
|
linger_ms : Int
|
|
flush : AsyncFlushPolicy
|
|
}
|
|
|
|
pub fn AsyncLoggerConfig::new(
|
|
max_pending~ : Int = 0,
|
|
overflow~ : AsyncOverflowPolicy = AsyncOverflowPolicy::Blocking,
|
|
max_batch~ : Int = 1,
|
|
linger_ms~ : Int = 0,
|
|
flush~ : AsyncFlushPolicy = AsyncFlushPolicy::Never,
|
|
) -> AsyncLoggerConfig {
|
|
{
|
|
max_pending,
|
|
overflow,
|
|
max_batch: if max_batch <= 1 { 1 } else { max_batch },
|
|
linger_ms: if linger_ms < 0 { 0 } else { linger_ms },
|
|
flush,
|
|
}
|
|
}
|
|
|
|
pub struct AsyncLogger[S] {}
|
|
|
|
pub struct AsyncLoggerBuildConfig {
|
|
logger : @bitlogger.LoggerConfig
|
|
async_config : AsyncLoggerConfig
|
|
}
|
|
|
|
pub fn AsyncLoggerBuildConfig::new(
|
|
logger~ : @bitlogger.LoggerConfig = @bitlogger.default_logger_config(),
|
|
async_config~ : AsyncLoggerConfig = AsyncLoggerConfig::new(),
|
|
) -> AsyncLoggerBuildConfig {
|
|
{ logger, async_config }
|
|
}
|
|
|
|
pub fn parse_async_logger_build_config_text(input : String) -> AsyncLoggerBuildConfig raise {
|
|
ignore(input)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn parse_async_logger_config_text(input : String) -> AsyncLoggerConfig raise {
|
|
ignore(input)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn async_logger_config_to_json(config : AsyncLoggerConfig) -> @json_parser.JsonValue {
|
|
ignore(config)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn stringify_async_logger_config(config : AsyncLoggerConfig, pretty~ : Bool = false) -> String {
|
|
ignore(config)
|
|
ignore(pretty)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn async_logger_build_config_to_json(
|
|
config : AsyncLoggerBuildConfig,
|
|
) -> @json_parser.JsonValue {
|
|
ignore(config)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn stringify_async_logger_build_config(
|
|
config : AsyncLoggerBuildConfig,
|
|
pretty~ : Bool = false,
|
|
) -> String {
|
|
ignore(config)
|
|
ignore(pretty)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn async_logger[S : @bitlogger.Sink](
|
|
sink : S,
|
|
config~ : AsyncLoggerConfig = AsyncLoggerConfig::new(),
|
|
min_level~ : @bitlogger.Level = @bitlogger.Level::Info,
|
|
target~ : String = "",
|
|
flush~ : (S) -> Int = fn(_) { 0 },
|
|
) -> AsyncLogger[S] {
|
|
ignore(sink)
|
|
ignore(config)
|
|
ignore(min_level)
|
|
ignore(target)
|
|
ignore(flush)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::with_timestamp(self : AsyncLogger[S], enabled~ : Bool = true) -> AsyncLogger[S] {
|
|
ignore(self)
|
|
ignore(enabled)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::with_target(self : AsyncLogger[S], target : String) -> AsyncLogger[S] {
|
|
ignore(self)
|
|
ignore(target)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::with_context_fields(
|
|
self : AsyncLogger[S],
|
|
fields : Array[@bitlogger.Field],
|
|
) -> AsyncLogger[S] {
|
|
ignore(self)
|
|
ignore(fields)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::with_filter(
|
|
self : AsyncLogger[S],
|
|
predicate : (@bitlogger.Record) -> Bool,
|
|
) -> AsyncLogger[S] {
|
|
ignore(self)
|
|
ignore(predicate)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::with_patch(
|
|
self : AsyncLogger[S],
|
|
patch : @bitlogger.RecordPatch,
|
|
) -> AsyncLogger[S] {
|
|
ignore(self)
|
|
ignore(patch)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::with_min_level(
|
|
self : AsyncLogger[S],
|
|
min_level : @bitlogger.Level,
|
|
) -> AsyncLogger[S] {
|
|
ignore(self)
|
|
ignore(min_level)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::child(self : AsyncLogger[S], target : String) -> AsyncLogger[S] {
|
|
ignore(self)
|
|
ignore(target)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::is_enabled(self : AsyncLogger[S], level : @bitlogger.Level) -> Bool {
|
|
ignore(self)
|
|
ignore(level)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::pending_count(self : AsyncLogger[S]) -> Int {
|
|
ignore(self)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::dropped_count(self : AsyncLogger[S]) -> Int {
|
|
ignore(self)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::is_closed(self : AsyncLogger[S]) -> Bool {
|
|
ignore(self)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::is_running(self : AsyncLogger[S]) -> Bool {
|
|
ignore(self)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::has_failed(self : AsyncLogger[S]) -> Bool {
|
|
ignore(self)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::last_error(self : AsyncLogger[S]) -> String {
|
|
ignore(self)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::flush_policy(self : AsyncLogger[S]) -> AsyncFlushPolicy {
|
|
ignore(self)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn[S] AsyncLogger::close(self : AsyncLogger[S], clear? : Bool = false) -> Unit {
|
|
ignore(self)
|
|
ignore(clear)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub async fn[S] AsyncLogger::wait_idle(self : AsyncLogger[S]) -> Unit {
|
|
ignore(self)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub async fn[S] AsyncLogger::shutdown(self : AsyncLogger[S], clear? : Bool = false) -> Unit {
|
|
ignore(self)
|
|
ignore(clear)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub async fn[S : @bitlogger.Sink] AsyncLogger::run(self : AsyncLogger[S]) -> Unit {
|
|
ignore(self)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn build_async_logger(
|
|
config : AsyncLoggerBuildConfig,
|
|
) -> AsyncLogger[@bitlogger.RuntimeSink] {
|
|
ignore(config)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|
|
|
|
pub fn build_async_text_logger(config : AsyncLoggerBuildConfig) -> AsyncLogger[@bitlogger.FormattedConsoleSink] {
|
|
ignore(config)
|
|
abort("bitlogger_async currently only supports native/llvm backends")
|
|
}
|