Skip to content

Commit

Permalink
facility
Browse files Browse the repository at this point in the history
  • Loading branch information
athoune committed Aug 10, 2010
1 parent c84ce44 commit 8eb1151
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
35 changes: 34 additions & 1 deletion README
Expand Up @@ -12,19 +12,52 @@ sudo ./rebar install
Trying it
---------

You should have a look at syslog.h

In an other shell :
$ tail -f /var/log/sylsog
Or for mac user :
$ tail -f /var/log/system.log

$ erl
> syslog:start().
> syslog:open("Beuha", 1, 128).
> syslog:open("Beuha", 1, local0).
> syslog:log(err, "Damned").

API
---

syslog:open(Ident, Logopt, Facility) :

Ident is an arbitrary string
Logopt
Facility is an atom :
* kern
* user
* mail
* daemon
* auth
* syslog
* lpr
* news
* uucp
* cron
* authpriv
* ftp
* netinfo
* remoteauth
* install
* ras
* local0
* local1
* local2
* local3
* local4
* local5
* local6
* local7


syslog:log(Priority, Message) :

Priority can be a number or better, an atom :
Expand Down
28 changes: 27 additions & 1 deletion src/syslog.erl
Expand Up @@ -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}).
gen_server:call(?MODULE, {open, Ident, Logopt, facility(Facility)}).

log(Priority, Message) ->
gen_server:call(?MODULE, {log, priorities(Priority), Message}).
Expand Down Expand Up @@ -109,6 +109,32 @@ priorities(info) -> 6;
priorities(debug) -> 7;
priorities(N) -> N.

facility(kern) -> 0;
facility(user) -> 8;
facility(mail) -> 16;
facility(daemon) -> 24;
facility(auth) -> 32;
facility(syslog) -> 40;
facility(lpr) -> 48;
facility(news) -> 56;
facility(uucp) -> 64;
facility(cron) -> 72;
facility(authpriv) -> 80;
facility(ftp) -> 88;
facility(netinfo) -> 96;
facility(remoteauth)-> 104;
facility(install) -> 112;
facility(ras) -> 120;
facility(local0) -> 16 * 8;
facility(local1) -> 17 * 8;
facility(local2) -> 18 * 8;
facility(local3) -> 19 * 8;
facility(local4) -> 20 * 8;
facility(local5) -> 21 * 8;
facility(local6) -> 22 * 8;
facility(local7) -> 23 * 8;
facility(N) -> N.

load_path(File) ->
case lists:zf(fun(Ebin) ->
Priv = Ebin ++ "/../priv/",
Expand Down

0 comments on commit 8eb1151

Please sign in to comment.