mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-05-30 15:42:25 +00:00
📝 Polish onboarding and add feature examples
This commit is contained in:
+27
-4
@@ -29,13 +29,26 @@ BitLogger is designed to provide composable, configurable, and cross-target logg
|
||||
## Quick Start
|
||||
|
||||
```moonbit
|
||||
let logger = Logger::new(console_sink(), min_level=Level::Info, target="demo")
|
||||
.with_timestamp()
|
||||
.with_context_fields([field("service", "bitlogger")])
|
||||
let logger = build_logger(
|
||||
with_queue(
|
||||
text_console(
|
||||
min_level=Level::Info,
|
||||
target="demo",
|
||||
text_formatter=TextFormatterConfig::new(show_timestamp=false, separator=" | "),
|
||||
),
|
||||
max_pending=32,
|
||||
overflow=QueueOverflowPolicy::DropOldest,
|
||||
),
|
||||
)
|
||||
|
||||
logger.info("starting", fields=[field("port", "8080")])
|
||||
ignore(logger.flush())
|
||||
```
|
||||
|
||||
Start new synchronous code with `presets + build_logger(...)`: use `console(...)`, `json_console(...)`, `text_console(...)`, or `file(...)` to assemble `LoggerConfig`, optionally extend it with `with_queue(...)` or `with_file_rotation(...)`, then call `build_logger(...)`.
|
||||
|
||||
Switch to `Logger::new(...)` when you need direct runtime sink composition such as `fanout`, `split`, `callback`, or custom patch/filter graphs.
|
||||
|
||||
Async entry example:
|
||||
|
||||
```moonbit
|
||||
@@ -52,7 +65,13 @@ let logger = async_logger(console_sink(), target="async.demo")
|
||||
- `src/`: core logging package.
|
||||
- `src-async/`: async logging layer built on `moonbitlang/async`.
|
||||
- `docs/api/`: one-file-per-interface API documentation.
|
||||
- `examples/basic/`: minimal synchronous example.
|
||||
- `examples/basic/`: breadth example; starts with the recommended presets-based sync path and then sweeps broader capabilities.
|
||||
- `examples/console_basic/`: minimal console and JSON console output.
|
||||
- `examples/text_formatter/`: text formatter and template example.
|
||||
- `examples/style_tags/`: style tag and colored formatter example.
|
||||
- `examples/file_rotation/`: file sink and rotation example.
|
||||
- `examples/config_build/`: config-driven `build_logger(...)` example.
|
||||
- `examples/presets/`: presets-based construction example.
|
||||
- `examples/async_basic/`: async logger example.
|
||||
|
||||
## Documentation Entry Points
|
||||
@@ -60,11 +79,15 @@ let logger = async_logger(console_sink(), target="async.demo")
|
||||
- [Mooncake package page](https://mooncakes.io/docs/Nanaloveyuki/BitLogger)
|
||||
- [Chinese README](../README.md)
|
||||
- [src package README](../src/README.mbt.md)
|
||||
- Recommended sync starting APIs: `text_console(...)`, `file(...)`, `with_queue(...)`, `build_logger(...)`
|
||||
- Selected API docs in `docs/api/`:
|
||||
- [logger-new.md](./api/logger-new.md)
|
||||
- [async-logger.md](./api/async-logger.md)
|
||||
- [build-logger.md](./api/build-logger.md)
|
||||
- [build-async-logger.md](./api/build-async-logger.md)
|
||||
- [build-application-logger.md](./api/build-application-logger.md)
|
||||
- [build-library-logger.md](./api/build-library-logger.md)
|
||||
- [build-application-async-logger.md](./api/build-application-async-logger.md)
|
||||
|
||||
## Notes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user