Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 112 lines (92 sloc) 2.541 kb
f4cfd45 @khia Documentation is added
authored
1 ExLager
2 =======
3
4 This package implements a simple wrapper over https://github.com/basho/lager.
5
6 It embeds logging calls to ExLager into a module if currently configured logging
7 level is less or equal than severity of a call. Therefore it doesn't have
8 any negative impact on performance of a production system when you configure
a29a17f @khia Update README.md
authored
9 error level even if you have tons of debug messages.
f4cfd45 @khia Documentation is added
authored
10
11 Information about location of a call (module, function, line, pid) is properly
03235ba @khia Update README.md
authored
12 passed to lager for your convinience so you can easily find the source of a message.
f4cfd45 @khia Documentation is added
authored
13 In this aspect using ExLager is equal to using parse transform shipped with
14 basho lager.
15
16 Since ExLager depends on macro implemented in Lager module you have to require it.
17 Then you call one of logging methods on Lager module. There are seven logging
18 methods in order of severity:
19
20 - debug
21 - info
22 - notice
23 - warning
24 - error
25 - critical
26 - alert
27 - emergency
28
29 Examples:
30 ---------
31
32 ```elixir
33 defmodule Test do
34 require Lager
35 def debug do
36 Lager.debug "Hi debug"
37 end
38 def info do
39 Lager.info "Hi error"
40 end
41 def notice do
42 Lager.notice "Hi notice"
43 end
44 def warning do
45 Lager.warning "Hi warning"
46 end
47 def error do
48 Lager.error "Hi error"
49 end
50 def critical do
51 Lager.critical "Hi critical"
52 end
53 def alert do
54 Lager.alert "Hi alert"
55 end
56 def emergency do
57 Lager.emergency "Hi emergency"
58 end
59 def test do
60 debug
61 info
62 notice
63 warning
64 error
65 critical
66 alert
67 emergency
68 end
69 end
70
71 Application.start :exlager
72 Test.test
73 ```
74
779a753 @khia Update documentation to mention configuration of underlying lagger
authored
75 It is possible to configure truncation size and compile time log level.
76 Beign a simple wrapper ExLager doesn't attempt to configure underlying Lager.
77 You would need to configure it yourself [see](https://github.com/basho/lager) to ensure that:
78
79 * lager_truncation_size >= compile_truncation_size
80 * lager severity level >= compile_log_level
81 * appropriate handlers are configured
82
83 Configuration of ExLager can be done by calling helper functions of Lager from your build system as follows:
97456ff @khia Use compiler options to pass configuration.
authored
84
85 ```
86 iex(1)> Lager.compile_log_level(:info)
87 true
88 iex(2)> Lager.compile_truncation_size(512)
89 true
90 ```
91
92 If you cannot call those function you can set compiler options:
93
94 ```
f8dd071 @khia Update documentation
authored
95 iex(3)> Code.compiler_options exlager_level: :debug
97456ff @khia Use compiler options to pass configuration.
authored
96 ok
97 iex(4)> Code.compiler_options exlager_truncation_size: 512
98 ok
99 ```
100
2e15347 @jsvisa Update README.md
jsvisa authored
101 If you are mix user you could specify level and truncation_size in *config/config.#{Mix.env}.exs* as follows:
c991651 @khia Specify compile_log_level using name of the level rather than an integer
authored
102
103 ```
2e15347 @jsvisa Update README.md
jsvisa authored
104 use Mix.Config
c991651 @khia Specify compile_log_level using name of the level rather than an integer
authored
105
2e15347 @jsvisa Update README.md
jsvisa authored
106 config :exlager,
107 level: :debug,
108 truncation_size: 8096
c991651 @khia Specify compile_log_level using name of the level rather than an integer
authored
109 ```
110
f4cfd45 @khia Documentation is added
authored
111
Something went wrong with that request. Please try again.