BladeLogConfiguration.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package org.springblade.common.config;
  18. import lombok.AllArgsConstructor;
  19. import org.springblade.common.event.ApiLogListener;
  20. import org.springblade.common.event.ErrorLogListener;
  21. import org.springblade.common.event.UsualLogListener;
  22. import org.springblade.core.launch.props.BladeProperties;
  23. import org.springblade.core.launch.server.ServerInfo;
  24. import org.springblade.modules.system.service.ILogService;
  25. import org.springframework.context.annotation.Bean;
  26. import org.springframework.context.annotation.Configuration;
  27. /**
  28. * 日志工具自动配置
  29. *
  30. * @author Chill
  31. */
  32. @Configuration(proxyBeanMethods = false)
  33. @AllArgsConstructor
  34. public class BladeLogConfiguration {
  35. private final ILogService logService;
  36. private final ServerInfo serverInfo;
  37. private final BladeProperties bladeProperties;
  38. @Bean(name = "apiLogListener")
  39. public ApiLogListener apiLogListener() {
  40. return new ApiLogListener(logService, serverInfo, bladeProperties);
  41. }
  42. @Bean(name = "errorEventListener")
  43. public ErrorLogListener errorEventListener() {
  44. return new ErrorLogListener(logService, serverInfo, bladeProperties);
  45. }
  46. @Bean(name = "usualEventListener")
  47. public UsualLogListener usualEventListener() {
  48. return new UsualLogListener(logService, serverInfo, bladeProperties);
  49. }
  50. }