• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

diags.i

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 
00025 
00026 //Diags *diags;
00027 #define DIAGS_LOG_FILE "diags.log"
00028 
00029 //////////////////////////////////////////////////////////////////////////////
00030 //
00031 //      void reconfigure_diags()
00032 //
00033 //      This function extracts the current diags configuration settings from
00034 //      records.config, and rebuilds the Diags data structures.
00035 //
00036 //////////////////////////////////////////////////////////////////////////////
00037 
00038 static void
00039 reconfigure_diags()
00040 {
00041   int i;
00042   DiagsConfigState c;
00043 
00044 
00045   // initial value set to 0 or 1 based on command line tags
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   // read output routing values
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   // clear out old tag tables //
00065   //////////////////////////////
00066 
00067   diags->deactivate_all(DiagsTagType_Debug);
00068   diags->deactivate_all(DiagsTagType_Action);
00069 
00070   //////////////////////////////////////////////////////////////////////
00071   //                     add new tag tables 
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   // change the diags config values //
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 }

Generated by  doxygen 1.7.1