.. Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. .. include:: ../../common.defs .. _developer-debug-tags: Debug Tags ********** Use the API macro ``TSDbg(ctlptr, const char *format_str, ...)`` to add traces in your plugin. In this macro: - ``ctlptr`` is the Traffic Server parameter that enables Traffic Server to print out ``format_str``. It is returned by ``TSDbgCtlCreate()``. - ``...`` are variables for ``format_str`` in the standard ``printf`` style. ``void TSDbgCtlCreate (const char *tag)`` returns a (const) pointer to ``TSDbgCtl``. The ``TSDbgCtl`` control is enabled when debug output is enabled globally by configuaration, and ``tag`` matches a configured regular expression. The deprecated API ``void TSDebug (const char *tag, const char *format_str, ...)`` also outputs traces. In this API: - ``tag`` is the Traffic Server parameter that enables Traffic Server to print out ``format_str`` - ``...`` are variables for ``format_str`` in the standard ``printf`` style. Use of ``TSDebug()`` causes trace output to have a more negative impact on proxy throughput. Run Traffic Server with the ``-Ttag`` option. For example, if the tag is ``my-plugin``, then the debug output goes to ``traffic.out.``\ See below: :: traffic_server -T"my-plugin" Sets the following variables in :file:`records.config` (in the Traffic Server ``config`` directory): :: CONFIG proxy.config.diags.debug.enabled INT 1 CONFIG proxy.config.diags.debug.tags STRING debug-tag-name (Performance will be better if ``enabled`` is set to 3 rather than 1, but, using 3, output from ``TSDebug()`` will not be enabled, only from ``TSDbg()``.) In this case, debug output goes to ``traffic.out``. Example: .. code-block:: c static TSDbgCtl const *my_dbg_ctl; // Non-local variable. ... my_dbg_ctl = TSDbgCtlCreate("my-plugin"); // In TSPluginInit() or TSRemapInit(). ... TSDbg(my_dbg_ctl, "Starting my-plugin at %d", the_time); ... TSDbg(my_dbg_ctl, "Later on in my-plugin"); The statement ``"Starting my-plugin at