Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andylokandy committed Aug 1, 2024
1 parent 10d78d6 commit 2b0b284
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 37 deletions.
12 changes: 6 additions & 6 deletions examples/fn_layout_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
// limitations under the License.

use log::LevelFilter;
use logforth::{
append,
filter::{CustomFilter, FilterResult},
layout::CustomLayout,
Dispatch, Logger,
};
use logforth::append;
use logforth::filter::CustomFilter;
use logforth::filter::FilterResult;
use logforth::layout::CustomLayout;
use logforth::Dispatch;
use logforth::Logger;

fn main() {
Logger::new()
Expand Down
5 changes: 2 additions & 3 deletions examples/json_stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

use log::LevelFilter;
use logforth::append;
use logforth::filter;
use logforth::layout;
use logforth::logger::Dispatch;
use logforth::logger::Logger;
use logforth::Dispatch;
use logforth::Logger;

fn main() {
Logger::new()
Expand Down
19 changes: 9 additions & 10 deletions examples/rolling_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
// limitations under the License.

use log::LevelFilter;
use logforth::append;
use logforth::append::NonBlockingBuilder;
use logforth::append::RollingFileWriter;
use logforth::append::Rotation;
use logforth::filter;
use logforth::layout;
use logforth::logger::Dispatch;
use logforth::logger::Logger;
use logforth::append::rolling_file::NonBlockingBuilder;
use logforth::append::rolling_file::RollingFile;
use logforth::append::rolling_file::RollingFileWriter;
use logforth::append::rolling_file::Rotation;
use logforth::layout::JsonLayout;
use logforth::Dispatch;
use logforth::Logger;

fn main() {
let rolling = RollingFileWriter::builder()
Expand All @@ -36,8 +35,8 @@ fn main() {
.dispatch(
Dispatch::new()
.filter(LevelFilter::Trace)
.layout(layout::JsonLayout)
.append(append::RollingFile::new(writer)),
.layout(JsonLayout)
.append(RollingFile::new(writer)),
)
.apply()
.unwrap();
Expand Down
9 changes: 6 additions & 3 deletions examples/simple_stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use log::Level;
use logforth::{append, filter::MinLevel, layout::TextLayout, Dispatch, Logger};
use log::LevelFilter;
use logforth::append;
use logforth::layout::TextLayout;
use logforth::Dispatch;
use logforth::Logger;

fn main() {
Logger::new()
.dispatch(
Dispatch::new()
.filter(MinLevel(Level::Trace))
.filter(LevelFilter::Trace)
.layout(TextLayout::default())
.append(append::Stdout),
)
Expand Down
10 changes: 5 additions & 5 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# comment_width = 120
# format_code_in_doc_comments = true
# group_imports = "StdExternalCrate"
# imports_granularity = "Item"
# wrap_comments = true
comment_width = 120
format_code_in_doc_comments = true
group_imports = "StdExternalCrate"
imports_granularity = "Item"
wrap_comments = true
6 changes: 4 additions & 2 deletions src/append/opentelemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ use std::time::Duration;
use std::time::SystemTime;

use log::Record;
use opentelemetry::logs::{AnyValue, LoggerProvider as ILoggerProvider};
use opentelemetry::logs::{Logger, Severity};
use opentelemetry::logs::AnyValue;
use opentelemetry::logs::Logger;
use opentelemetry::logs::LoggerProvider as ILoggerProvider;
use opentelemetry::logs::Severity;
use opentelemetry::InstrumentationLibrary;
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::logs::LoggerProvider;
Expand Down
8 changes: 4 additions & 4 deletions src/filter/min_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use log::Level;
use log::LevelFilter;
use log::Metadata;

use crate::filter::Filter;
use crate::filter::FilterResult;

#[derive(Debug, Clone)]
pub struct MinLevel(pub Level);
pub struct MinLevel(pub LevelFilter);

impl MinLevel {
pub(crate) fn filter(&self, metadata: &Metadata) -> FilterResult {
Expand All @@ -37,8 +37,8 @@ impl From<MinLevel> for Filter {
}
}

impl From<Level> for Filter {
fn from(filter: Level) -> Self {
impl From<LevelFilter> for Filter {
fn from(filter: LevelFilter) -> Self {
Filter::MinLevel(MinLevel(filter))
}
}
3 changes: 2 additions & 1 deletion src/filter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

pub use self::{custom::CustomFilter, min_level::MinLevel};
pub use self::custom::CustomFilter;
pub use self::min_level::MinLevel;

mod custom;
mod min_level;
Expand Down
4 changes: 3 additions & 1 deletion src/layout/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::fmt::{Arguments, Debug, Formatter};
use std::fmt::Arguments;
use std::fmt::Debug;
use std::fmt::Formatter;

use crate::layout::Layout;

Expand Down
3 changes: 2 additions & 1 deletion src/layout/identical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::layout::Layout;
use std::fmt::Arguments;

use crate::layout::Layout;

#[derive(Debug, Default, Clone, Copy)]
pub struct IdenticalLayout;

Expand Down
2 changes: 1 addition & 1 deletion src/layout/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@ impl JsonLayout {

impl From<JsonLayout> for Layout {
fn from(layout: JsonLayout) -> Self {
Layout::JsonLayout(layout)
Layout::Json(layout)
}
}

0 comments on commit 2b0b284

Please sign in to comment.