MCPcopy Create free account
hub / github.com/apache/trafficserver / setup

Method setup

src/proxy/logging/LogFormat.cc:63–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61 -------------------------------------------------------------------------*/
62
63bool
64LogFormat::setup(const char *name, const char *format_str, unsigned interval_sec)
65{
66 if (name == nullptr) {
67 Note("missing log format name");
68 return false;
69 }
70
71 if (format_str) {
72 const char *tag = " %<phn>";
73 const size_t m_format_str_size = strlen(format_str) + (m_tagging_on ? strlen(tag) : 0) + 1;
74 m_format_str = static_cast<char *>(ats_malloc(m_format_str_size));
75 ink_strlcpy(m_format_str, format_str, m_format_str_size);
76 if (m_tagging_on) {
77 Note("Log tagging enabled, adding %%<phn> field at the end of "
78 "format %s",
79 name);
80 ink_strlcat(m_format_str, tag, m_format_str_size);
81 };
82
83 char *printf_str = nullptr;
84 char *fieldlist_str = nullptr;
85 int nfields = parse_format_string(m_format_str, &printf_str, &fieldlist_str);
86 if (nfields > (m_tagging_on ? 1 : 0)) {
87 init_variables(name, fieldlist_str, printf_str, interval_sec);
88 } else {
89 Note("Format %s encountered an error parsing the symbol string "
90 "\"%s\", symbol string contains no fields",
91 ((name) ? name : "no-name"), format_str);
92 m_valid = false;
93 }
94
95 ats_free(fieldlist_str);
96 ats_free(printf_str);
97
98 // We are only valid if init_variables() says we are.
99 return true;
100 }
101
102 // We don't have a format string (ie. this will be a raw text log, so we are always valid.
103 m_valid = true;
104 return true;
105}
106
107/*-------------------------------------------------------------------------
108 LogFormat::id_from_name

Callers

nothing calls this directly

Calls 4

ats_mallocFunction · 0.85
ink_strlcpyFunction · 0.85
ink_strlcatFunction · 0.85
ats_freeFunction · 0.85

Tested by

no test coverage detected