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.

65 lines
1.6 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. try
  13. {
  14. Time time;
  15. log4cplus::tstring str;
  16. time = Time::gettimeofday ();
  17. str = time.getFormattedTime (fmtstr);
  18. log4cplus::tcout << LOG4CPLUS_TEXT ("now: ") << str << std::endl;
  19. time = Time (0, 7);
  20. str = time.getFormattedTime (fmtstr);
  21. log4cplus::tcout << str << std::endl;
  22. time = Time (0, 17);
  23. str = time.getFormattedTime (fmtstr);
  24. log4cplus::tcout << str << std::endl;
  25. time = Time (0, 123);
  26. str = time.getFormattedTime (fmtstr);
  27. log4cplus::tcout << str << std::endl;
  28. time = Time (0, 1234);
  29. str = time.getFormattedTime (fmtstr);
  30. log4cplus::tcout << str << std::endl;
  31. time = Time (0, 12345);
  32. str = time.getFormattedTime (fmtstr);
  33. log4cplus::tcout << str << std::endl;
  34. time = Time (0, 123456);
  35. str = time.getFormattedTime (fmtstr);
  36. log4cplus::tcout << str << std::endl;
  37. time = Time (0, 0);
  38. str = time.getFormattedTime (fmtstr);
  39. log4cplus::tcout << str << std::endl;
  40. }
  41. catch(std::exception const & e)
  42. {
  43. std::cout << "Exception: " << e.what () << std::endl;
  44. }
  45. catch(...)
  46. {
  47. std::cout << "Exception..." << std::endl;
  48. }
  49. std::cout << "Exiting main()..." << std::endl;
  50. return 0;
  51. }