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.

66 lines
1.7 KiB

  1. #include <log4cplus/helpers/timehelper.h>
  2. #include <log4cplus/streams.h>
  3. #include <iostream>
  4. using namespace log4cplus;
  5. using namespace log4cplus::helpers;
  6. log4cplus::tchar const fmtstr[] =
  7. LOG4CPLUS_TEXT("%s, %Q%%q%q %%Q %%q=%%%q%%;%%q, %%Q=%Q");
  8. int
  9. main()
  10. {
  11. std::cout << "Entering main()..." << std::endl;
  12. log4cplus::initialize ();
  13. try
  14. {
  15. Time time;
  16. log4cplus::tstring str;
  17. time = Time::gettimeofday ();
  18. str = time.getFormattedTime (fmtstr);
  19. log4cplus::tcout << LOG4CPLUS_TEXT ("now: ") << str << std::endl;
  20. time = Time (0, 7);
  21. str = time.getFormattedTime (fmtstr);
  22. log4cplus::tcout << str << std::endl;
  23. time = Time (0, 17);
  24. str = time.getFormattedTime (fmtstr);
  25. log4cplus::tcout << str << std::endl;
  26. time = Time (0, 123);
  27. str = time.getFormattedTime (fmtstr);
  28. log4cplus::tcout << str << std::endl;
  29. time = Time (0, 1234);
  30. str = time.getFormattedTime (fmtstr);
  31. log4cplus::tcout << str << std::endl;
  32. time = Time (0, 12345);
  33. str = time.getFormattedTime (fmtstr);
  34. log4cplus::tcout << str << std::endl;
  35. time = Time (0, 123456);
  36. str = time.getFormattedTime (fmtstr);
  37. log4cplus::tcout << str << std::endl;
  38. time = Time (0, 0);
  39. str = time.getFormattedTime (fmtstr);
  40. log4cplus::tcout << str << std::endl;
  41. }
  42. catch(std::exception const & e)
  43. {
  44. std::cout << "Exception: " << e.what () << std::endl;
  45. }
  46. catch(...)
  47. {
  48. std::cout << "Exception..." << std::endl;
  49. }
  50. std::cout << "Exiting main()..." << std::endl;
  51. return 0;
  52. }