Changeset 111 for hvcontrol/src


Ignore:
Timestamp:
09/23/09 11:07:01 (15 years ago)
Author:
ogrimm
Message:
Small bug fix to printing routine
Location:
hvcontrol/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • hvcontrol/src/ProcessIO.cc

    r100 r111  
    554554  va_list ArgumentPointer;
    555555  va_start(ArgumentPointer, Format);
    556   PrintMessage(Target, Format, ArgumentPointer);
     556  PrintMessage(Format, ArgumentPointer, Target);
    557557  va_end(ArgumentPointer);
    558558}
     
    562562  va_list ArgumentPointer;
    563563  va_start(ArgumentPointer, Format);
    564   if (CmdFromSocket) PrintMessage(MsgToSocket|MsgToLog, Format, ArgumentPointer);
    565   else PrintMessage(MsgToConsole|MsgToLog, Format, ArgumentPointer);
     564  if (CmdFromSocket) PrintMessage(Format, ArgumentPointer, MsgToSocket|MsgToLog);
     565  else PrintMessage(Format, ArgumentPointer, MsgToConsole|MsgToLog);
    566566  va_end(ArgumentPointer);
    567567}
    568568
    569569// Function doing the actual printing work
    570 void ProcessIO::PrintMessage(int Target, const char *Format, va_list ArgumentPointer) {
     570// It is important that Target is here the last argument, otherwise
     571// there can be confusion with the variadic versions (this function is
     572// called instead of PrintMessage(int, const char *, ...)
     573void ProcessIO::PrintMessage(const char *Format, va_list ArgumentPointer, int Target) {
    571574
    572575  char Textbuffer[MAX_COM_SIZE];
     
    592595      if(Textbuffer[i] == '\r') Textbuffer[i] = '\n';
    593596    }
    594     fprintf(Logfile, "%s", Textbuffer);
     597    time_t Time;
     598    strftime(Textbuffer+strlen(Textbuffer)+1,MAX_COM_SIZE-strlen(Textbuffer)-1, "%d/%m/%y %X", localtime(&(Time=time(NULL))));
     599    fprintf(Logfile, "%s: %s", Textbuffer+strlen(Textbuffer)+1, Textbuffer);
    595600    fflush(Logfile);
    596601  }
  • hvcontrol/src/ProcessIO.h

    r100 r111  
    6565  void PrintMessage(int, const char *, ...);
    6666  void PrintMessage(const char *, ...);
    67   void PrintMessage(int, const char *, va_list);
     67  void PrintMessage(const char *, va_list, int);
    6868  void CommandControl(char*);
    6969  bool RampVoltage(unsigned int, int, int, int);
Note: See TracChangeset for help on using the changeset viewer.