Changeset 111


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

Legend:

Unmodified
Added
Removed
  • hvcontrol/hvcontrol.cpp

    r93 r111  
    141141void ConsoleCommand(ProcessIO *m) {
    142142
    143   time_t Time;
    144   char Buf[MAX_COM_SIZE], *Command;
     143  char *Command;
    145144
    146145  while (!m->Exit) {
     
    167166
    168167    // Log command
    169     strftime(Buf,MAX_COM_SIZE, "%d/%m/%y %X", localtime(&(Time=time(NULL))));
    170     m->PrintMessage(MsgToLog, "CONSOLE(%s)> %s\n", Buf, Command);
     168    m->PrintMessage(MsgToLog, "CONSOLE> %s\n", Command);
    171169
    172170    // Process command     
     
    202200  struct hostent *ClientName;
    203201  socklen_t SizeClientAddress=sizeof(ClientAddress);
    204   char Command[MAX_COM_SIZE], Buf[MAX_COM_SIZE];
    205   time_t Time;
     202  char Command[MAX_COM_SIZE];
    206203
    207204  // Set up server socket
     
    258255     
    259256      // Log command
    260       strftime(Buf, MAX_COM_SIZE, "%d/%m/%y %X", localtime(&(Time=time(NULL))));
    261       m->PrintMessage(MsgToConsole|MsgToLog, "SOCKET(%s)> %s\n", Buf, Command);
     257      m->PrintMessage(MsgToConsole|MsgToLog, "SOCKET> %s\n", Command);
    262258           
    263259      // Process command
  • 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.