mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-07-24 00:42:18 +00:00
Compare commits
4 Commits
f4b161448c
...
4f532af026
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f532af026 | |||
| bee919a557 | |||
| d901bfd435 | |||
| d39d577c90 |
+149
-33
@@ -7,74 +7,190 @@ on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
moonbit:
|
||||
quality-matrix:
|
||||
name: Quality (${{ matrix.os }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup MoonBit (Linux/macOS)
|
||||
if: runner.os != 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
|
||||
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Setup MoonBit (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||||
irm https://cli.moonbitlang.com/install/powershell.ps1 | iex
|
||||
"$HOME/.moon/bin" | Out-File -FilePath $env:GITHUB_PATH -Append
|
||||
|
||||
- name: Setup MSYS2 toolchain (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: UCRT64
|
||||
update: true
|
||||
install: >-
|
||||
mingw-w64-ucrt-x86_64-gcc
|
||||
mingw-w64-ucrt-x86_64-openssl
|
||||
|
||||
- name: Show tool versions
|
||||
shell: bash
|
||||
run: |
|
||||
moon version --all
|
||||
|
||||
- name: Update Moon registry
|
||||
shell: bash
|
||||
run: |
|
||||
moon update
|
||||
|
||||
- name: Check formatting and exported interfaces
|
||||
shell: bash
|
||||
run: |
|
||||
moon fmt --check
|
||||
moon info
|
||||
git diff --exit-code
|
||||
|
||||
- name: Root checks and tests
|
||||
shell: bash
|
||||
run: |
|
||||
moon check --deny-warn
|
||||
moon test --deny-warn
|
||||
moon check --target native --deny-warn
|
||||
moon check --target wasm-gc --deny-warn
|
||||
moon check --target js --deny-warn
|
||||
|
||||
- name: Run sync example
|
||||
shell: bash
|
||||
run: |
|
||||
moon run examples/basic
|
||||
|
||||
- name: Check async example native
|
||||
if: runner.os != 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
moon check examples/async_basic --target native --deny-warn
|
||||
|
||||
async-cross-targets:
|
||||
name: Async cross-targets (Ubuntu)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install MoonBit
|
||||
- name: Setup MoonBit
|
||||
shell: bash
|
||||
run: |
|
||||
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
|
||||
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Show tool versions
|
||||
shell: bash
|
||||
run: |
|
||||
moon version
|
||||
moon version --all
|
||||
|
||||
- name: Update Moon registry
|
||||
shell: bash
|
||||
run: |
|
||||
moon update
|
||||
|
||||
- name: Check bitlogger
|
||||
- name: Check async package on wasm-gc and js
|
||||
shell: bash
|
||||
run: |
|
||||
moon check
|
||||
moon check src-async --target wasm-gc --deny-warn
|
||||
moon check src-async --target js --deny-warn
|
||||
|
||||
- name: Test bitlogger
|
||||
- name: Test async package on wasm-gc and js
|
||||
shell: bash
|
||||
run: |
|
||||
moon test
|
||||
moon test src-async --target wasm-gc --deny-warn
|
||||
moon test src-async --target js --deny-warn
|
||||
|
||||
- name: Check bitlogger native
|
||||
run: |
|
||||
moon check --target native
|
||||
async-native:
|
||||
name: Async native (${{ matrix.os }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
|
||||
- name: Check bitlogger wasm-gc
|
||||
run: |
|
||||
moon check --target wasm-gc
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check bitlogger js
|
||||
- name: Setup MoonBit
|
||||
shell: bash
|
||||
run: |
|
||||
moon check --target js
|
||||
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
|
||||
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Check bitlogger_async native
|
||||
- name: Show tool versions
|
||||
shell: bash
|
||||
run: |
|
||||
moon check src-async --target native
|
||||
moon version --all
|
||||
|
||||
- name: Check bitlogger_async wasm-gc
|
||||
- name: Update Moon registry
|
||||
shell: bash
|
||||
run: |
|
||||
moon check src-async --target wasm-gc
|
||||
moon update
|
||||
|
||||
- name: Check bitlogger_async js
|
||||
- name: Check async native path
|
||||
shell: bash
|
||||
run: |
|
||||
moon check src-async --target js
|
||||
moon check src-async --target native --deny-warn
|
||||
|
||||
- name: Test bitlogger_async native
|
||||
- name: Test async native path
|
||||
shell: bash
|
||||
run: |
|
||||
moon test src-async --target native
|
||||
moon test src-async --target native --deny-warn
|
||||
|
||||
- name: Test bitlogger_async wasm-gc
|
||||
run: |
|
||||
moon test src-async --target wasm-gc
|
||||
coverage:
|
||||
name: Coverage (Ubuntu)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
- name: Test bitlogger_async js
|
||||
run: |
|
||||
moon test src-async --target js
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Run basic example
|
||||
- name: Setup MoonBit
|
||||
shell: bash
|
||||
run: |
|
||||
moon run examples/basic
|
||||
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
|
||||
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Check async example native
|
||||
- name: Show tool versions
|
||||
shell: bash
|
||||
run: |
|
||||
moon check examples/async_basic --target native
|
||||
moon version --all
|
||||
|
||||
- name: Update Moon registry
|
||||
shell: bash
|
||||
run: |
|
||||
moon update
|
||||
|
||||
- name: Root coverage (default target)
|
||||
shell: bash
|
||||
run: |
|
||||
moon coverage clean
|
||||
moon test --deny-warn --enable-coverage
|
||||
moon coverage report -f summary
|
||||
moon coverage analyze
|
||||
|
||||
- name: Root coverage (native target)
|
||||
shell: bash
|
||||
run: |
|
||||
moon coverage clean
|
||||
moon test --deny-warn --target native --enable-coverage
|
||||
moon coverage report -f summary
|
||||
moon coverage analyze
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "Nanaloveyuki/BitLogger/examples/basic"
|
||||
|
||||
// Values
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "Nanaloveyuki/BitLogger/examples/config_build"
|
||||
|
||||
// Values
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "Nanaloveyuki/BitLogger/examples/console_basic"
|
||||
|
||||
// Values
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "Nanaloveyuki/BitLogger/examples/file_rotation"
|
||||
|
||||
// Values
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "Nanaloveyuki/BitLogger/examples/presets"
|
||||
|
||||
// Values
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "Nanaloveyuki/BitLogger/examples/style_tags"
|
||||
|
||||
// Values
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "Nanaloveyuki/BitLogger/examples/text_formatter"
|
||||
|
||||
// Values
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
|
||||
@@ -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 {
|
||||
@@ -1902,14 +1902,8 @@ async test "library async shutdown preserves wrapped failure cleanup semantics"
|
||||
inspect(full.last_error().contains("TestFlushError"), content="true")
|
||||
inspect(full.is_running(), content="false")
|
||||
inspect(writes.val, content="1")
|
||||
inspect(
|
||||
full.pending_count(),
|
||||
content=if async_runtime_supports_background_worker() { "0" } else { "1" },
|
||||
)
|
||||
inspect(
|
||||
full.dropped_count(),
|
||||
content=if async_runtime_supports_background_worker() { "1" } else { "0" },
|
||||
)
|
||||
inspect(full.pending_count(), content="0")
|
||||
inspect(full.dropped_count(), content="1")
|
||||
}
|
||||
|
||||
///|
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "Nanaloveyuki/BitLogger/src-async/utils"
|
||||
|
||||
import {
|
||||
"Nanaloveyuki/BitLogger/src/config_model",
|
||||
"maria/json_parser",
|
||||
}
|
||||
|
||||
// Values
|
||||
pub fn async_logger_build_config_to_json(AsyncLoggerBuildConfig) -> @json_parser.JsonValue
|
||||
|
||||
pub fn async_logger_config_to_json(AsyncLoggerConfig) -> @json_parser.JsonValue
|
||||
|
||||
pub fn async_logger_state_to_json(AsyncLoggerState) -> @json_parser.JsonValue
|
||||
|
||||
pub fn async_runtime_mode_label(AsyncRuntimeMode) -> String
|
||||
|
||||
pub fn async_runtime_state_to_json(AsyncRuntimeState) -> @json_parser.JsonValue
|
||||
|
||||
pub fn compatibility_async_runtime_mode() -> AsyncRuntimeMode
|
||||
|
||||
pub fn native_worker_async_runtime_mode() -> AsyncRuntimeMode
|
||||
|
||||
pub fn parse_async_logger_build_config_text(String) -> AsyncLoggerBuildConfig raise
|
||||
|
||||
pub fn parse_async_logger_config_text(String) -> AsyncLoggerConfig raise
|
||||
|
||||
pub fn stringify_async_logger_build_config(AsyncLoggerBuildConfig, pretty? : Bool) -> String
|
||||
|
||||
pub fn stringify_async_logger_config(AsyncLoggerConfig, pretty? : Bool) -> String
|
||||
|
||||
pub fn stringify_async_logger_state(AsyncLoggerState, pretty? : Bool) -> String
|
||||
|
||||
pub fn stringify_async_runtime_state(AsyncRuntimeState, pretty? : Bool) -> String
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
pub(all) enum AsyncFlushPolicy {
|
||||
Never
|
||||
Batch
|
||||
Shutdown
|
||||
}
|
||||
|
||||
pub(all) enum AsyncLifecyclePhase {
|
||||
Ready
|
||||
Running
|
||||
Failed
|
||||
Closing
|
||||
Closed
|
||||
ClosedFailed
|
||||
}
|
||||
|
||||
pub struct AsyncLoggerBuildConfig {
|
||||
logger : @config_model.LoggerConfig
|
||||
async_config : AsyncLoggerConfig
|
||||
}
|
||||
pub fn AsyncLoggerBuildConfig::new(logger? : @config_model.LoggerConfig, async_config? : AsyncLoggerConfig) -> Self
|
||||
|
||||
pub struct AsyncLoggerConfig {
|
||||
max_pending : Int
|
||||
overflow : AsyncOverflowPolicy
|
||||
max_batch : Int
|
||||
linger_ms : Int
|
||||
flush : AsyncFlushPolicy
|
||||
}
|
||||
pub fn AsyncLoggerConfig::new(max_pending? : Int, overflow? : AsyncOverflowPolicy, max_batch? : Int, linger_ms? : Int, flush? : AsyncFlushPolicy) -> Self
|
||||
|
||||
pub struct AsyncLoggerState {
|
||||
runtime : AsyncRuntimeState
|
||||
phase : AsyncLifecyclePhase
|
||||
pending_count : Int
|
||||
dropped_count : Int
|
||||
is_closed : Bool
|
||||
is_running : Bool
|
||||
has_failed : Bool
|
||||
backlog_retained : Bool
|
||||
can_rerun : Bool
|
||||
terminal : Bool
|
||||
last_error : String
|
||||
flush_policy : AsyncFlushPolicy
|
||||
}
|
||||
pub fn AsyncLoggerState::new(AsyncRuntimeState, AsyncLifecyclePhase, Int, Int, String, AsyncFlushPolicy) -> Self
|
||||
|
||||
pub(all) enum AsyncOverflowPolicy {
|
||||
Blocking
|
||||
DropOldest
|
||||
DropNewest
|
||||
}
|
||||
|
||||
pub enum AsyncRuntimeMode {
|
||||
NativeWorker
|
||||
Compatibility
|
||||
}
|
||||
|
||||
pub struct AsyncRuntimeState {
|
||||
mode : AsyncRuntimeMode
|
||||
background_worker : Bool
|
||||
}
|
||||
pub fn AsyncRuntimeState::new(AsyncRuntimeMode, Bool) -> Self
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "Nanaloveyuki/BitLogger/src/core"
|
||||
|
||||
// Values
|
||||
pub fn field(String, String) -> Field
|
||||
|
||||
pub fn fields(Array[(String, String)]) -> Array[Field]
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
pub struct Field {
|
||||
key : String
|
||||
value : String
|
||||
}
|
||||
pub fn Field::with_value(Self, String) -> Self
|
||||
|
||||
pub(all) enum Level {
|
||||
Trace
|
||||
Debug
|
||||
Info
|
||||
Warn
|
||||
Error
|
||||
}
|
||||
pub fn Level::enabled(Self, Self) -> Bool
|
||||
pub fn Level::label(Self) -> String
|
||||
pub fn Level::priority(Self) -> Int
|
||||
|
||||
pub struct Record {
|
||||
level : Level
|
||||
timestamp_ms : UInt64
|
||||
target : String
|
||||
message : String
|
||||
fields : Array[Field]
|
||||
}
|
||||
pub fn Record::copy(Self) -> Self
|
||||
pub fn Record::new(Level, String, timestamp_ms? : UInt64, target? : String, fields? : Array[Field]) -> Self
|
||||
pub fn Record::with_fields(Self, Array[Field]) -> Self
|
||||
pub fn Record::with_message(Self, String) -> Self
|
||||
pub fn Record::with_target(Self, String) -> Self
|
||||
|
||||
// Type aliases
|
||||
|
||||
// Traits
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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~)
|
||||
}
|
||||
|
||||
|
||||
@@ -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\"}",
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
// Generated using `moon info`, DON'T EDIT IT
|
||||
package "Nanaloveyuki/BitLogger/src/utils"
|
||||
|
||||
import {
|
||||
"Nanaloveyuki/BitLogger/src/core",
|
||||
"Nanaloveyuki/BitLogger/src/formatting",
|
||||
}
|
||||
|
||||
// Values
|
||||
pub fn all_of(Array[(@core.Record) -> Bool]) -> (@core.Record) -> Bool
|
||||
|
||||
pub fn any_of(Array[(@core.Record) -> Bool]) -> (@core.Record) -> Bool
|
||||
|
||||
pub fn append_fields(Array[@core.Field]) -> (@core.Record) -> @core.Record
|
||||
|
||||
pub fn close_file_handle_internal(FileHandle) -> Bool
|
||||
|
||||
pub fn color_mode_label(@formatting.ColorMode) -> String
|
||||
|
||||
pub fn color_support_label(@formatting.ColorSupport) -> String
|
||||
|
||||
pub fn compose_patches(Array[(@core.Record) -> @core.Record]) -> (@core.Record) -> @core.Record
|
||||
|
||||
pub fn default_style_tag_registry() -> @formatting.StyleTagRegistry
|
||||
|
||||
pub fn field_equals(String, String) -> (@core.Record) -> Bool
|
||||
|
||||
pub fn file_size_i64_internal(FileHandle) -> Int64
|
||||
|
||||
pub fn flush_file_handle_internal(FileHandle) -> Bool
|
||||
|
||||
pub fn format_json(@core.Record) -> String
|
||||
|
||||
pub fn format_text(@core.Record, formatter? : @formatting.TextFormatter) -> String
|
||||
|
||||
pub fn global_style_tag_registry() -> @formatting.StyleTagRegistry
|
||||
|
||||
pub fn has_field(String) -> (@core.Record) -> Bool
|
||||
|
||||
pub fn identity_patch() -> (@core.Record) -> @core.Record
|
||||
|
||||
pub fn level_at_least(@core.Level) -> (@core.Record) -> Bool
|
||||
|
||||
pub fn message_contains(String) -> (@core.Record) -> Bool
|
||||
|
||||
pub fn native_files_supported_internal() -> Bool
|
||||
|
||||
pub fn not_((@core.Record) -> Bool) -> (@core.Record) -> Bool
|
||||
|
||||
pub fn open_file_handle_internal(String, Bool) -> FileHandle?
|
||||
|
||||
pub fn prefix_message(String) -> (@core.Record) -> @core.Record
|
||||
|
||||
pub fn redact_field(String, placeholder? : String) -> (@core.Record) -> @core.Record
|
||||
|
||||
pub fn redact_fields(Array[String], placeholder? : String) -> (@core.Record) -> @core.Record
|
||||
|
||||
pub fn remove_file_internal(String) -> Bool
|
||||
|
||||
pub fn rename_file_internal(String, String) -> Bool
|
||||
|
||||
pub fn reset_global_style_tag_registry() -> Unit
|
||||
|
||||
pub fn set_global_style_tag_registry(@formatting.StyleTagRegistry) -> Unit
|
||||
|
||||
pub fn set_target(String) -> (@core.Record) -> @core.Record
|
||||
|
||||
pub fn string_byte_length_internal(String) -> Int
|
||||
|
||||
pub fn style_markup_mode_label(@formatting.StyleMarkupMode) -> String
|
||||
|
||||
pub fn style_tag_registry() -> @formatting.StyleTagRegistry
|
||||
|
||||
pub fn target_has_prefix(String) -> (@core.Record) -> Bool
|
||||
|
||||
pub fn target_is(String) -> (@core.Record) -> Bool
|
||||
|
||||
pub fn text_formatter(show_timestamp? : Bool, show_level? : Bool, show_target? : Bool, show_fields? : Bool, separator? : String, field_separator? : String, template? : String, color_mode? : @formatting.ColorMode, color_support? : @formatting.ColorSupport, style_markup? : @formatting.StyleMarkupMode, target_style_markup? : @formatting.StyleMarkupMode, fields_style_markup? : @formatting.StyleMarkupMode, style_tags? : @formatting.StyleTagRegistry?) -> @formatting.TextFormatter
|
||||
|
||||
pub fn text_style(fg? : String?, bg? : String?, bold? : Bool, dim? : Bool, italic? : Bool, underline? : Bool) -> @formatting.TextStyle
|
||||
|
||||
pub fn write_file_handle_internal(FileHandle, String) -> Bool
|
||||
|
||||
// Errors
|
||||
|
||||
// Types and methods
|
||||
pub struct FileHandle {
|
||||
path : String
|
||||
}
|
||||
|
||||
// Type aliases
|
||||
pub using @formatting {type ColorMode}
|
||||
|
||||
pub using @formatting {type ColorSupport}
|
||||
|
||||
pub type RecordFormatter = (@core.Record) -> String
|
||||
|
||||
pub type RecordPatch = (@core.Record) -> @core.Record
|
||||
|
||||
pub type RecordPredicate = (@core.Record) -> Bool
|
||||
|
||||
pub using @formatting {type StyleMarkupMode}
|
||||
|
||||
pub using @formatting {type StyleTagRegistry}
|
||||
|
||||
pub using @formatting {type TextFormatter}
|
||||
|
||||
pub using @formatting {type TextStyle}
|
||||
|
||||
// Traits
|
||||
|
||||
Reference in New Issue
Block a user