Skip to content

extra::workcache: Remove unused Logger #11468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 6 additions & 31 deletions src/libextra/workcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,28 +209,11 @@ impl Drop for Database {
}
}

pub struct Logger {
// FIXME #4432: Fill in
priv a: ()
}

impl Logger {

pub fn new() -> Logger {
Logger { a: () }
}

pub fn info(&self, i: &str) {
info!("workcache: {}", i);
}
}

pub type FreshnessMap = TreeMap<~str,extern fn(&str,&str)->bool>;

#[deriving(Clone)]
pub struct Context {
db: RWArc<Database>,
priv logger: RWArc<Logger>,
priv cfg: Arc<json::Object>,
/// Map from kinds (source, exe, url, etc.) to a freshness function.
/// The freshness function takes a name (e.g. file path) and value
Expand Down Expand Up @@ -275,18 +258,15 @@ fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
impl Context {

pub fn new(db: RWArc<Database>,
lg: RWArc<Logger>,
cfg: Arc<json::Object>) -> Context {
Context::new_with_freshness(db, lg, cfg, Arc::new(TreeMap::new()))
Context::new_with_freshness(db, cfg, Arc::new(TreeMap::new()))
}

pub fn new_with_freshness(db: RWArc<Database>,
lg: RWArc<Logger>,
cfg: Arc<json::Object>,
freshness: Arc<FreshnessMap>) -> Context {
Context {
db: db,
logger: lg,
cfg: cfg,
freshness: freshness
}
Expand Down Expand Up @@ -378,15 +358,11 @@ impl<'a> Prep<'a> {
None => fail!("missing freshness-function for '{}'", kind),
Some(f) => (*f)(name, val)
};
self.ctxt.logger.write(|lg| {
if fresh {
lg.info(format!("{} {}:{} is fresh",
cat, kind, name));
} else {
lg.info(format!("{} {}:{} is not fresh",
cat, kind, name))
}
});
if fresh {
info!("{} {}:{} is fresh", cat, kind, name);
} else {
info!("{} {}:{} is not fresh", cat, kind, name);
}
fresh
}

Expand Down Expand Up @@ -509,7 +485,6 @@ fn test() {
let db_path = make_path(~"db.json");

let cx = Context::new(RWArc::new(Database::new(db_path)),
RWArc::new(Logger::new()),
Arc::new(TreeMap::new()));

let s = cx.with_prep("test1", |prep| {
Expand Down
5 changes: 2 additions & 3 deletions src/librustpkg/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub use source_control::{safe_git_clone, git_clone_url};
use std::run;
use extra::arc::{Arc,RWArc};
use extra::workcache;
use extra::workcache::{Database, Logger, FreshnessMap};
use extra::workcache::{Database, FreshnessMap};
use extra::treemap::TreeMap;

// A little sad -- duplicated from rustc::back::*
Expand Down Expand Up @@ -70,14 +70,13 @@ pub fn new_workcache_context(p: &Path) -> workcache::Context {
let db_file = p.join("rustpkg_db.json"); // ??? probably wrong
debug!("Workcache database file: {}", db_file.display());
let db = RWArc::new(Database::new(db_file));
let lg = RWArc::new(Logger::new());
let cfg = Arc::new(TreeMap::new());
let mut freshness: FreshnessMap = TreeMap::new();
// Set up freshness functions for every type of dependency rustpkg
// knows about
freshness.insert(~"file", file_is_fresh);
freshness.insert(~"binary", binary_is_fresh);
workcache::Context::new_with_freshness(db, lg, cfg, Arc::new(freshness))
workcache::Context::new_with_freshness(db, cfg, Arc::new(freshness))
}

pub fn build_lib(sysroot: Path, root: Path, name: ~str, version: Version,
Expand Down
3 changes: 1 addition & 2 deletions src/librustpkg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use extra::arc::Arc;
use extra::arc::RWArc;
use extra::tempfile::TempDir;
use extra::workcache;
use extra::workcache::{Database, Logger};
use extra::workcache::{Database};
use extra::treemap::TreeMap;
use extra::getopts::groups::getopts;
use std::run::ProcessOutput;
Expand All @@ -46,7 +46,6 @@ use exit_codes::{BAD_FLAG_CODE, COPY_FAILED_CODE};
fn fake_ctxt(sysroot: Path, workspace: &Path) -> BuildContext {
let context = workcache::Context::new(
RWArc::new(Database::new(workspace.join("rustpkg_db.json"))),
RWArc::new(Logger::new()),
Arc::new(TreeMap::new()));
BuildContext {
workcache_context: context,
Expand Down