VCOS_STATUS_T vcos_log_set_cmd( VCOS_CMD_PARAM_T *param ) { VCOS_LOG_CAT_T *cat; char *name; char *levelStr; VCOS_LOG_LEVEL_T level; VCOS_STATUS_T status; if ( param->argc != 3 ) { vcos_cmd_usage( param ); return VCOS_EINVAL; } name = param->argv[1]; levelStr = param->argv[2]; if ( vcos_string_to_log_level( levelStr, &level ) != VCOS_SUCCESS ) { vcos_cmd_printf( param, "Unrecognized logging level: '%s'\n", levelStr ); return VCOS_EINVAL; } vcos_mutex_lock(&lock); status = VCOS_SUCCESS; for ( cat = vcos_logging_categories; cat != NULL; cat = cat->next ) { if ( vcos_strcmp( name, cat->name ) == 0 ) { cat->level = level; vcos_cmd_printf( param, "Category %s level set to %s\n", name, levelStr ); break; } else if ( vcos_strcmp( name, "*") == 0 ) { cat->level = level; vcos_cmd_printf( param, "Category %s level set to %s\n", name, levelStr ); } } if ( cat == NULL ) { vcos_cmd_printf( param, "Unrecognized category: '%s'\n", name ); status = VCOS_ENOENT; } vcos_mutex_unlock(&lock); return status; }
static void logging_parse_category( VCOS_CFG_BUF_T buf, void *data ) { VCOS_LOG_CAT_T *category = data; const char *str = vcos_cfg_buf_get_str( buf ); VCOS_LOG_LEVEL_T level; if ( vcos_string_to_log_level( str, &level ) == VCOS_SUCCESS ) { category->level = level; } else { printk( KERN_ERR "%s: Unrecognized logging level: '%s'\n", __func__, str ); } }
static int read_level(VCOS_LOG_LEVEL_T *level, const char **pstr, char sep) { char buf[16]; int ret = 1; if (read_tok(buf,sizeof(buf),pstr,sep)) { if (vcos_string_to_log_level(buf,level) != VCOS_SUCCESS) { vcos_log("Invalid trace level '%s'\n", buf); ret = 0; } } else { ret = 0; } return ret; }