Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

64 wiersze
1.8 KiB

14 lat temu
  1. %% Copyright (c) 2011 Basho Technologies, Inc. All Rights Reserved.
  2. %%
  3. %% This file is provided to you under the Apache License,
  4. %% Version 2.0 (the "License"); you may not use this file
  5. %% except in compliance with the License. You may obtain
  6. %% a copy of the License at
  7. %%
  8. %% http://www.apache.org/licenses/LICENSE-2.0
  9. %%
  10. %% Unless required by applicable law or agreed to in writing,
  11. %% software distributed under the License is distributed on an
  12. %% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. %% KIND, either express or implied. See the License for the
  14. %% specific language governing permissions and limitations
  15. %% under the License.
  16. -define(LEVELS,
  17. [debug, info, notice, warning, error, critical, alert, emergency]).
  18. -define(DEBUG, 7).
  19. -define(INFO, 6).
  20. -define(NOTICE, 5).
  21. -define(WARNING, 4).
  22. -define(ERROR, 3).
  23. -define(CRITICAL, 2).
  24. -define(ALERT, 1).
  25. -define(EMERGENCY, 0).
  26. -define(LEVEL2NUM(Level),
  27. case Level of
  28. debug -> ?DEBUG;
  29. info -> ?INFO;
  30. notice -> ?NOTICE;
  31. warning -> ?WARNING;
  32. error -> ?ERROR;
  33. critical -> ?CRITICAL;
  34. alert -> ?ALERT;
  35. emergency -> ?EMERGENCY
  36. end).
  37. -define(NUM2LEVEL(Num),
  38. case Num of
  39. ?DEBUG -> debug;
  40. ?INFO -> info;
  41. ?NOTICE -> notice;
  42. ?WARNING -> warning;
  43. ?ERROR -> error;
  44. ?CRITICAL -> critical;
  45. ?ALERT -> alert;
  46. ?EMERGENCY -> emergency
  47. end).
  48. -define(SHOULD_LOG(Level),
  49. ?LEVEL2NUM(Level) =< lager_mochiglobal:get(loglevel, ?DEBUG)).
  50. %% internal non-blocking logging call
  51. -define(INT_LOG(Level, Format, Args),
  52. case ?SHOULD_LOG(Level) of
  53. true ->
  54. gen_event:notify(lager_event, {log, lager_util:level_to_num(Level),
  55. lager_util:format_time(), [io_lib:format("[~p] ~p ", [Level, self()]), io_lib:format(Format, Args)]});
  56. _ -> ok
  57. end).