Skip to content

Commit

Permalink
priorities
Browse files Browse the repository at this point in the history
  • Loading branch information
athoune committed Aug 10, 2010
1 parent 6587431 commit c84ce44
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
18 changes: 17 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 11 additions & 1 deletion src/syslog.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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 %%%

Expand Down Expand Up @@ -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/",
Expand Down

0 comments on commit c84ce44

Please sign in to comment.