Skip to content

Commit a446e6a

Browse files
committed
chore: restructure repo layout
Signed-off-by: tison <wander4096@gmail.com>
1 parent 3e807b3 commit a446e6a

File tree

42 files changed

+434
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+434
-153
lines changed

.cargo/config.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2024 FastLabs Developers
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
[alias]
16+
x = "run --package x --"
17+
18+
[env]
19+
CARGO_WORKSPACE_DIR = { value = "", relative = true }

.github/workflows/ci.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@ jobs:
4747
- uses: taiki-e/install-action@v2
4848
with:
4949
tool: typos-cli,taplo-cli,hawkeye
50-
- name: Check all
51-
run: |
52-
hawkeye check
53-
taplo format --check
54-
typos
55-
cargo +nightly fmt --all -- --check
56-
cargo +nightly clippy --all-targets --all-features -- -D warnings
50+
- run: cargo x lint
5751

5852
msrv:
5953
name: Resolve MSRV
@@ -89,10 +83,9 @@ jobs:
8983
run: cargo build --workspace --all-features --bins --tests --examples --benches --lib
9084
- name: Run unit tests
9185
shell: bash
92-
run: cargo test --all-features -- --nocapture
86+
run: cargo x test --no-capture
9387
- name: Run examples
9488
shell: bash
95-
working-directory: logforth
9689
run: |
9790
set -x
9891
cargo run --features="bridge-log" --example simple_stdout

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
[workspace]
1616
members = [
1717
"core",
18+
"examples",
1819
"logforth",
1920
"appenders/*",
2021
"bridges/*",
2122
"diagnostics/*",
2223
"layouts/*",
24+
"xtask",
2325
]
2426
resolver = "2"
2527

@@ -34,6 +36,7 @@ rust-version = "1.85.0"
3436

3537
[workspace.dependencies]
3638
# Workspace dependencies
39+
logforth = { version = "0.29.1", path = "logforth" }
3740
logforth-append-async = { version = "0.3.0", path = "appenders/async" }
3841
logforth-append-fastrace = { version = "0.3.0", path = "appenders/fastrace" }
3942
logforth-append-file = { version = "0.3.0", path = "appenders/file" }
@@ -52,6 +55,7 @@ logforth-layout-text = { version = "0.3.0", path = "layouts/text" }
5255
# Crates.io dependencies
5356
anyhow = { version = "1.0" }
5457
arc-swap = { version = "1.7.1" }
58+
clap = { version = "4.5.49", features = ["derive"] }
5559
colored = { version = "3.0" }
5660
crossbeam-channel = { version = "0.5.15" }
5761
fastrace = { version = "0.7" }
@@ -71,9 +75,9 @@ serde_json = { version = "1.0" }
7175
tempfile = { version = "3.16" }
7276
tokio = { version = "1.47.1" }
7377
value-bag = { version = "1.11.1", features = ["inline-i128", "owned", "sval"] }
78+
which = { version = "8.0.0" }
7479

7580
[workspace.lints.rust]
76-
missing_docs = "deny"
7781
unknown_lints = "deny"
7882
unused_must_use = "deny"
7983

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fn main() {
9999
}
100100
```
101101

102-
Read more demos under the [examples](logforth/examples) directory.
102+
Read more demos under the [examples](examples) directory.
103103

104104
## Features
105105

appenders/async/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
This appender is a remix of [spdlog-rs's AsyncPoolSink](https://docs.rs/spdlog-rs/*/spdlog/sink/struct.AsyncPoolSink.html), with several modifications to fit this crate's need:
44

55
* Instead of a thread pool, it uses a single background thread to drain the log queue.
6+
* `flush` will block until all pending log messages are processed. This avoids the need of `Append::exit` we once added.

appenders/async/src/append.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@ use crate::state::AsyncState;
2727
use crate::worker::Worker;
2828

2929
/// A composable appender, logging and flushing asynchronously.
30+
///
31+
/// # Examples
32+
///
33+
/// ```
34+
/// use logforth_append_async::AsyncBuilder;
35+
/// use logforth_core::append::Stderr;
36+
///
37+
/// let async_append = AsyncBuilder::new("logforth-async-append")
38+
/// .overflow_drop_incoming()
39+
/// // for demonstration purposes; in practice, this can be a file appender, etc.
40+
/// .append(Stderr::default())
41+
/// .build();
42+
/// ```
43+
///
44+
/// # Caveats
45+
///
46+
/// The caller or application should ensure that the `flush` method is called before the program
47+
/// exits to write out any buffered events, especially when this appender is used in a global
48+
/// context.
49+
///
50+
/// The drop glue will also flush the appender. But, in Rust, static items do not call `drop`
51+
/// at the end of the program.
3052
#[derive(Debug)]
3153
pub struct Async {
3254
state: AsyncState,

appenders/async/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//! A composable appender, logging and flushing asynchronously.
1616
1717
#![cfg_attr(docsrs, feature(doc_cfg))]
18+
#![deny(missing_docs)]
1819

1920
use logforth_core::Error;
2021
use logforth_core::kv;

appenders/async/tests/flushes.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
//! Tests for asynchronous appenders wait on flushes.
16-
1715
use std::sync::Arc;
1816
use std::sync::Barrier;
1917
use std::sync::atomic::AtomicBool;

appenders/fastrace/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//! Appender for integrating with [fastrace](https://crates.io/crates/fastrace).
1616
1717
#![cfg_attr(docsrs, feature(doc_cfg))]
18+
#![deny(missing_docs)]
1819

1920
use std::borrow::Cow;
2021

@@ -42,10 +43,6 @@ use logforth_core::record::Record;
4243
/// The caller or application should ensure that the `flush` method or [`fastrace::flush`] is called
4344
/// before the program exits to collect the final events, especially when this appender is used
4445
/// in a global context.
45-
///
46-
/// Both the `exit` method and the drop glue do not call `fastrace::flush`, because it uses
47-
/// thread-local storage internally, which is not supported in `atexit` callbacks or arbitrary
48-
/// drop cases.
4946
#[derive(Default, Debug, Clone)]
5047
#[non_exhaustive]
5148
pub struct FastraceEvent {}

appenders/file/src/append.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ use crate::rolling::RollingFileWriterBuilder;
3131
use crate::rotation::Rotation;
3232

3333
/// A builder to configure and create an [`File`] appender.
34+
///
35+
/// See [module-level documentation](super) for usage examples.
3436
#[derive(Debug)]
3537
pub struct FileBuilder {
3638
builder: RollingFileWriterBuilder,

0 commit comments

Comments
 (0)