Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

785 righe
28 KiB

8 anni fa
9 anni fa
8 anni fa
8 anni fa
8 anni fa
9 anni fa
9 anni fa
  1. Overview
  2. --------
  3. Lager (as in the beer) is a logging framework for Erlang. Its purpose is
  4. to provide a more traditional way to perform logging in an erlang application
  5. that plays nicely with traditional UNIX logging tools like logrotate and
  6. syslog.
  7. [Travis-CI](http://travis-ci.org/erlang-lager/lager) :: ![Travis-CI](https://secure.travis-ci.org/erlang-lager/lager.png)
  8. Features
  9. --------
  10. * Finer grained log levels (debug, info, notice, warning, error, critical,
  11. alert, emergency)
  12. * Logger calls are transformed using a parse transform to allow capturing
  13. Module/Function/Line/Pid information
  14. * When no handler is consuming a log level (eg. debug) no event is sent
  15. to the log handler
  16. * Supports multiple backends, including console and file.
  17. * Supports multiple sinks
  18. * Rewrites common OTP error messages into more readable messages
  19. * Support for pretty printing records encountered at compile time
  20. * Tolerant in the face of large or many log messages, won't out of memory the node
  21. * Optional feature to bypass log size truncation ("unsafe")
  22. * Supports internal time and date based rotation, as well as external rotation tools
  23. * Syslog style log level comparison flags
  24. * Colored terminal output (requires R16+)
  25. * Map support (requires 17+)
  26. * Optional load shedding by setting a high water mark to kill (and reinstall)
  27. a sink after a configurable cool down timer
  28. Usage
  29. -----
  30. To use lager in your application, you need to define it as a rebar dep or have
  31. some other way of including it in Erlang's path. You can then add the
  32. following option to the erlang compiler flags:
  33. ```erlang
  34. {parse_transform, lager_transform}
  35. ```
  36. Alternately, you can add it to the module you wish to compile with logging
  37. enabled:
  38. ```erlang
  39. -compile([{parse_transform, lager_transform}]).
  40. ```
  41. Before logging any messages, you'll need to start the lager application. The
  42. lager module's `start` function takes care of loading and starting any dependencies
  43. lager requires.
  44. ```erlang
  45. lager:start().
  46. ```
  47. You can also start lager on startup with a switch to `erl`:
  48. ```erlang
  49. erl -pa path/to/lager/ebin -s lager
  50. ```
  51. Once you have built your code with lager and started the lager application,
  52. you can then generate log messages by doing the following:
  53. ```erlang
  54. lager:error("Some message")
  55. ```
  56. Or:
  57. ```erlang
  58. lager:warning("Some message with a term: ~p", [Term])
  59. ```
  60. The general form is `lager:Severity()` where `Severity` is one of the log levels
  61. mentioned above.
  62. Configuration
  63. -------------
  64. To configure lager's backends, you use an application variable (probably in
  65. your app.config):
  66. ```erlang
  67. {lager, [
  68. {log_root, "/var/log/hello"},
  69. {handlers, [
  70. {lager_console_backend, info},
  71. {lager_file_backend, [{file, "error.log"}, {level, error}]},
  72. {lager_file_backend, [{file, "console.log"}, {level, info}]}
  73. ]}
  74. ]}.
  75. ```
  76. ```log_root``` variable is optional, by default file paths are relative to CWD.
  77. The available configuration options for each backend are listed in their
  78. module's documentation.
  79. Sinks
  80. -----
  81. Lager has traditionally supported a single sink (implemented as a
  82. `gen_event` manager) named `lager_event` to which all backends were
  83. connected.
  84. Lager now supports extra sinks; each sink can have different
  85. sync/async message thresholds and different backends.
  86. ### Sink configuration
  87. To use multiple sinks (beyond the built-in sink of lager and lager_event), you
  88. need to:
  89. 1. Setup rebar.config
  90. 2. Configure the backends in app.config
  91. #### Names
  92. Each sink has two names: one atom to be used like a module name for
  93. sending messages, and that atom with `_lager_event` appended for backend
  94. configuration.
  95. This reflects the legacy behavior: `lager:info` (or `critical`, or
  96. `debug`, etc) is a way of sending a message to a sink named
  97. `lager_event`. Now developers can invoke `audit:info` or
  98. `myCompanyName:debug` so long as the corresponding `audit_lager_event` or
  99. `myCompanyName_lager_event` sinks are configured.
  100. #### rebar.config
  101. In `rebar.config` for the project that requires lager, include a list
  102. of sink names (without the `_lager_event` suffix) in `erl_opts`:
  103. `{lager_extra_sinks, [audit]}`
  104. #### Runtime requirements
  105. To be useful, sinks must be configured at runtime with backends.
  106. In `app.config` for the project that requires lager, for example,
  107. extend the lager configuration to include an `extra_sinks` tuple with
  108. backends (aka "handlers") and optionally `async_threshold` and
  109. `async_threshold_window` values (see **Overload Protection**
  110. below). If async values are not configured, no overload protection
  111. will be applied on that sink.
  112. ```erlang
  113. [{lager, [
  114. {log_root, "/tmp"},
  115. %% Default handlers for lager/lager_event
  116. {handlers, [
  117. {lager_console_backend, info},
  118. {lager_file_backend, [{file, "error.log"}, {level, error}]},
  119. {lager_file_backend, [{file, "console.log"}, {level, info}]}
  120. ]},
  121. %% Any other sinks
  122. {extra_sinks,
  123. [
  124. {audit_lager_event,
  125. [{handlers,
  126. [{lager_file_backend,
  127. [{file, "sink1.log"},
  128. {level, info}
  129. ]
  130. }]
  131. },
  132. {async_threshold, 500},
  133. {async_threshold_window, 50}]
  134. }]
  135. }
  136. ]
  137. }
  138. ].
  139. ```
  140. Custom Formatting
  141. -----------------
  142. All loggers have a default formatting that can be overriden. A formatter is any module that
  143. exports `format(#lager_log_message{},Config#any())`. It is specified as part of the configuration
  144. for the backend:
  145. ```erlang
  146. {lager, [
  147. {handlers, [
  148. {lager_console_backend, [info, {lager_default_formatter, [time," [",severity,"] ", message, "\n"]}]},
  149. {lager_file_backend, [{file, "error.log"}, {level, error}, {formatter, lager_default_formatter},
  150. {formatter_config, [date, " ", time," [",severity,"] ",pid, " ", message, "\n"]}]},
  151. {lager_file_backend, [{file, "console.log"}, {level, info}]}
  152. ]}
  153. ]}.
  154. ```
  155. Included is `lager_default_formatter`. This provides a generic, default
  156. formatting for log messages using a structure similar to Erlang's
  157. [iolist](http://learnyousomeerlang.com/buckets-of-sockets#io-lists) which we
  158. call "semi-iolist":
  159. * Any traditional iolist elements in the configuration are printed verbatim.
  160. * Atoms in the configuration are treated as placeholders for lager metadata and
  161. extracted from the log message.
  162. * The placeholders `date`, `time`, `message`, `sev` and `severity` will always exist.
  163. * `sev` is an abbreviated severity which is interpreted as a capitalized
  164. single letter encoding of the severity level (e.g. `'debug'` -> `$D`)
  165. * The placeholders `pid`, `file`, `line`, `module`, `function`, and `node`
  166. will always exist if the parse transform is used.
  167. * Applications can define their own metadata placeholder.
  168. * A tuple of `{atom(), semi-iolist()}` allows for a fallback for
  169. the atom placeholder. If the value represented by the atom
  170. cannot be found, the semi-iolist will be interpreted instead.
  171. * A tuple of `{atom(), semi-iolist(), semi-iolist()}` represents a
  172. conditional operator: if a value for the atom placeholder can be
  173. found, the first semi-iolist will be output; otherwise, the
  174. second will be used.
  175. Examples:
  176. ```
  177. ["Foo"] -> "Foo", regardless of message content.
  178. [message] -> The content of the logged message, alone.
  179. [{pid,"Unknown Pid"}] -> "<?.?.?>" if pid is in the metadata, "Unknown Pid" if not.
  180. [{pid, ["My pid is ", pid], ["Unknown Pid"]}] -> if pid is in the metadata print "My pid is <?.?.?>", otherwise print "Unknown Pid"
  181. [{server,{pid, ["(", pid, ")"], ["(Unknown Server)"]}}] -> user provided server metadata, otherwise "(<?.?.?>)", otherwise "(Unknown Server)"
  182. ```
  183. Error logger integration
  184. ------------------------
  185. Lager is also supplied with a `error_logger` handler module that translates
  186. traditional erlang error messages into a friendlier format and sends them into
  187. lager itself to be treated like a regular lager log call. To disable this, set
  188. the lager application variable `error_logger_redirect` to `false`.
  189. You can also disable reformatting for OTP and Cowboy messages by setting variable
  190. `error_logger_format_raw` to `true`.
  191. The `error_logger` handler will also log more complete error messages (protected
  192. with use of `trunc_io`) to a "crash log" which can be referred to for further
  193. information. The location of the crash log can be specified by the crash_log
  194. application variable. If set to `false` it is not written at all.
  195. Messages in the crash log are subject to a maximum message size which can be
  196. specified via the `crash_log_msg_size` application variable.
  197. Messages from `error_logger` will be redirected to `error_logger_lager_event` sink
  198. if it is defined so it can be redirected to another log file.
  199. For example:
  200. ```
  201. [{lager, [
  202. {extra_sinks,
  203. [
  204. {error_logger_lager_event,
  205. [{handlers, [
  206. {lager_file_backend, [{file, "error_logger.log"}, {level, info}]}]
  207. }]
  208. }]
  209. }]
  210. }].
  211. ```
  212. will send all `error_logger` messages to `error_logger.log` file.
  213. Overload Protection
  214. -------------------
  215. ### Asynchronous mode
  216. Prior to lager 2.0, the `gen_event` at the core of lager operated purely in
  217. synchronous mode. Asynchronous mode is faster, but has no protection against
  218. message queue overload. As of lager 2.0, the `gen_event` takes a hybrid
  219. approach. it polls its own mailbox size and toggles the messaging between
  220. synchronous and asynchronous depending on mailbox size.
  221. ```erlang
  222. {async_threshold, 20},
  223. {async_threshold_window, 5}
  224. ```
  225. This will use async messaging until the mailbox exceeds 20 messages, at which
  226. point synchronous messaging will be used, and switch back to asynchronous, when
  227. size reduces to `20 - 5 = 15`.
  228. If you wish to disable this behaviour, simply set `async_threshold` to `undefined`. It defaults
  229. to a low number to prevent the mailbox growing rapidly beyond the limit and causing
  230. problems. In general, lager should process messages as fast as they come in, so getting
  231. 20 behind should be relatively exceptional anyway.
  232. If you want to limit the number of messages per second allowed from `error_logger`,
  233. which is a good idea if you want to weather a flood of messages when lots of
  234. related processes crash, you can set a limit:
  235. ```erlang
  236. {error_logger_hwm, 50}
  237. ```
  238. It is probably best to keep this number small.
  239. ### Sink Killer
  240. In some high volume situations, it may be preferable to drop all pending log
  241. messages instead of letting them drain over time.
  242. If you prefer, you may choose to use the sink killer to shed load. In this
  243. operational mode, if the `gen_event` mailbox exceeds a configurable
  244. high water mark, the sink will be killed and reinstalled after a
  245. configurable cool down time.
  246. You can configure this behavior by using these configuration directives:
  247. ```erlang
  248. {killer_hwm, 1000},
  249. {killer_reinstall_after, 5000}
  250. ```
  251. This means if the sink's mailbox size exceeds 1000 messages, kill the
  252. entire sink and reload it after 5000 milliseconds. This behavior can
  253. also be installed into alternative sinks if desired.
  254. By default, the manager killer *is not installed* into any sink. If
  255. the `killer_reinstall_after` cool down time is not specified it defaults
  256. to 5000.
  257. "Unsafe"
  258. --------
  259. The unsafe code pathway bypasses the normal lager formatting code and uses the
  260. same code as error_logger in OTP. This provides a marginal speedup to your logging
  261. code (we measured between 0.5-1.3% improvement during our benchmarking; others have
  262. reported better improvements.)
  263. This is a **dangerous** feature. It *will not* protect you against
  264. large log messages - large messages can kill your application and even your
  265. Erlang VM dead due to memory exhaustion as large terms are copied over and
  266. over in a failure cascade. We strongly recommend that this code pathway
  267. only be used by log messages with a well bounded upper size of around 500 bytes.
  268. If there's any possibility the log messages could exceed that limit, you should
  269. use the normal lager message formatting code which will provide the appropriate
  270. size limitations and protection against memory exhaustion.
  271. If you want to format an unsafe log message, you may use the severity level (as
  272. usual) followed by `_unsafe`. Here's an example:
  273. ```erlang
  274. lager:info_unsafe("The quick brown ~s jumped over the lazy ~s", ["fox", "dog"]).
  275. ```
  276. Runtime loglevel changes
  277. ------------------------
  278. You can change the log level of any lager backend at runtime by doing the
  279. following:
  280. ```erlang
  281. lager:set_loglevel(lager_console_backend, debug).
  282. ```
  283. Or, for the backend with multiple handles (files, mainly):
  284. ```erlang
  285. lager:set_loglevel(lager_file_backend, "console.log", debug).
  286. ```
  287. Lager keeps track of the minimum log level being used by any backend and
  288. suppresses generation of messages lower than that level. This means that debug
  289. log messages, when no backend is consuming debug messages, are effectively
  290. free. A simple benchmark of doing 1 million debug log messages while the
  291. minimum threshold was above that takes less than half a second.
  292. Syslog style loglevel comparison flags
  293. --------------------------------------
  294. In addition to the regular log level names, you can also do finer grained masking
  295. of what you want to log:
  296. ```
  297. info - info and higher (>= is implicit)
  298. =debug - only the debug level
  299. !=info - everything but the info level
  300. <=notice - notice and below
  301. <warning - anything less than warning
  302. ```
  303. These can be used anywhere a loglevel is supplied, although they need to be either
  304. a quoted atom or a string.
  305. Internal log rotation
  306. ---------------------
  307. Lager can rotate its own logs or have it done via an external process. To
  308. use internal rotation, use the `size`, `date` and `count` values in the file
  309. backend's config:
  310. ```erlang
  311. [{file, "error.log"}, {level, error}, {size, 10485760}, {date, "$D0"}, {count, 5}]
  312. ```
  313. This tells lager to log error and above messages to `error.log` and to
  314. rotate the file at midnight or when it reaches 10mb, whichever comes first,
  315. and to keep 5 rotated logs in addition to the current one. Setting the
  316. count to 0 does not disable rotation, it instead rotates the file and keeps
  317. no previous versions around. To disable rotation set the size to 0 and the
  318. date to "".
  319. The `$D0` syntax is taken from the syntax newsyslog uses in newsyslog.conf.
  320. The relevant extract follows:
  321. ```
  322. Day, week and month time format: The lead-in character
  323. for day, week and month specification is a `$'-sign.
  324. The particular format of day, week and month
  325. specification is: [Dhh], [Ww[Dhh]] and [Mdd[Dhh]],
  326. respectively. Optional time fields default to
  327. midnight. The ranges for day and hour specifications
  328. are:
  329. hh hours, range 0 ... 23
  330. w day of week, range 0 ... 6, 0 = Sunday
  331. dd day of month, range 1 ... 31, or the
  332. letter L or l to specify the last day of
  333. the month.
  334. Some examples:
  335. $D0 rotate every night at midnight
  336. $D23 rotate every day at 23:00 hr
  337. $W0D23 rotate every week on Sunday at 23:00 hr
  338. $W5D16 rotate every week on Friday at 16:00 hr
  339. $M1D0 rotate on the first day of every month at
  340. midnight (i.e., the start of the day)
  341. $M5D6 rotate on every 5th day of the month at
  342. 6:00 hr
  343. ```
  344. To configure the crash log rotation, the following application variables are
  345. used:
  346. * `crash_log_size`
  347. * `crash_log_date`
  348. * `crash_log_count`
  349. See the `.app.src` file for further details.
  350. Syslog Support
  351. --------------
  352. Lager syslog output is provided as a separate application:
  353. [lager_syslog](https://github.com/basho/lager_syslog). It is packaged as a
  354. separate application so lager itself doesn't have an indirect dependency on a
  355. port driver. Please see the `lager_syslog` README for configuration information.
  356. Older Backends
  357. --------------
  358. Lager 2.0 changed the backend API, there are various 3rd party backends for
  359. lager available, but they may not have been updated to the new API. As they
  360. are updated, links to them can be re-added here.
  361. Exception Pretty Printing
  362. ----------------------
  363. ```erlang
  364. try
  365. foo()
  366. catch
  367. Class:Reason ->
  368. lager:error(
  369. "~nStacktrace:~s",
  370. [lager:pr_stacktrace(erlang:get_stacktrace(), {Class, Reason})])
  371. end.
  372. ```
  373. Record Pretty Printing
  374. ----------------------
  375. Lager's parse transform will keep track of any record definitions it encounters
  376. and store them in the module's attributes. You can then, at runtime, print any
  377. record a module compiled with the lager parse transform knows about by using the
  378. `lager:pr/2` function, which takes the record and the module that knows about the record:
  379. ```erlang
  380. lager:info("My state is ~p", [lager:pr(State, ?MODULE)])
  381. ```
  382. Often, `?MODULE` is sufficent, but you can obviously substitute that for a literal module name.
  383. `lager:pr` also works from the shell.
  384. Colored terminal output
  385. -----------------------
  386. If you have Erlang R16 or higher, you can tell lager's console backend to be colored. Simply
  387. add to lager's application environment config:
  388. ```erlang
  389. {colored, true}
  390. ```
  391. If you don't like the default colors, they are also configurable; see
  392. the `.app.src` file for more details.
  393. The output will be colored from the first occurrence of the atom color
  394. in the formatting configuration. For example:
  395. ```erlang
  396. {lager_console_backend, [info, {lager_default_formatter, [time, color, " [",severity,"] ", message, "\e[0m\r\n"]}]}
  397. ```
  398. This will make the entire log message, except time, colored. The
  399. escape sequence before the line break is needed in order to reset the
  400. color after each log message.
  401. Tracing
  402. -------
  403. Lager supports basic support for redirecting log messages based on log message
  404. attributes. Lager automatically captures the pid, module, function and line at the
  405. log message callsite. However, you can add any additional attributes you wish:
  406. ```erlang
  407. lager:warning([{request, RequestID},{vhost, Vhost}], "Permission denied to ~s", [User])
  408. ```
  409. Then, in addition to the default trace attributes, you'll be able to trace
  410. based on request or vhost:
  411. ```erlang
  412. lager:trace_file("logs/example.com.error", [{vhost, "example.com"}], error)
  413. ```
  414. To persist metadata for the life of a process, you can use `lager:md/1` to store metadata
  415. in the process dictionary:
  416. ```erlang
  417. lager:md([{zone, forbidden}])
  418. ```
  419. Note that `lager:md` will *only* accept a list of key/value pairs keyed by atoms.
  420. You can also omit the final argument, and the loglevel will default to
  421. `debug`.
  422. Tracing to the console is similar:
  423. ```erlang
  424. lager:trace_console([{request, 117}])
  425. ```
  426. In the above example, the loglevel is omitted, but it can be specified as the
  427. second argument if desired.
  428. You can also specify multiple expressions in a filter, or use the `*` atom as
  429. a wildcard to match any message that has that attribute, regardless of its
  430. value.
  431. Tracing to an existing logfile is also supported (but see **Multiple
  432. sink support** below):
  433. ```erlang
  434. lager:trace_file("log/error.log", [{module, mymodule}, {function, myfunction}], warning)
  435. ```
  436. To view the active log backends and traces, you can use the `lager:status()`
  437. function. To clear all active traces, you can use `lager:clear_all_traces()`.
  438. To delete a specific trace, store a handle for the trace when you create it,
  439. that you later pass to `lager:stop_trace/1`:
  440. ```erlang
  441. {ok, Trace} = lager:trace_file("log/error.log", [{module, mymodule}]),
  442. ...
  443. lager:stop_trace(Trace)
  444. ```
  445. Tracing to a pid is somewhat of a special case, since a pid is not a
  446. data-type that serializes well. To trace by pid, use the pid as a string:
  447. ```erlang
  448. lager:trace_console([{pid, "<0.410.0>"}])
  449. ```
  450. As of lager 2.0, you can also use a 3 tuple while tracing, where the second
  451. element is a comparison operator. The currently supported comparison operators
  452. are:
  453. * `<` - less than
  454. * `=` - equal to
  455. * `>` - greater than
  456. ```erlang
  457. lager:trace_console([{request, '>', 117}, {request, '<', 120}])
  458. ```
  459. Using `=` is equivalent to the 2-tuple form.
  460. ### Multiple sink support
  461. If using multiple sinks, there are limitations on tracing that you
  462. should be aware of.
  463. Traces are specific to a sink, which can be specified via trace
  464. filters:
  465. ```erlang
  466. lager:trace_file("log/security.log", [{sink, audit_event}, {function, myfunction}], warning)
  467. ```
  468. If no sink is thus specified, the default lager sink will be used.
  469. This has two ramifications:
  470. * Traces cannot intercept messages sent to a different sink.
  471. * Tracing to a file already opened via `lager:trace_file` will only be
  472. successful if the same sink is specified.
  473. The former can be ameliorated by opening multiple traces; the latter
  474. can be fixed by rearchitecting lager's file backend, but this has not
  475. been tackled.
  476. ### Traces from configuration
  477. Lager supports starting traces from its configuration file. The keyword
  478. to define them is `traces`, followed by a proplist of tuples that define
  479. a backend handler and zero or more filters in a required list,
  480. followed by an optional message severity level.
  481. An example looks like this:
  482. ```erlang
  483. {lager, [
  484. {handlers, [...]},
  485. {traces, [
  486. %% handler, filter, message level (defaults to debug if not given)
  487. {lager_console_backend, [{module, foo}], info },
  488. {{lager_file_backend, "trace.log"}, [{request, '>', 120}], error},
  489. {{lager_file_backend, "event.log"}, [{module, bar}] } %% implied debug level here
  490. ]}
  491. ]}.
  492. ```
  493. In this example, we have three traces. One using the console backend, and two
  494. using the file backend. If the message severity level is left out, it defaults
  495. to `debug` as in the last file backend example.
  496. The `traces` keyword works on alternative sinks too but the same limitations
  497. and caveats noted above apply.
  498. **IMPORTANT**: You **must** define a severity level in all lager releases
  499. up to and including 3.1.0 or previous. The 2-tuple form wasn't added until
  500. 3.2.0.
  501. Setting dynamic metadata at compile-time
  502. ----------------------------------------
  503. Lager supports supplying metadata from external sources. You can add these by
  504. using the `{lager_parse_transform_functions, X}` option. In rebar, you can
  505. add it to `erl_opts`:
  506. ```erlang
  507. {erl_opts, [{parse_transform, lager_transform},
  508. {lager_function_transforms,
  509. [
  510. {metadata_placeholder, on_emit, {module_name, function_name}},
  511. {other_metadata_placeholder, on_log, {module_name, function_name}}
  512. ]}]}.
  513. ```
  514. The MF called should take no arguments and should return a value that can be be
  515. formatted into a log message.
  516. Following the placeholder atom you have to specify either `on_emit` or
  517. `on_log`. This is tell the function to resolve at the time of emit or
  518. the time of logging.
  519. `on_emit`:
  520. * Functions are not resolve until the message is emitted.
  521. * If the function cannot be resolve, not loaded or produces errors then
  522. `undefined` or the provided default value will be returned.
  523. * If the function call is dependent on another process, there is the chance
  524. that message will be emitted after the dependent process has died.
  525. `on_log`:
  526. * Functions are resolved regardless whether the message is emitted or not
  527. * If the function cannot be resolved or not loaded the errors are not handled.
  528. * Any potential errors should be handled by the calling function. If the
  529. function returns `undefined` then it should return the provided default
  530. value if supplied.
  531. * Because the function is resolved at log time there should be less change
  532. of the dependent process dying before you can resolve it, especially if
  533. you are logging from the app which contains the module:function.
  534. This metadata is also persistent across processes.
  535. **IMPORTANT**: Since `on_emit` relies on function calls injected at the
  536. point where a log message is emitted, your logging performance (ops/sec)
  537. will be impacted by what the functions you call do and how much latency they
  538. may introduce. This impact will even greater with `on_log` since the calls
  539. are injected at the point a message is logged.
  540. Setting the truncation limit at compile-time
  541. --------------------------------------------
  542. Lager defaults to truncating messages at 4096 bytes, you can alter this by
  543. using the `{lager_truncation_size, X}` option. In rebar, you can add it to
  544. `erl_opts`:
  545. ```erlang
  546. {erl_opts, [{parse_transform, lager_transform}, {lager_truncation_size, 1024}]}.
  547. ```
  548. You can also pass it to `erlc`, if you prefer:
  549. ```
  550. erlc -pa lager/ebin +'{parse_transform, lager_transform}' +'{lager_truncation_size, 1024}' file.erl
  551. ```
  552. Suppress applications and supervisors start/stop logs
  553. -----------------------------------------------------
  554. If you don't want to see supervisors and applications start/stop logs in debug
  555. level of your application, you can use these configs to turn it off:
  556. ```erlang
  557. {lager, [{suppress_application_start_stop, true},
  558. {suppress_supervisor_start_stop, true}]}
  559. ```
  560. 3.x Changelog
  561. -------------
  562. 3.3.0 - 16 February 2017
  563. * Docs: Fix documentation to make 'it' unambiguous when discussing asychronous
  564. operation. (#387)
  565. * Test: Fix test flappiness due to insufficient sanitation between test runs (#384, #385)
  566. * Feature: Allow metadata only logging. (#380)
  567. * Feature: Add an upper case severity formatter (#372)
  568. * Feature: Add support for suppressing start/stop messages from supervisors (#368)
  569. * Bugfix: Fix ranch crash messages (#366)
  570. * Test: Update Travis config for 18.3 and 19.0 (#365)
  571. 3.2.4 - 11 October 2016
  572. * Test: Fix dialyzer warnings.
  573. 3.2.3 - 29 September 2016
  574. * Dependency: Update to goldrush 0.19
  575. 3.2.2 - 22 September 2016
  576. * Bugfix: Backwards-compatibility fix for `{crash_log, undefined}` (#371)
  577. * Fix documentation/README to reflect the preference for using `false`
  578. as the `crash_log` setting value rather than `undefined` to indicate
  579. that the crash log should not be written (#364)
  580. * Bugfix: Backwards-compatibility fix for `lager_file_backend` "legacy"
  581. configuration format (#374)
  582. 3.2.1 - 10 June 2016
  583. * Bugfix: Recent `get_env` changes resulted in launch failure (#355)
  584. * OTP: Support typed records for Erlang 19.0 (#361)
  585. 3.2.0 - 08 April 2016
  586. * Feature: Optional sink killer to shed load when mailbox size exceeds a
  587. configurable high water mark (#346)
  588. * Feature: Export `configure_sink/2` so users may dynamically configure
  589. previously setup and parse transformed sinks from their own code. (#342)
  590. * Feature: Re-enable Travis CI and update .travis.yml (#340)
  591. * Bugfix: Fix test race conditions for Travis CI (#344)
  592. * Bugfix: Add the atom 'none' to the log_level() type so downstream
  593. users won't get dialyzer failures if they use the 'none' log level. (#343)
  594. * Bugfix: Fix typo in documentation. (#341)
  595. * Bugfix: Fix OTP 18 test failures due to `warning_map/0` response
  596. change. (#337)
  597. * Bugfix: Make sure traces that use the file backend work correctly
  598. when specified in lager configuration. (#336)
  599. * Bugfix: Use `lager_app:get_env/3` for R15 compatibility. (#335)
  600. * Bugfix: Make sure lager uses `id` instead of `name` when reporting
  601. supervisor children failures. (The atom changed in OTP in 2014.) (#334)
  602. * Bugfix: Make lager handle improper iolists (#327)
  603. 3.1.0 - 27 January 2016
  604. * Feature: API calls to a rotate handler, sink or all. This change
  605. introduces a new `rotate` message for 3rd party lager backends; that's
  606. why this is released as a new minor version number. (#311)
  607. 3.0.3 - 27 January 2016
  608. * Feature: Pretty printer for human readable stack traces (#298)
  609. * Feature: Make error reformatting optional (#305)
  610. * Feature: Optional and explicit sink for error_logger messages (#303)
  611. * Bugfix: Always explicitly close a file after its been rotated (#316)
  612. * Bugfix: If a relative path already contains the log root, do not add it again (#317)
  613. * Bugfix: Configure and start extra sinks before traces are evaluated (#307)
  614. * Bugfix: Stop and remove traces correctly (#306)
  615. * Bugfix: A byte value of 255 is valid for Unicode (#300)
  616. * Dependency: Bump to goldrush 0.1.8 (#313)