Browse files

log opt

  • Loading branch information...
1 parent 8eb1151 commit 1f7cf07e5c4ffded4fd75cd49145f08e7bdf1728 @athoune athoune committed Aug 10, 2010
Showing with 21 additions and 3 deletions.
  1. +8 −2 README
  2. +13 −1 src/syslog.erl
View
10 README
@@ -21,7 +21,7 @@ $ tail -f /var/log/system.log
$ erl
> syslog:start().
-> syslog:open("Beuha", 1, local0).
+> syslog:open("Beuha", [cons, perror, pid], local0).
> syslog:log(err, "Damned").
API
@@ -30,7 +30,13 @@ API
syslog:open(Ident, Logopt, Facility) :
Ident is an arbitrary string
-Logopt
+Logopt is an array of options :
+ * pid
+ * cons
+ * odelay
+ * ndelay
+ * perror
+
Facility is an atom :
* kern
* user
View
14 src/syslog.erl
@@ -31,7 +31,7 @@ start_linked() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
open(Ident, Logopt, Facility) ->
- gen_server:call(?MODULE, {open, Ident, Logopt, facility(Facility)}).
+ gen_server:call(?MODULE, {open, Ident, logopt(Logopt), facility(Facility)}).
log(Priority, Message) ->
gen_server:call(?MODULE, {log, priorities(Priority), Message}).
@@ -135,6 +135,18 @@ facility(local6) -> 22 * 8;
facility(local7) -> 23 * 8;
facility(N) -> N.
+openlog_opt(pid) -> 1;
+openlog_opt(cons) -> 2;
+openlog_opt(odelay) -> 4;
+openlog_opt(ndelay) -> 8;
+openlog_opt(perror) -> 20;
+openlog_opt(N) -> N.
+
+logopt([Queue]) -> openlog_opt(Queue);
+logopt([Tail|Queue]) ->
+ openlog_opt(Tail) bor logopt(Queue);
+logopt([]) -> 0.
+
load_path(File) ->
case lists:zf(fun(Ebin) ->
Priv = Ebin ++ "/../priv/",

0 comments on commit 1f7cf07

Please sign in to comment.