Changeset 111
- Timestamp:
- 09/23/09 11:07:01 (15 years ago)
- Location:
- hvcontrol
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
hvcontrol/hvcontrol.cpp
r93 r111 141 141 void ConsoleCommand(ProcessIO *m) { 142 142 143 time_t Time; 144 char Buf[MAX_COM_SIZE], *Command; 143 char *Command; 145 144 146 145 while (!m->Exit) { … … 167 166 168 167 // 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); 171 169 172 170 // Process command … … 202 200 struct hostent *ClientName; 203 201 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]; 206 203 207 204 // Set up server socket … … 258 255 259 256 // 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); 262 258 263 259 // Process command -
hvcontrol/src/ProcessIO.cc
r100 r111 554 554 va_list ArgumentPointer; 555 555 va_start(ArgumentPointer, Format); 556 PrintMessage( Target, Format, ArgumentPointer);556 PrintMessage(Format, ArgumentPointer, Target); 557 557 va_end(ArgumentPointer); 558 558 } … … 562 562 va_list ArgumentPointer; 563 563 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); 566 566 va_end(ArgumentPointer); 567 567 } 568 568 569 569 // 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 *, ...) 573 void ProcessIO::PrintMessage(const char *Format, va_list ArgumentPointer, int Target) { 571 574 572 575 char Textbuffer[MAX_COM_SIZE]; … … 592 595 if(Textbuffer[i] == '\r') Textbuffer[i] = '\n'; 593 596 } 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); 595 600 fflush(Logfile); 596 601 } -
hvcontrol/src/ProcessIO.h
r100 r111 65 65 void PrintMessage(int, const char *, ...); 66 66 void PrintMessage(const char *, ...); 67 void PrintMessage( int, const char *, va_list);67 void PrintMessage(const char *, va_list, int); 68 68 void CommandControl(char*); 69 69 bool RampVoltage(unsigned int, int, int, int);
Note:
See TracChangeset
for help on using the changeset viewer.