Log.cpp 678 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "Log.h"
  2. #include <QCoreApplication>
  3. #include <QThread>
  4. Log::Log(QObject *parent) :
  5. QObject(parent)
  6. {
  7. QString configPath = QCoreApplication::applicationDirPath() + "/log4j.properties";
  8. Log4Qt::PropertyConfigurator::configure(configPath);
  9. }
  10. Log::~Log()
  11. {
  12. }
  13. Log* Log::instance()
  14. {
  15. static Log log;
  16. return &log;
  17. }
  18. void Log::debug(const QString &log)
  19. {
  20. logger()->debug(log);
  21. }
  22. void Log::info(const QString &log)
  23. {
  24. logger()->info(log);
  25. }
  26. void Log::warn(const QString &log)
  27. {
  28. logger()->warn(log);
  29. }
  30. void Log::error(const QString &log)
  31. {
  32. logger()->error(log);
  33. }
  34. void Log::fatal(const QString &log)
  35. {
  36. logger()->fatal(log);
  37. }