Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 #define DIAGS_LOG_FILE "diags.log"
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 static void
00039 reconfigure_diags()
00040 {
00041   int i;
00042   DiagsConfigState c;
00043 
00044 
00045   
00046   c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
00047   c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
00048 
00049   c.enabled[DiagsTagType_Debug] = 1;
00050   c.enabled[DiagsTagType_Action] = 1;
00051   diags->show_location = 1;
00052 
00053 
00054   
00055   for (i = 0; i < DiagsLevel_Count; i++) {
00056 
00057     c.outputs[i].to_stdout = 0;
00058     c.outputs[i].to_stderr = 1;
00059     c.outputs[i].to_syslog = 1;
00060     c.outputs[i].to_diagslog = 1;
00061   }
00062 
00063 
00064   
00065 
00066 
00067   diags->deactivate_all(DiagsTagType_Debug);
00068   diags->deactivate_all(DiagsTagType_Action);
00069 
00070 
00071   
00072 
00073 
00074   if (diags->base_debug_tags)
00075     diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
00076   if (diags->base_action_tags)
00077     diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
00078 
00079 
00080   
00081 
00082 #if !defined(__GNUC__) && !defined(hpux)
00083   diags->config = c;
00084 #else
00085   memcpy(((void *) &diags->config), ((void *) &c), sizeof(DiagsConfigState));
00086 #endif
00087 
00088 }
00089 
00090 
00091 
00092 static void
00093 init_diags(char *bdt, char *bat)
00094 {
00095   FILE *diags_log_fp;
00096   char diags_logpath[500];
00097   strcpy(diags_logpath, DIAGS_LOG_FILE);
00098 
00099   diags_log_fp = fopen(diags_logpath, "w");
00100   if (diags_log_fp) {
00101     int status;
00102     status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
00103     if (status != 0) {
00104       fclose(diags_log_fp);
00105       diags_log_fp = NULL;
00106     }
00107   }
00108 
00109   diags = new Diags(bdt, bat, diags_log_fp);
00110 
00111   if (diags_log_fp == NULL) {
00112     SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
00113 
00114     diags->print(NULL, DL_Warning, NULL, &loc,
00115                  "couldn't open diags log file '%s', " "will not log to this file", diags_logpath);
00116   }
00117 
00118   diags->print(NULL, DL_Status, "STATUS", NULL, "opened %s", diags_logpath);
00119   reconfigure_diags();
00120 
00121 }