Skip to content

Commit

Permalink
Switch from log facade to tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
attila-lin authored and silvanshade committed May 14, 2022
1 parent 4da888d commit cc4c858
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

* Update `async-tungstenite` from `0.16` to `0.17`
* Update `ws_stream_tungstenite` from `0.7` to `0.8`
* Switching from `log` facade to `tracing`.

## [0.17.0] - 2022-04-15

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ bytes = "1.0"
dashmap = "5.1"
futures = { version = "0.3", default-features = false, features = ["std", "async-await"] }
httparse = "1.3.5"
log = "0.4"
lsp-types = "0.93"
memchr = "2.4.1"
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -36,10 +35,11 @@ tokio = { version = "1.17", optional = true }
tokio-util = { version = "0.7", optional = true, features = ["codec"] }
tower-lsp-macros = { version = "0.6", path = "./tower-lsp-macros" }
tower = { version = "0.4.12", default-features = false, features = ["util"] }
tracing = "0.1.34"

[dev-dependencies]
async-tungstenite = { version = "0.17", features = ["tokio-runtime"] }
env_logger = "0.9"
tracing-subscriber = "0.3.11"
tokio = { version = "1.17", features = ["io-util", "io-std", "macros", "rt-multi-thread"] }
tokio-util = { version = "0.7", features = ["compat"] }
ws_stream_tungstenite = { version = "0.8", features = ["tokio_io"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async fn main() {
#[cfg(feature = "runtime-agnostic")]
use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};

env_logger::init();
tracing_subscriber::fmt().init();

let (stdin, stdout) = (tokio::io::stdin(), tokio::io::stdout());
#[cfg(feature = "runtime-agnostic")]
Expand Down
2 changes: 1 addition & 1 deletion examples/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async fn main() {
#[cfg(feature = "runtime-agnostic")]
use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};

env_logger::init();
tracing_subscriber::fmt().init();

let (stdin, stdout) = (tokio::io::stdin(), tokio::io::stdout());
#[cfg(feature = "runtime-agnostic")]
Expand Down
2 changes: 1 addition & 1 deletion examples/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async fn main() {
#[cfg(feature = "runtime-agnostic")]
use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};

env_logger::init();
tracing_subscriber::fmt().init();

let mut args = std::env::args();
let stream = match args.nth(1).as_deref() {
Expand Down
4 changes: 3 additions & 1 deletion examples/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use tokio::net::TcpListener;
use tower_lsp::jsonrpc::Result;
use tower_lsp::lsp_types::*;
use tower_lsp::{Client, LanguageServer, LspService, Server};
use tracing::info;
use ws_stream_tungstenite::*;

#[derive(Debug)]
Expand Down Expand Up @@ -121,9 +122,10 @@ async fn main() {
#[cfg(feature = "runtime-agnostic")]
use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};

env_logger::init();
tracing_subscriber::fmt().init();

let listener = TcpListener::bind("127.0.0.1:9257").await.unwrap();
info!("Listening on {}", listener.local_addr().unwrap());
let (stream, _) = listener.accept().await.unwrap();
let (read, write) = tokio::io::split(WsStream::new(accept_async(stream).await.unwrap()));
#[cfg(feature = "runtime-agnostic")]
Expand Down
2 changes: 1 addition & 1 deletion src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use std::str::Utf8Error;

use bytes::buf::BufMut;
use bytes::{Buf, BytesMut};
use log::{trace, warn};
use memchr::memmem;
use serde::{de::DeserializeOwned, Serialize};
use tracing::{trace, warn};

#[cfg(feature = "runtime-agnostic")]
use async_codec_lite::{Decoder, Encoder};
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ pub use self::service::{Client, ClientSocket, ExitedError, LspService, LspServic
pub use self::transport::{Loopback, Server};

use auto_impl::auto_impl;
use log::{error, warn};
use lsp_types::request::{
GotoDeclarationParams, GotoDeclarationResponse, GotoImplementationParams,
GotoImplementationResponse, GotoTypeDefinitionParams, GotoTypeDefinitionResponse,
};
use lsp_types::*;
use serde_json::Value;
use tower_lsp_macros::rpc;
use tracing::{error, warn};

use self::jsonrpc::{Error, Result};

Expand Down
2 changes: 1 addition & 1 deletion src/service/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use std::task::{Context, Poll};
use futures::channel::mpsc::{self, Sender};
use futures::future::BoxFuture;
use futures::sink::SinkExt;
use log::{error, trace};
use lsp_types::notification::*;
use lsp_types::request::*;
use lsp_types::*;
use serde::Serialize;
use serde_json::Value;
use tower::Service;
use tracing::{error, trace};

use self::pending::Pending;
use super::state::{ServerState, State};
Expand Down
2 changes: 1 addition & 1 deletion src/service/client/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::future::Future;

use dashmap::{mapref::entry::Entry, DashMap};
use futures::channel::oneshot;
use log::warn;
use tracing::warn;

use crate::jsonrpc::{Id, Response};

Expand Down
2 changes: 1 addition & 1 deletion src/service/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::sync::Arc;
use std::task::{Context, Poll};

use futures::future::{self, BoxFuture, FutureExt};
use log::{info, warn};
use tower::{Layer, Service};
use tracing::{info, warn};

use super::ExitedError;
use crate::jsonrpc::{not_initialized_error, Error, Id, Request, Response};
Expand Down
2 changes: 1 addition & 1 deletion src/service/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::Arc;

use dashmap::{mapref::entry::Entry, DashMap};
use futures::future::{self, Either};
use log::{info, warn};
use tracing::{info, warn};

use super::ExitedError;
use crate::jsonrpc::{Error, Id, Response};
Expand Down
2 changes: 1 addition & 1 deletion src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use tokio_util::codec::{FramedRead, FramedWrite};

use futures::channel::mpsc;
use futures::{future, join, stream, FutureExt, Sink, SinkExt, Stream, StreamExt, TryFutureExt};
use log::error;
use tower::Service;
use tracing::error;

use crate::codec::{LanguageServerCodec, ParseError};
use crate::jsonrpc::{Error, Id, Message, Request, Response};
Expand Down
2 changes: 1 addition & 1 deletion tower-lsp-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fn gen_server_router(trait_name: &syn::Ident, methods: &[MethodCall]) -> proc_ma
use std::sync::Arc;
use std::future::{Future, Ready};

use log::info;
use tracing::info;
use lsp_types::*;
use lsp_types::notification::*;
use lsp_types::request::*;
Expand Down

0 comments on commit cc4c858

Please sign in to comment.