+static clib_error_t *
+log_config_class (vlib_main_t * vm, char *name, unformat_input_t * input)
+{
+ vlib_log_main_t *lm = &log_main;
+ vlib_log_class_config_t *cc, tmp;
+ uword *p;
+
+ if (lm->config_index_by_name == 0)
+ lm->config_index_by_name = hash_create_string (0, sizeof (uword));
+
+ p = hash_get_mem (lm->config_index_by_name, name);
+
+ if (p)
+ return clib_error_return (0, "logging class '%s' already configured",
+ name);
+
+ clib_memset_u8 (&tmp, 0xff, sizeof (vlib_log_class_config_t));
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "level %U", unformat_vlib_log_level, &tmp.level))
+ ;
+ else if (unformat (input, "syslog-level %U", unformat_vlib_log_level,
+ &tmp.syslog_level))
+ ;
+ else if (unformat (input, "rate-limit %u", &tmp.rate_limit))
+ ;
+ else
+ return clib_error_return (0, "unknown input '%U'",
+ format_unformat_error, input);
+ }
+
+ vec_add2 (lm->configs, cc, 1);
+ clib_memcpy_fast (cc, &tmp, sizeof (vlib_log_class_config_t));
+ cc->name = name;
+ hash_set_mem (lm->config_index_by_name, name, cc - lm->configs);
+ return 0;
+}
+