aarch64_test.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include <iostream>
  2. #include <glog/logging.h>
  3. GOOGLE_GLOG_DLL_DECL void shut_down_logging(const char* data, int size)
  4. {
  5. time_t tt;
  6. time( &tt );
  7. tt = tt + 8*3600; // transform the time zone
  8. tm* t= gmtime( &tt );
  9. char buf[255]={0};
  10. sprintf(buf,"./%d%02d%02d-%02d%02d%02d-dump.txt",
  11. t->tm_year + 1900,
  12. t->tm_mon + 1,
  13. t->tm_mday,
  14. t->tm_hour,
  15. t->tm_min,
  16. t->tm_sec);
  17. FILE* tp_file=fopen(buf,"w");
  18. fprintf(tp_file,data,strlen(data));
  19. fclose(tp_file);
  20. }
  21. void init_glog()
  22. {
  23. time_t tt = time(0);//时间cuo
  24. struct tm* t = localtime(&tt);
  25. char strYear[255]={0};
  26. char strMonth[255]={0};
  27. char strDay[255]={0};
  28. sprintf(strYear,"%04d", t->tm_year+1900);
  29. sprintf(strMonth,"%02d", t->tm_mon+1);
  30. sprintf(strDay,"%02d", t->tm_mday);
  31. char buf[255]={0};
  32. getcwd(buf,255);
  33. char strdir[255]={0};
  34. sprintf(strdir,"%s/log/%s/%s/%s", buf,strYear,strMonth,strDay);
  35. // PathCreator creator;
  36. // creator.Mkdir(strdir);
  37. char logPath[255] = { 0 };
  38. sprintf(logPath, "%s/", strdir);
  39. FLAGS_max_log_size = 100;
  40. FLAGS_logbufsecs = 0;
  41. google::InitGoogleLogging("clamp_safety");
  42. google::SetStderrLogging(google::INFO);
  43. google::SetLogDestination(0, logPath);
  44. google::SetLogFilenameExtension("zxlog");
  45. google::InstallFailureSignalHandler();
  46. google::InstallFailureWriter(&shut_down_logging);
  47. FLAGS_colorlogtostderr = true; // Set log color
  48. FLAGS_logbufsecs = 0; // Set log output speed(s)
  49. FLAGS_max_log_size = 1024; // Set max log file size(GB)
  50. FLAGS_stop_logging_if_full_disk = true;
  51. }
  52. int main() {
  53. printf("aarch64 test begain.\n");
  54. init_glog();
  55. return -1;
  56. }