Permalink
Browse files

facility

  • Loading branch information...
1 parent c84ce44 commit 8eb115180e4dba12a1c9d0981dbb1287d58261b7 @athoune athoune committed Aug 10, 2010
Showing with 61 additions and 2 deletions.
  1. +34 −1 README
  2. +27 −1 src/syslog.erl
View
35 README
@@ -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 :
View
@@ -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}).
@@ -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/",

0 comments on commit 8eb1151

Please sign in to comment.