Skip to content

Commit

Permalink
cdp: Remove escape chars for colors in log
Browse files Browse the repository at this point in the history
Usually they are not interpreted on log
and they are messing up the log itsefl
  • Loading branch information
Federico Favaro committed Jul 1, 2016
1 parent 1b1a781 commit 01b16ce
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 20 deletions.
10 changes: 0 additions & 10 deletions modules/cdp/globals.h
Expand Up @@ -64,14 +64,4 @@ extern gen_lock_t *shutdownx_lock; /**< lock used on shutdown */

extern pid_t *dp_first_pid; /**< first pid that we started from */

/* ANSI Terminal colors */
#define ANSI_GRAY "\033[01;30m"
#define ANSI_BLINK_RED "\033[00;31m"
#define ANSI_RED "\033[01;31m"
#define ANSI_GREEN "\033[01;32m"
#define ANSI_YELLOW "\033[01;33m"
#define ANSI_BLUE "\033[01;34m"
#define ANSI_MAGENTA "\033[01;35m"
#define ANSI_CYAN "\033[01;36m"
#define ANSI_WHITE "\033[01;37m"
#endif
6 changes: 3 additions & 3 deletions modules/cdp/peermanager.c
Expand Up @@ -141,9 +141,9 @@ void log_peer_list()

LM_DBG("--- Peer List: ---\n");
for(p = peer_list->head;p;p = p->next){
LM_DBG(ANSI_GREEN" S["ANSI_YELLOW"%s"ANSI_GREEN"] "ANSI_BLUE"%.*s:%d"ANSI_GREEN" D["ANSI_RED"%c"ANSI_GREEN"]\n",dp_states[p->state],p->fqdn.len,p->fqdn.s,p->port,p->is_dynamic?'X':' ');
LM_DBG("State of peer: %s FQDN: %.*s Port: %d Is dynamic %c\n",dp_states[p->state],p->fqdn.len,p->fqdn.s,p->port,p->is_dynamic?'X':' ');
for(i=0;i<p->applications_cnt;i++)
LM_DBG(ANSI_YELLOW"\t [%d,%d]"ANSI_GREEN"\n",p->applications[i].id,p->applications[i].vendor);
LM_DBG("Application ID: %d, Application Vendor: %d \n",p->applications[i].id,p->applications[i].vendor);
}
LM_DBG("------------------\n");
}
Expand Down Expand Up @@ -275,7 +275,7 @@ int peer_timer(time_t now,void *ptr)
}

if (p->activity+config->tc<=now){
LM_DBG("peer_timer(): Peer %.*s \tState %d \n",p->fqdn.len,p->fqdn.s,p->state);
LM_DBG("peer_timer(): Peer %.*s State %d \n",p->fqdn.len,p->fqdn.s,p->state);
switch (p->state){
/* initiating connection */
case Closed:
Expand Down
2 changes: 1 addition & 1 deletion modules/cdp/peerstatemachine.c
Expand Up @@ -86,7 +86,7 @@ int sm_process(peer *p,peer_event_t event,AAAMessage *msg,int peer_locked,int so
int msg_received=0;

if (!peer_locked) lock_get(p->lock);
LM_DBG("sm_process(): Peer %.*s \tState %s \tEvent %s\n",
LM_DBG("sm_process(): Peer %.*s State %s Event %s\n",
p->fqdn.len,p->fqdn.s,dp_states[p->state],dp_events[event-101]);

switch (p->state){
Expand Down
4 changes: 2 additions & 2 deletions modules/cdp/receiver.c
Expand Up @@ -99,10 +99,10 @@ static void log_serviced_peers()
{
serviced_peer_t *sp;

LM_DBG("--- Receiver ["ANSI_BLUE"%s"ANSI_GREEN"] Serviced Peers: ---\n",
LM_DBG("--- Receiver %s Serviced Peers: ---\n",
pt[process_no].desc);
for(sp=serviced_peers;sp;sp=sp->next){
LM_DBG(ANSI_GREEN" Peer: ["ANSI_YELLOW"%.*s"ANSI_GREEN"] TCP Socket: ["ANSI_YELLOW"%d"ANSI_GREEN"] Recv.State: ["ANSI_YELLOW"%d"ANSI_GREEN"]\n",
LM_DBG(" Peer: %.*s TCP Socket: %d Recv.State: %d \n",
sp->p?sp->p->fqdn.len:0,
sp->p?sp->p->fqdn.s:0,
sp->tcp_socket,
Expand Down
8 changes: 4 additions & 4 deletions modules/cdp/session.c
Expand Up @@ -392,7 +392,7 @@ void cdp_sessions_log()
int hash;
cdp_session_t *x;

LM_DBG(ANSI_MAGENTA"------- CDP Sessions ----------------\n"ANSI_GREEN);
LM_DBG("------- CDP Sessions ----------------\n");
for(hash=0;hash<sessions_hash_size;hash++){
AAASessionsLock(hash);
for(x = sessions[hash].head;x;x=x->next) {
Expand All @@ -404,7 +404,7 @@ void cdp_sessions_log()
switch (x->type){
case AUTH_CLIENT_STATEFULL:
case AUTH_SERVER_STATEFULL:
LM_DBG(ANSI_GRAY"\tAuth State [%d] Timeout [%d] Lifetime [%d] Grace [%d] Generic [%p] Class [%d]\n",
LM_DBG("Auth State [%d] Timeout [%d] Lifetime [%d] Grace [%d] Generic [%p] Class [%d]\n",
x->u.auth.state,
(int)(x->u.auth.timeout-time(0)),
x->u.auth.lifetime?(int)(x->u.auth.lifetime-time(0)):-1,
Expand All @@ -413,7 +413,7 @@ void cdp_sessions_log()
x->u.auth.class);
break;
case ACCT_CC_CLIENT:
LM_DBG(ANSI_GRAY"\tCCAcct State [%d] Charging Active [%c (%d)s] Reserved Units(valid=%ds) [%d] Generic [%p]\n",
LM_DBG("CCAcct State [%d] Charging Active [%c (%d)s] Reserved Units(valid=%ds) [%d] Generic [%p]\n",
x->u.cc_acc.state,
(x->u.cc_acc.charging_start_time&&x->u.cc_acc.state!=ACC_CC_ST_DISCON)?'Y':'N',
x->u.cc_acc.charging_start_time?(int)((int)time(0) - (int)x->u.cc_acc.charging_start_time):-1,
Expand All @@ -427,7 +427,7 @@ void cdp_sessions_log()
}
AAASessionsUnlock(hash);
}
LM_DBG(ANSI_MAGENTA"-------------------------------------\n"ANSI_GREEN);
LM_DBG("-------------------------------------\n");
}

int cdp_sessions_timer(time_t now, void* ptr)
Expand Down

0 comments on commit 01b16ce

Please sign in to comment.