From 6f6aac3b35f51e5119100d96efda0dacaf5f29e1 Mon Sep 17 00:00:00 2001 From: Kevin Lynx Date: Sat, 3 Aug 2013 21:39:14 +0800 Subject: [PATCH] adjust crawler log directory --- src/crawler/crawler_app.erl | 3 ++- src/crawler/crawler_stats.erl | 3 ++- src/crawler/crawler_sup.erl | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/crawler/crawler_app.erl b/src/crawler/crawler_app.erl index 3f87780..892cacf 100644 --- a/src/crawler/crawler_app.erl +++ b/src/crawler/crawler_app.erl @@ -30,7 +30,8 @@ do_start() -> crawler_sup:start_link({StartPort, Count, DBHost, DBPort, LogLevel, DBConn, CacheMaxTime, CacheMaxCount}). start() -> - error_logger:logfile({open, "crash.log"}), + filelib:ensure_dir("log/"), + error_logger:logfile({open, "log/crash.log"}), code:add_path("deps/bson/ebin"), code:add_path("deps/kdht/ebin"), code:add_path("deps/mongodb/ebin"), diff --git a/src/crawler/crawler_stats.erl b/src/crawler/crawler_stats.erl index 736960f..5ad6ee2 100644 --- a/src/crawler/crawler_stats.erl +++ b/src/crawler/crawler_stats.erl @@ -136,7 +136,8 @@ date_string() -> -define(TEXT(Fmt, Arg), lists:flatten(io_lib:format(Fmt, Arg))). do_dump(State) -> - {ok, FP} = file:open("dhtcrawler-stats.txt", [append]), + filelib:ensure_dir("log/"), + {ok, FP} = file:open("log/dhtcrawler-stats.txt", [append]), io:format(FP, "~s~n", [date_string()]), io:format(FP, "~s~n", [format_stats(State)]), file:close(FP). diff --git a/src/crawler/crawler_sup.erl b/src/crawler/crawler_sup.erl index a4477dd..28e7fc5 100644 --- a/src/crawler/crawler_sup.erl +++ b/src/crawler/crawler_sup.erl @@ -24,7 +24,8 @@ srv_name() -> init([{StartPort, Count, DBHost, DBPort, LogLevel, DBConn, CacheTime, HashCacheMax}]) -> Spec = {one_for_one, 1, 600}, Instances = create_dht_instance(StartPort, Count), - Logger = [{dht_logger, {vlog, start_link, ["dht_crawler.txt", LogLevel]}, + filelib:ensure_dir("log/"), + Logger = [{dht_logger, {vlog, start_link, ["log/dht_crawler.txt", LogLevel]}, permanent, 2000, worker, dynamic}], HashInserter = [{hash_cache_writer, {hash_cache_writer, start_link, [DBHost, DBPort, DBConn, CacheTime, HashCacheMax]}, permanent, 2000, worker, dynamic}],