Skip to content
This repository
Newer
Older
100644 49 lines (38 sloc) 1.499 kb
7bcf044f » Vagabond
2011-06-24 Initial import
1 * Overview
2 Lager (pronounced lAAger) is a logging framework for Erlang. Its purpose is
3 to provide a more traditional way to perform logging in an erlang application
4 that plays nicely with traditional UNIX logging tools like logrotate and
5 syslog.
6
7 Features
8 - Finer grained log levels (debug, info, notice, warning, error, critical,
9 alert, emergency)
10 - Logger calls are transformed using a parse transform to allow capturing
11 Module/Function/Line/Pid information
12 - When no handler is consuming a log level (eg. debug) no event is even sent
13 to the log handler
14 - Supports multiple backends, including console, file and syslog.
15
16 * Usage
17 To use lager in your application, you need to define it as a rebar dep or have
18 some other way of including it in erlang's path. You can then add the
19 following option to the erlang compiler flags
20
d4b06a04 » Vagabond
2011-06-24 Adventures in org mode
21 #+BEGIN_EXAMPLE
7bcf044f » Vagabond
2011-06-24 Initial import
22 {parse_transform, lager_transform}
d4b06a04 » Vagabond
2011-06-24 Adventures in org mode
23 #+END_EXAMPLE
7bcf044f » Vagabond
2011-06-24 Initial import
24
25 Alternately, you can add it to the module you which to compile with logging
26 enabled:
27
d4b06a04 » Vagabond
2011-06-24 Adventures in org mode
28 #+BEGIN_EXAMPLE
7bcf044f » Vagabond
2011-06-24 Initial import
29 -compile([{parse_transform, lager_transform}]).
d4b06a04 » Vagabond
2011-06-24 Adventures in org mode
30 #+END_EXAMPLE
7bcf044f » Vagabond
2011-06-24 Initial import
31
32 Once you have built your code with lager, you can then generate log messages
33 by doing the following:
34
d4b06a04 » Vagabond
2011-06-24 Adventures in org mode
35 #+BEGIN_EXAMPLE
7bcf044f » Vagabond
2011-06-24 Initial import
36 lager:error("Some message")
d4b06a04 » Vagabond
2011-06-24 Adventures in org mode
37 #+END_EXAMPLE
7bcf044f » Vagabond
2011-06-24 Initial import
38
39 Or:
40
d4b06a04 » Vagabond
2011-06-24 Adventures in org mode
41 #+BEGIN_EXAMPLE
7bcf044f » Vagabond
2011-06-24 Initial import
42 lager:warning("Some message with a term: ~p", [Term])
d4b06a04 » Vagabond
2011-06-24 Adventures in org mode
43 #+END_EXAMPLE
7bcf044f » Vagabond
2011-06-24 Initial import
44
45 The general form is lager:Severity() where Severity is one of the log levels
46 mentioned above.
47
48 * Configuration
49 TODO
Something went wrong with that request. Please try again.