You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 line
1.5 KiB

14 年之前
14 年之前
14 年之前
14 年之前
14 年之前
14 年之前
14 年之前
14 年之前
14 年之前
  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. Features
  7. - Finer grained log levels (debug, info, notice, warning, error, critical,
  8. alert, emergency)
  9. - Logger calls are transformed using a parse transform to allow capturing
  10. Module/Function/Line/Pid information
  11. - When no handler is consuming a log level (eg. debug) no event is even sent
  12. to the log handler
  13. - Supports multiple backends, including console, file and syslog.
  14. * Usage
  15. To use lager in your application, you need to define it as a rebar dep or have
  16. some other way of including it in erlang's path. You can then add the
  17. following option to the erlang compiler flags
  18. #+BEGIN_EXAMPLE
  19. {parse_transform, lager_transform}
  20. #+END_EXAMPLE
  21. Alternately, you can add it to the module you which to compile with logging
  22. enabled:
  23. #+BEGIN_EXAMPLE
  24. -compile([{parse_transform, lager_transform}]).
  25. #+END_EXAMPLE
  26. Once you have built your code with lager, you can then generate log messages
  27. by doing the following:
  28. #+BEGIN_EXAMPLE
  29. lager:error("Some message")
  30. #+END_EXAMPLE
  31. Or:
  32. #+BEGIN_EXAMPLE
  33. lager:warning("Some message with a term: ~p", [Term])
  34. #+END_EXAMPLE
  35. The general form is lager:Severity() where Severity is one of the log levels
  36. mentioned above.
  37. * Configuration
  38. TODO