2 .\" # Copyright (c) 2014, Juniper Networks, Inc.
3 .\" # All rights reserved.
4 .\" # This SOFTWARE is licensed under the LICENSE provided in the
5 .\" # ../Copyright file. By downloading, installing, copying, or
6 .\" # using the SOFTWARE, you agree to be bound by the terms of that
8 .\" # Phil Shafer, July 2014
14 .Nm xo_attr , xo_attr_h , xo_attr_hv
15 .Nd Add attribute name/value pairs to formatted output
21 .Fn xo_attr "const char *name" "const char *fmt" "..."
23 .Fn xo_attr_h "xo_handle_t *handle" "const char *name, const char *fmt" "..."
25 .Fn xo_attr_hv "xo_handle_t *handle" "const char *name" "const char *fmt" "va_list vap"
29 function emits attributes for the XML output style. The attribute
30 value is recorded in the
32 and is attached to the next field that is emitted via a
38 parameter give the name of the attribute to be encoded. The
40 parameter gives a printf-style format string used to format the
41 value of the attribute using any remaining arguments, or the
43 parameter as passed to
45 .Bd -literal -offset indent
47 xo_attr("seconds", "%ld", (unsigned long) login_time);
48 struct tm *tmp = localtime(login_time);
49 strftime(buf, sizeof(buf), "%R", tmp);
50 xo_emit("Logged in at {:login-time}\\n", buf);
52 <login-time seconds="1408336270">00:14</login-time>
55 Since attributes are only emitted in XML, their use should be limited
56 to meta-data and additional or redundant representations of data
57 already emitted in other form.
64 library first appeared in
69 .An Phil Shafer Aq Mt phil@freebsd.org .