Logging options in config are now honoured.
authorStanislaw Klekot <dozzie@jarowit.net>
Wed, 17 Sep 2014 22:28:30 +0000 (00:28 +0200)
committerStanislaw Klekot <dozzie@jarowit.net>
Wed, 17 Sep 2014 22:28:30 +0000 (00:28 +0200)
config.ini.example
priv/haircut

index 135ba01..ba878ad 100644 (file)
@@ -1,8 +1,8 @@
 state_dir = /var/lib/haircut/state
-activity_logs = /var/lib/haircut/activity
-operation_logs := syslog
-#operation_logs := none
-#operation_logs = /var/log/haircut/operations.log
+activity_log = /var/lib/haircut/activity
+system_log := syslog
+#system_log := none
+#system_log = /var/log/haircut/operations.log
 
 # TODO
 #alog_mask := ...
index c622577..52cd740 100755 (executable)
@@ -14,6 +14,8 @@
   erl_node,
   erl_cookie,
   shell = false,
+  op_log,
+  activity_log,
   server,
   nick,
   user,
@@ -64,6 +66,8 @@ start(Opts) ->
   setup_erlang_networking(Opts),
   indira:start_rec(haircut), % before indira to prevent race condition
   indira:start_rec(indira),
+  gen_event:notify(haircut_log_operational,
+                   {info, [{event,<<"haircut started">>}]}),
   case Opts of
     #opts{shell = true} -> shell:start();
     _ -> ok
@@ -98,6 +102,14 @@ setup_haircut(Opts) ->
     #opts{nick = Nick} -> indira:set_option(haircut, nick, Nick)
   end,
   case Opts of
+    #opts{op_log = undefined} -> ok;
+    #opts{op_log = OpL} -> indira:set_option(haircut, op_log, OpL)
+  end,
+  case Opts of
+    #opts{activity_log = undefined} -> ok;
+    #opts{activity_log = AL} -> indira:set_option(haircut, activity_log, AL)
+  end,
+  case Opts of
     #opts{user = undefined, full_name = undefined} -> ok;
     #opts{user = User,      full_name = undefined} ->
       indira:set_option(haircut, user, {User, "haircut IRC bot"});
@@ -143,7 +155,9 @@ read_config(Opts = #opts{config_file = ConfigFile}) ->
     nick      = proplists:get_value(nick, Config, User),
     full_name = proplists:get_value(full_name, Config, "haircut IRC bot"),
     server    = proplists:get_value(server, Config),
-    channels  = proplists:get_all_values(channel, Config)
+    channels  = proplists:get_all_values(channel, Config),
+    op_log       = proplists:get_value(system_log, Config),
+    activity_log = proplists:get_value(activity_log, Config)
   },
   case CombinedOpts of
     #opts{user = false}       -> {error, no_user};