🧹 apply moon fmt and async mbti refresh

This commit is contained in:
Nanaloveyuki
2026-07-08 12:17:31 +08:00
parent d901bfd435
commit bee919a557
7 changed files with 40 additions and 43 deletions
+1 -1
View File
@@ -190,7 +190,7 @@ async test "run rejects duplicate worker startup for same logger" {
@async.pause()
}
let second_error = (async fn() -> String raise {
let second_error = (async fn() -> String {
logger.run()
"no error"
})() catch {
+3 -3
View File
@@ -180,9 +180,9 @@ pub fn[S] async_logger(
///|
fn async_logger_phase_is_closed(phase : AsyncLifecyclePhase) -> Bool {
match phase {
AsyncLifecyclePhase::Closing |
AsyncLifecyclePhase::Closed |
AsyncLifecyclePhase::ClosedFailed => true
AsyncLifecyclePhase::Closing
| AsyncLifecyclePhase::Closed
| AsyncLifecyclePhase::ClosedFailed => true
_ => false
}
}
+14 -13
View File
@@ -2,9 +2,10 @@
package "Nanaloveyuki/BitLogger/src-async"
import {
"Nanaloveyuki/BitLogger/src",
"Nanaloveyuki/BitLogger/src-async/utils",
"Nanaloveyuki/BitLogger/src/core",
"Nanaloveyuki/BitLogger/src/runtime",
"Nanaloveyuki/BitLogger/src/sink_graph",
"maria/json_parser",
"moonbitlang/async/aqueue",
"moonbitlang/core/ref",
@@ -29,21 +30,21 @@ pub fn async_runtime_state_to_json(@utils.AsyncRuntimeState) -> @json_parser.Jso
pub fn async_runtime_supports_background_worker() -> Bool
pub fn build_application_async_logger(@utils.AsyncLoggerBuildConfig) -> AsyncLogger[@src.RuntimeSink]
pub fn build_application_async_logger(@utils.AsyncLoggerBuildConfig) -> AsyncLogger[@runtime.RuntimeSink]
pub fn build_application_text_async_logger(@utils.AsyncLoggerBuildConfig) -> AsyncLogger[@src.FormattedConsoleSink]
pub fn build_application_text_async_logger(@utils.AsyncLoggerBuildConfig) -> AsyncLogger[@sink_graph.FormattedConsoleSink]
pub fn build_async_logger(@utils.AsyncLoggerBuildConfig) -> AsyncLogger[@src.RuntimeSink]
pub fn build_async_logger(@utils.AsyncLoggerBuildConfig) -> AsyncLogger[@runtime.RuntimeSink]
pub fn build_async_text_logger(@utils.AsyncLoggerBuildConfig) -> AsyncLogger[@src.FormattedConsoleSink]
pub fn build_async_text_logger(@utils.AsyncLoggerBuildConfig) -> AsyncLogger[@sink_graph.FormattedConsoleSink]
pub fn build_library_async_logger(@utils.AsyncLoggerBuildConfig) -> LibraryAsyncLogger[@src.RuntimeSink]
pub fn build_library_async_logger(@utils.AsyncLoggerBuildConfig) -> LibraryAsyncLogger[@runtime.RuntimeSink]
pub fn build_library_async_text_logger(@utils.AsyncLoggerBuildConfig) -> LibraryAsyncLogger[@src.FormattedConsoleSink]
pub fn build_library_async_text_logger(@utils.AsyncLoggerBuildConfig) -> LibraryAsyncLogger[@sink_graph.FormattedConsoleSink]
pub fn parse_and_build_application_async_logger(String) -> AsyncLogger[@src.RuntimeSink] raise
pub fn parse_and_build_application_async_logger(String) -> AsyncLogger[@runtime.RuntimeSink] raise
pub fn parse_and_build_library_async_logger(String) -> LibraryAsyncLogger[@src.RuntimeSink] raise
pub fn parse_and_build_library_async_logger(String) -> LibraryAsyncLogger[@runtime.RuntimeSink] raise
pub fn parse_async_logger_build_config_text(String) -> @utils.AsyncLoggerBuildConfig raise
@@ -101,7 +102,7 @@ pub fn[S] AsyncLogger::last_error(Self[S]) -> String
pub async fn[S] AsyncLogger::log(Self[S], @core.Level, String, fields? : Array[@core.Field], target? : String) -> Unit
pub fn[S] AsyncLogger::pending_count(Self[S]) -> Int
pub fn[S] AsyncLogger::phase(Self[S]) -> @utils.AsyncLifecyclePhase
pub async fn[S : @src.Sink] AsyncLogger::run(Self[S]) -> Unit
pub async fn[S : @sink_graph.Sink] AsyncLogger::run(Self[S]) -> Unit
pub async fn[S] AsyncLogger::shutdown(Self[S], clear? : Bool) -> Unit
pub fn[S] AsyncLogger::state(Self[S]) -> @utils.AsyncLoggerState
pub fn[S] AsyncLogger::to_library_async_logger(Self[S]) -> LibraryAsyncLogger[S]
@@ -125,7 +126,7 @@ pub async fn[S] LibraryAsyncLogger::info(Self[S], String, fields? : Array[@core.
pub fn[S] LibraryAsyncLogger::is_enabled(Self[S], @core.Level) -> Bool
pub async fn[S] LibraryAsyncLogger::log(Self[S], @core.Level, String, fields? : Array[@core.Field], target? : String) -> Unit
pub fn[S] LibraryAsyncLogger::new(S, config? : @utils.AsyncLoggerConfig, min_level? : @core.Level, target? : String, flush? : (S) -> Unit raise) -> Self[S]
pub async fn[S : @src.Sink] LibraryAsyncLogger::run(Self[S]) -> Unit
pub async fn[S : @sink_graph.Sink] LibraryAsyncLogger::run(Self[S]) -> Unit
pub async fn[S] LibraryAsyncLogger::shutdown(Self[S], clear? : Bool) -> Unit
pub fn[S] LibraryAsyncLogger::to_async_logger(Self[S]) -> AsyncLogger[S]
pub async fn[S] LibraryAsyncLogger::warn(Self[S], String, fields? : Array[@core.Field]) -> Unit
@@ -133,9 +134,9 @@ pub fn[S] LibraryAsyncLogger::with_context_fields(Self[S], Array[@core.Field]) -
pub fn[S] LibraryAsyncLogger::with_target(Self[S], String) -> Self[S]
// Type aliases
pub type ApplicationAsyncLogger = AsyncLogger[@src.RuntimeSink]
pub type ApplicationAsyncLogger = AsyncLogger[@runtime.RuntimeSink]
pub type ApplicationTextAsyncLogger = AsyncLogger[@src.FormattedConsoleSink]
pub type ApplicationTextAsyncLogger = AsyncLogger[@sink_graph.FormattedConsoleSink]
pub using @utils {type AsyncFlushPolicy}
+4 -6
View File
@@ -75,9 +75,9 @@ fn async_lifecycle_phase_label(phase : AsyncLifecyclePhase) -> String {
///|
fn async_lifecycle_phase_is_closed(phase : AsyncLifecyclePhase) -> Bool {
match phase {
AsyncLifecyclePhase::Closing |
AsyncLifecyclePhase::Closed |
AsyncLifecyclePhase::ClosedFailed => true
AsyncLifecyclePhase::Closing
| AsyncLifecyclePhase::Closed
| AsyncLifecyclePhase::ClosedFailed => true
_ => false
}
}
@@ -203,9 +203,7 @@ fn async_logger_state_to_json_value(
"is_closed": @json_parser.JsonValue::Bool(state.is_closed),
"is_running": @json_parser.JsonValue::Bool(state.is_running),
"has_failed": @json_parser.JsonValue::Bool(state.has_failed),
"backlog_retained": @json_parser.JsonValue::Bool(
state.backlog_retained,
),
"backlog_retained": @json_parser.JsonValue::Bool(state.backlog_retained),
"can_rerun": @json_parser.JsonValue::Bool(state.can_rerun),
"terminal": @json_parser.JsonValue::Bool(state.terminal),
"last_error": @json_parser.JsonValue::String(state.last_error),
+3 -9
View File
@@ -128,9 +128,7 @@ pub fn Logger::file_rotation_failures(self : Logger[RuntimeSink]) -> Int {
}
///|
pub fn Logger::file_reset_failure_counters(
self : Logger[RuntimeSink],
) -> Bool {
pub fn Logger::file_reset_failure_counters(self : Logger[RuntimeSink]) -> Bool {
@runtime.RuntimeSink::file_reset_failure_counters(self.sink)
}
@@ -166,16 +164,12 @@ pub fn Logger::file_default_policy(
}
///|
pub fn Logger::file_policy_matches_default(
self : Logger[RuntimeSink],
) -> Bool {
pub fn Logger::file_policy_matches_default(self : Logger[RuntimeSink]) -> Bool {
@runtime.RuntimeSink::file_policy_matches_default(self.sink)
}
///|
pub fn Logger::file_state_or_none(
self : Logger[RuntimeSink],
) -> FileSinkState? {
pub fn Logger::file_state_or_none(self : Logger[RuntimeSink]) -> FileSinkState? {
@runtime.RuntimeSink::file_state_or_none(self.sink)
}
+1 -4
View File
@@ -46,10 +46,7 @@ pub fn Logger::drain_progress(
}
///|
pub fn Logger::drain(
self : Logger[RuntimeSink],
max_items? : Int = -1,
) -> Int {
pub fn Logger::drain(self : Logger[RuntimeSink], max_items? : Int = -1) -> Int {
@runtime.RuntimeSink::drain(self.sink, max_items~)
}
+14 -7
View File
@@ -1,9 +1,12 @@
///|
test "text formatter can customize visible parts" {
let rec = Record::new(Level::Info, "hello", timestamp_ms=123UL, target="svc.api", fields=[
field("user", "alice"),
field("request_id", "42"),
])
let rec = Record::new(
Level::Info,
"hello",
timestamp_ms=123UL,
target="svc.api",
fields=[field("user", "alice"), field("request_id", "42")],
)
let compact = text_formatter(
show_timestamp=false,
show_target=false,
@@ -458,9 +461,13 @@ test "formatted callback sink receives rendered text" {
///|
test "json formatter keeps structured shape" {
let rec = Record::new(Level::Error, "failed", timestamp_ms=55UL, target="svc", fields=[
field("code", "500"),
])
let rec = Record::new(
Level::Error,
"failed",
timestamp_ms=55UL,
target="svc",
fields=[field("code", "500")],
)
inspect(
format_json(rec),
content="{\"level\":\"ERROR\",\"message\":\"failed\",\"fields\":{\"code\":\"500\"},\"timestamp_ms\":\"55\",\"target\":\"svc\"}",