2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #include <vlib/vlib.h>
17 #include <vppinfra/elog.h>
19 static inline void elog_four_int_sample (u32 *data)
21 ELOG_TYPE_DECLARE(e) =
23 .format = "four int: first %d second %d third %d fourth %d",
24 .format_args = "i4i4i4i4",
26 struct { u32 data[4];} * ed;
27 ed = ELOG_DATA (&vlib_global_main.elog_main, e);
28 ed->data[0] = data[0];
29 ed->data[1] = data[1];
30 ed->data[2] = data[2];
31 ed->data[3] = data[3];
34 static inline void elog_four_int_track_sample (u32 *data)
36 ELOG_TYPE_DECLARE(e) =
38 .format = "four_int_track: first %d second %d third %d fourth %d",
39 .format_args = "i4i4i4i4",
41 struct { u32 data[4];} * ed;
42 ELOG_TRACK(sample_track);
43 ed = ELOG_TRACK_DATA (&vlib_global_main.elog_main, e, sample_track);
44 ed->data[0] = data[0];
45 ed->data[1] = data[1];
46 ed->data[2] = data[2];
47 ed->data[3] = data[3];
50 static inline void elog_enum_sample (u8 which)
52 ELOG_TYPE_DECLARE (e) =
54 .format = "my enum: %s",
63 struct { u8 which;} * ed;
64 ed = ELOG_DATA (&vlib_global_main.elog_main, e);
68 static inline void elog_one_datum_sample (u32 data)
70 ELOG_TYPE_DECLARE (e) =
72 .format = "one datum: %d",
76 elog (&vlib_global_main.elog_main, &e, data);
80 test_elog_command_fn (vlib_main_t * vm,
81 unformat_input_t * input,
82 vlib_cli_command_t * cmd)
87 for (i = 0; i < 10; i++)
94 elog_four_int_sample (samples);
95 elog_four_int_track_sample (samples);
98 elog_one_datum_sample (i);
104 VLIB_CLI_COMMAND (test_elog_command, static) = {
105 .path = "test elog sample",
106 .short_help = "test elog sample",
107 .function = test_elog_command_fn,