Skip to content

Commit 141a262

Browse files
authored
feat: switch to tracing ecosystem (#379)
* feat: switch to tracing ecosystem Signed-off-by: Alex Chi <iskyzh@gmail.com> * feat(tracing): switch to tokio-tracing ecosystem Signed-off-by: Alex Chi <iskyzh@gmail.com> * remove unused deps Signed-off-by: Alex Chi <iskyzh@gmail.com>
1 parent 8e92486 commit 141a262

File tree

14 files changed

+127
-11
lines changed

14 files changed

+127
-11
lines changed

Cargo.lock

Lines changed: 103 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ csv = "1"
2727
dirs = "4"
2828
downcast-rs = "1"
2929
enum_dispatch = "0.3"
30-
env_logger = "0.9"
3130
erased-serde = "0.3"
3231
futures = { version = "0.3", default-features = false, features = ["alloc"] }
3332
futures-async-stream = { git = "https://github.com/taiki-e/futures-async-stream", rev = "944f407" }
3433
indicatif = { version = "0.16" }
3534
iter-chunks = "0.1"
3635
itertools = "0.10"
37-
log = "0.4"
3836
moka = { version = "0.6", features = ["future"] }
3937
num-traits = "0.2"
4038
parking_lot = "0.11"
@@ -51,9 +49,12 @@ sqlparser = { git = "https://github.com/risinglightdb/sqlparser-rs", rev = "edea
5149
thiserror = "1"
5250
tikv-jemallocator = { version = "0.4", optional = true }
5351
tokio = { version = "1", features = ["full"] }
52+
tracing = "0.1"
53+
tracing-subscriber = { version = "0.3", features = ["env-filter", "parking_lot"] }
5454

5555
[dev-dependencies]
5656
criterion = { version = "0.3", features = ["async_tokio"] }
57+
env_logger = "0.9"
5758
tempfile = "3"
5859
test-case = "1"
5960

docs/00-develop.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ It is recommended to use VSCode with [rust-analyzer][rust-analyzer] extension to
5757
`rust-analyzer` extension in VSCode, and everything will be set for you. Note that `rust-analyzer` conflicts with
5858
the official Rust extension. You will need to uninstall "The Rust Programming Language" extension before proceeding.
5959

60-
To enable logs for RisingLight, export the following environment variable to your shell environment.
60+
To enable debug logs for RisingLight, export the following environment variable to your shell environment.
6161

6262
```
63-
export RUST_LOG=info
63+
export RUST_LOG=debug
6464
```
6565

6666
If you want to contribute to the RisingLight project, refer to [Contributing to RisingLight](../CONTRIBUTING.md) docs

src/db.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::sync::Arc;
44

55
use futures::TryStreamExt;
66
use risinglight_proto::rowset::block_statistics::BlockStatisticsType;
7+
use tracing::debug;
78

89
use crate::array::{ArrayBuilder, ArrayBuilderImpl, DataChunk, I32ArrayBuilder, Utf8ArrayBuilder};
910
use crate::binder::{BindError, Binder};

src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
#![feature(generators)]
1313
#![feature(backtrace)]
1414

15-
// Enable macros for logging.
16-
#[macro_use]
17-
extern crate log;
18-
1915
/// Top-level structure of the database.
2016
pub mod db;
2117

src/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ use std::sync::Mutex;
77

88
use anyhow::{anyhow, Result};
99
use clap::Parser;
10-
use log::{info, warn};
1110
use risinglight::array::{datachunk_to_sqllogictest_string, DataChunk};
1211
use risinglight::storage::SecondaryStorageOptions;
1312
use risinglight::Database;
1413
use rustyline::error::ReadlineError;
1514
use rustyline::Editor;
15+
use tracing::{info, warn, Level};
16+
use tracing_subscriber::prelude::*;
1617

1718
/// RisingLight: an OLAP database system.
1819
#[derive(Parser, Debug)]
@@ -149,7 +150,14 @@ async fn run_sqllogictest(db: Database, path: &str) -> Result<()> {
149150
async fn main() -> Result<()> {
150151
let args = Args::parse();
151152

152-
env_logger::init();
153+
let fmt_layer = tracing_subscriber::fmt::layer().compact();
154+
let filter_layer =
155+
tracing_subscriber::EnvFilter::from_default_env().add_directive(Level::INFO.into());
156+
157+
tracing_subscriber::registry()
158+
.with(filter_layer)
159+
.with(fmt_layer)
160+
.init();
153161

154162
let db = if args.memory {
155163
info!("using memory engine");

src/storage/memory/transaction.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::sync::Arc;
55

66
use async_trait::async_trait;
77
use itertools::Itertools;
8+
use tracing::warn;
89

910
use super::table::InMemoryTableInnerRef;
1011
use super::{InMemoryRowHandler, InMemoryTable, InMemoryTxnIterator};

src/storage/secondary/compactor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::time::Duration;
55

66
use itertools::Itertools;
77
use tokio::sync::oneshot::Receiver;
8+
use tracing::{info, warn};
89

910
use super::{SecondaryStorage, SecondaryTable, Snapshot};
1011
use crate::catalog::find_sort_key_id;

src/storage/secondary/manifest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use serde::{Deserialize, Serialize};
1414
use serde_json::Deserializer;
1515
use tokio::fs::OpenOptions;
1616
use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt, BufReader};
17+
use tracing::warn;
1718

1819
use super::version_manager::EpochOp;
1920
use super::{SecondaryStorage, SecondaryTable, StorageResult, TracedStorageError};

src/storage/secondary/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ use parking_lot::RwLock;
5959
use tokio::sync::oneshot::Sender;
6060
use tokio::sync::Mutex;
6161
use tokio::task::JoinHandle;
62+
use tracing::info;
6263

6364
use super::{Storage, StorageResult, TracedStorageError};
6465
use crate::catalog::{ColumnCatalog, RootCatalogRef, TableRefId};

0 commit comments

Comments
 (0)