Skip to content
Snippets Groups Projects
Commit e13e4957 authored by rswindell's avatar rswindell
Browse files

Beautify log output a bit.

parent 5b0e5c8c
Branches
Tags
No related merge requests found
...@@ -1223,6 +1223,7 @@ int main(int argc, char **argv) ...@@ -1223,6 +1223,7 @@ int main(int argc, char **argv)
if(log_fp!=NULL) { if(log_fp!=NULL) {
time_t now=time(NULL); time_t now=time(NULL);
fprintf(log_fp,"%.15s Log closed\n", ctime(&now)+4); fprintf(log_fp,"%.15s Log closed\n", ctime(&now)+4);
fprintf(log_fp,"---------------\n");
fclose(log_fp); fclose(log_fp);
log_fp=NULL; log_fp=NULL;
} }
......
...@@ -24,6 +24,7 @@ char terminal[TELNET_TERM_MAXLEN+1]; ...@@ -24,6 +24,7 @@ char terminal[TELNET_TERM_MAXLEN+1];
uchar telnet_local_option[0x100]; uchar telnet_local_option[0x100];
uchar telnet_remote_option[0x100]; uchar telnet_remote_option[0x100];
extern char *log_levels[];
extern FILE* log_fp; extern FILE* log_fp;
int telnet_log_level; int telnet_log_level;
...@@ -39,7 +40,7 @@ static int lprintf(int level, const char *fmt, ...) ...@@ -39,7 +40,7 @@ static int lprintf(int level, const char *fmt, ...)
vsnprintf(sbuf,sizeof(sbuf),fmt,argptr); vsnprintf(sbuf,sizeof(sbuf),fmt,argptr);
sbuf[sizeof(sbuf)-1]=0; sbuf[sizeof(sbuf)-1]=0;
va_end(argptr); va_end(argptr);
return(fprintf(log_fp, "%s\n", sbuf)); return(fprintf(log_fp, "Telnet %s %s\n", log_levels[level], sbuf));
} }
void putcom(BYTE* buf, size_t len) void putcom(BYTE* buf, size_t len)
...@@ -60,12 +61,12 @@ static void send_telnet_cmd(uchar cmd, uchar opt) ...@@ -60,12 +61,12 @@ static void send_telnet_cmd(uchar cmd, uchar opt)
char buf[16]; char buf[16];
if(cmd<TELNET_WILL) { if(cmd<TELNET_WILL) {
lprintf(LOG_INFO,"TX Telnet command: %s" lprintf(LOG_INFO,"TX: %s"
,telnet_cmd_desc(cmd)); ,telnet_cmd_desc(cmd));
sprintf(buf,"%c%c",TELNET_IAC,cmd); sprintf(buf,"%c%c",TELNET_IAC,cmd);
putcom(buf,2); putcom(buf,2);
} else { } else {
lprintf(LOG_INFO,"TX Telnet command: %s %s" lprintf(LOG_INFO,"TX: %s %s"
,telnet_cmd_desc(cmd), telnet_opt_desc(opt)); ,telnet_cmd_desc(cmd), telnet_opt_desc(opt));
sprintf(buf,"%c%c%c",TELNET_IAC,cmd,opt); sprintf(buf,"%c%c%c",TELNET_IAC,cmd,opt);
putcom(buf,3); putcom(buf,3);
...@@ -135,7 +136,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen) ...@@ -135,7 +136,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen)
,TELNET_IAC,TELNET_SB ,TELNET_IAC,TELNET_SB
,TELNET_TERM_TYPE,TELNET_TERM_IS ,TELNET_TERM_TYPE,TELNET_TERM_IS
,TELNET_IAC,TELNET_SE); ,TELNET_IAC,TELNET_SE);
lprintf(LOG_INFO,"TX Telnet command: Terminal Type is ANSI"); lprintf(LOG_INFO,"TX: Terminal Type is ANSI");
putcom(buf,len); putcom(buf,len);
request_telnet_opt(TELNET_WILL, TELNET_NEGOTIATE_WINDOW_SIZE); request_telnet_opt(TELNET_WILL, TELNET_NEGOTIATE_WINDOW_SIZE);
} }
...@@ -147,7 +148,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen) ...@@ -147,7 +148,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen)
} }
else if(telnet_cmdlen>=3) { /* telnet option negotiation */ else if(telnet_cmdlen>=3) { /* telnet option negotiation */
lprintf(LOG_INFO,"RX Telnet command: %s %s" lprintf(LOG_INFO,"RX: %s %s"
,telnet_cmd_desc(command),telnet_opt_desc(option)); ,telnet_cmd_desc(command),telnet_opt_desc(option));
if(command==TELNET_DO || command==TELNET_DONT) { /* local options */ if(command==TELNET_DO || command==TELNET_DONT) { /* local options */
...@@ -179,7 +180,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen) ...@@ -179,7 +180,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen)
buf[6]=term.height&0xff; buf[6]=term.height&0xff;
buf[7]=TELNET_IAC; buf[7]=TELNET_IAC;
buf[8]=TELNET_SE; buf[8]=TELNET_SE;
lprintf(LOG_INFO,"TX Telnet command: Window Size is %u x %u" lprintf(LOG_INFO,"TX: Window Size is %u x %u"
,term.width, term.height); ,term.width, term.height);
putcom(buf,9); putcom(buf,9);
} }
......
...@@ -254,7 +254,7 @@ static int lputs(void* cbdata, int level, const char* str) ...@@ -254,7 +254,7 @@ static int lputs(void* cbdata, int level, const char* str)
#endif #endif
if(log_fp!=NULL && level <= log_level) if(log_fp!=NULL && level <= log_level)
fprintf(log_fp,"%s: %s\n",log_levels[level], str); fprintf(log_fp,"Xfer %s: %s\n",log_levels[level], str);
if(level > LOG_INFO) if(level > LOG_INFO)
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment