Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

priorities

  • Loading branch information...
commit c84ce448d1e8fbe1f627f93160bd4395524e951e 1 parent 6587431
@athoune athoune authored
Showing with 28 additions and 2 deletions.
  1. +17 −1 README
  2. +11 −1 src/syslog.erl
View
18 README
@@ -20,4 +20,20 @@ $ tail -f /var/log/system.log
$ erl
> syslog:start().
> syslog:open("Beuha", 1, 128).
-> syslog:log(4, "Damned").
+> syslog:log(err, "Damned").
+
+API
+---
+
+syslog:log(Priority, Message) :
+
+Priority can be a number or better, an atom :
+ * emerg
+ * alert
+ * crit
+ * err
+ * warning
+ * notice
+ * info
+ * debug
+Message is a String
View
12 src/syslog.erl
@@ -34,7 +34,7 @@ open(Ident, Logopt, Facility) ->
gen_server:call(?MODULE, {open, Ident, Logopt, Facility}).
log(Priority, Message) ->
- gen_server:call(?MODULE, {log, Priority, Message}).
+ gen_server:call(?MODULE, {log, priorities(Priority), Message}).
%%% API %%%
@@ -99,6 +99,16 @@ code_change(_, _, _) ->
%%% internal functions %%%
+priorities(emerg) -> 0;
+priorities(alert) -> 1;
+priorities(crit) -> 2;
+priorities(err) -> 3;
+priorities(warning) -> 4;
+priorities(notice) -> 5;
+priorities(info) -> 6;
+priorities(debug) -> 7;
+priorities(N) -> N.
+
load_path(File) ->
case lists:zf(fun(Ebin) ->
Priv = Ebin ++ "/../priv/",
Please sign in to comment.
Something went wrong with that request. Please try again.