From 263bdf72a02d23d17a4c63bcf9f2e2e582625f7a Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Wed, 26 Dec 2018 17:36:36 +0100 Subject: [PATCH] Fix what broke on the rebase --- src/rust/engine/Cargo.lock | 14 ++++++- src/rust/engine/Cargo.toml | 6 ++- src/rust/engine/logging/Cargo.toml | 13 +++++++ src/rust/engine/logging/src/lib.rs | 42 +++++++++------------ src/rust/engine/{ => logging}/src/logger.rs | 5 ++- src/rust/engine/src/externs.rs | 2 +- src/rust/engine/src/lib.rs | 3 -- 7 files changed, 52 insertions(+), 33 deletions(-) create mode 100644 src/rust/engine/logging/Cargo.toml rename src/rust/engine/{ => logging}/src/logger.rs (97%) diff --git a/src/rust/engine/Cargo.lock b/src/rust/engine/Cargo.lock index 9834230e3f37..920f16689321 100644 --- a/src/rust/engine/Cargo.lock +++ b/src/rust/engine/Cargo.lock @@ -410,13 +410,13 @@ dependencies = [ "itertools 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "logging 0.0.1", "num_enum 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "process_execution 0.0.1", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.5 (git+https://github.com/pantsbuild/reqwest.git?rev=983409edb6ba1693f38a6fc230dfcd34f9249649)", "resettable 0.0.1", - "simplelog 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "tar_api 0.0.1", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -941,6 +941,18 @@ dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "logging" +version = "0.0.1" +dependencies = [ + "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num_enum 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "simplelog 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ui 0.0.1", +] + [[package]] name = "matches" version = "0.1.8" diff --git a/src/rust/engine/Cargo.toml b/src/rust/engine/Cargo.toml index 5f4f3a60dfbc..3a4d413bd9c3 100644 --- a/src/rust/engine/Cargo.toml +++ b/src/rust/engine/Cargo.toml @@ -35,6 +35,7 @@ members = [ "fs/fs_util", "graph", "hashing", + "logging", "process_execution", "process_executor", "resettable", @@ -43,7 +44,7 @@ members = [ "testutil", "testutil/mock", "testutil/local_cas", - "ui" + "ui", ] # These are the packages which are built/tested when no special selector flags are passed to cargo. @@ -62,6 +63,7 @@ default-members = [ "fs/fs_util", "graph", "hashing", + "logging", "process_execution", "process_executor", "resettable", @@ -87,6 +89,7 @@ indexmap = "1.0.2" itertools = "0.7.2" lazy_static = "1" log = "0.4" +logging = { path = "logging" } num_enum = "0.1.1" parking_lot = "0.6" process_execution = { path = "process_execution" } @@ -100,4 +103,3 @@ tempfile = "3" ui = { path = "ui" } url = "1.7.1" tar_api = { path = "tar_api" } -simplelog = "0.5.3" \ No newline at end of file diff --git a/src/rust/engine/logging/Cargo.toml b/src/rust/engine/logging/Cargo.toml new file mode 100644 index 000000000000..d0cb6836c243 --- /dev/null +++ b/src/rust/engine/logging/Cargo.toml @@ -0,0 +1,13 @@ +[package] +version = "0.0.1" +name = "logging" +authors = [ "Pants Build " ] +publish = false + +[dependencies] +log = "0.4" +lazy_static = "1" +num_enum = "0.1.1" +parking_lot = "0.6" +simplelog = "0.5.3" +ui = { path = "../ui" } diff --git a/src/rust/engine/logging/src/lib.rs b/src/rust/engine/logging/src/lib.rs index c02e839bd75e..491c799503a2 100644 --- a/src/rust/engine/logging/src/lib.rs +++ b/src/rust/engine/logging/src/lib.rs @@ -2,42 +2,36 @@ // Licensed under the Apache License, Version 2.0 (see LICENSE). // Enable all clippy lints except for many of the pedantic ones. It's a shame this needs to be copied and pasted across crates, but there doesn't appear to be a way to include inner attributes from a common source. -#![cfg_attr( - feature = "cargo-clippy", - deny( - clippy, - default_trait_access, - expl_impl_clone_on_copy, - if_not_else, - needless_continue, - single_match_else, - unseparated_literal_suffix, - used_underscore_binding - ) +#![deny( + clippy::all, + clippy::default_trait_access, + clippy::expl_impl_clone_on_copy, + clippy::if_not_else, + clippy::needless_continue, + clippy::single_match_else, + clippy::unseparated_literal_suffix, + clippy::used_underscore_binding )] // It is often more clear to show that nothing is being moved. -#![cfg_attr(feature = "cargo-clippy", allow(match_ref_pats))] +#![allow(clippy::match_ref_pats)] // Subjective style. -#![cfg_attr( - feature = "cargo-clippy", - allow(len_without_is_empty, redundant_field_names) -)] +#![allow(clippy::len_without_is_empty, clippy::redundant_field_names)] // Default isn't as big a deal as people seem to think it is. -#![cfg_attr( - feature = "cargo-clippy", - allow(new_without_default, new_without_default_derive) +#![allow( + clippy::new_without_default, + clippy::new_without_default_derive, + clippy::new_ret_no_self )] // Arc can be more clear than needing to grok Orderings: -#![cfg_attr(feature = "cargo-clippy", allow(mutex_atomic))] - -pub mod logger; +#![allow(clippy::mutex_atomic)] extern crate lazy_static; extern crate log; extern crate num_enum; extern crate parking_lot; extern crate simplelog; -extern crate ui; + +pub mod logger; pub type Logger = logger::Logger; diff --git a/src/rust/engine/src/logger.rs b/src/rust/engine/logging/src/logger.rs similarity index 97% rename from src/rust/engine/src/logger.rs rename to src/rust/engine/logging/src/logger.rs index aa2cdad508fe..c8de8a025294 100644 --- a/src/rust/engine/src/logger.rs +++ b/src/rust/engine/logging/src/logger.rs @@ -1,6 +1,7 @@ // Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). +use crate::TryIntoPythonLogLevel; use lazy_static::lazy_static; use log::{log, set_logger, set_max_level, LevelFilter, Log, Metadata, Record}; use parking_lot::Mutex; @@ -10,7 +11,6 @@ use std::fs::File; use std::fs::OpenOptions; use std::io::{stderr, Stderr, Write}; use std::path::PathBuf; -use TryIntoPythonLogLevel; lazy_static! { pub static ref LOGGER: Logger = Logger::new(); @@ -64,7 +64,8 @@ impl Logger { .open(log_file_path) .map(|file| { *self.pantsd_log.lock() = MaybeWriteLogger::new(file, level.into()); - }).map_err(|err| format!("Error opening pantsd logfile: {}", err)) + }) + .map_err(|err| format!("Error opening pantsd logfile: {}", err)) }) } diff --git a/src/rust/engine/src/externs.rs b/src/rust/engine/src/externs.rs index 0d17c83f552c..7900e8b5f866 100644 --- a/src/rust/engine/src/externs.rs +++ b/src/rust/engine/src/externs.rs @@ -14,7 +14,7 @@ use crate::interning::Interns; use lazy_static::lazy_static; use parking_lot::RwLock; -use logger::Logger; +use logging::Logger; pub fn eval(python: &str) -> Result { with_externs(|e| (e.eval)(e.context, python.as_ptr(), python.len() as u64)).into() diff --git a/src/rust/engine/src/lib.rs b/src/rust/engine/src/lib.rs index 10255d7ccd7a..6ecfb2dcb75c 100644 --- a/src/rust/engine/src/lib.rs +++ b/src/rust/engine/src/lib.rs @@ -29,14 +29,12 @@ // other unsafeness. #![allow(clippy::not_unsafe_ptr_arg_deref)] - pub mod cffi_externs; mod context; mod core; mod externs; mod handles; mod interning; -mod logger; mod nodes; mod rule_graph; mod scheduler; @@ -86,7 +84,6 @@ use crate::types::Types; use futures::Future; use hashing::Digest; use log::error; - use logging::logger::LOGGER; // TODO: Consider renaming and making generic for collections of PyResults.