ad_log (public)

 ad_log [ -key key ] [ -interval interval ] [ -plain ] severity \
    [ args... ]

Defined in packages/acs-tcl/tcl/utilities-procs.tcl

Output ns_log message with detailed context. This function is intended to be used typically with "error" to ease debugging. Repeated messages are reported only once, with a reference to the first occurrence. When -key is supplied, rate-limit messages by severity and key across connection threads of this server. Log the first occurrence immediately, then suppress further messages within the interval. Include the suppressed count with the next emitted message. Without -key, logging behavior is unchanged. Suppressed message texts are not retained, and no summary is emitted until another call occurs after the interval.

Switches:
-key (optional)
optional stable identifier for a group of related messages; avoid unbounded keys such as full request URLs
-interval (optional, integer, defaults to "60")
minimum logging interval in seconds, default 60 when -key is supplied; must be positive and requires -key
-plain (optional, boolean)
log the supplied message without adding request or call context. The normal NaviServer log prefix and any rate-suppression summary are retained.
Parameters:
severity (required)
Severity level such as "error" or "warning".
Author:
Gustaf Neumann

Partial Call Graph (max 5 caller/called nodes):
test_create_folder_with_page create_folder_with_page (test xowf) ad_log ad_log test_create_folder_with_page->ad_log test_create_form_with_form_instance create_form_with_form_instance (test xowiki) test_create_form_with_form_instance->ad_log test_create_workflow_with_instance create_workflow_with_instance (test xowf) test_create_workflow_with_instance->ad_log util::log_rate_limit_check util::log_rate_limit_check (private) ad_log->util::log_rate_limit_check util::request_info util::request_info (public) ad_log->util::request_info Class ::xo::Context Class ::xo::Context (public) Class ::xo::Context->ad_log Class ::xo::db::Class Class ::xo::db::Class (public) Class ::xo::db::Class->ad_log Class ::xo::db::CrClass Class ::xo::db::CrClass (public) Class ::xo::db::CrClass->ad_log Class ::xowiki::includelet::child-resources Class ::xowiki::includelet::child-resources (public) Class ::xowiki::includelet::child-resources->ad_log Object ::throttle Object ::throttle (public) Object ::throttle->ad_log

Testcases:
create_folder_with_page, create_workflow_with_instance, create_form_with_form_instance
Source code:

    if {$key ne ""} {

        lassign [::util::log_rate_limit_check $severity $key $interval]  suppressed reference

        if {$suppressed < 0} {
            return
        }

        if {$suppressed > 0} {
            lappend args  " ($suppressed additional messages suppressed; see $reference)"
        }
    }
    
    #
    # ad_log gathers request information, which may itself encounter an
    # error and call ad_log. In that case, log without gathering context.
    #
    if {[info exists ::acs::ad_log_in_progress]} {
        ns_log $severity {*}$args  "\n    recursive ad_log invocation; request context omitted"
        return
    }

    set ::__ad_log_in_progress 1
    try {
        if {$plain_p} {
            ns_log $severity {*}$args
        } else {
            set with_headers [expr {$severity in {error Error}}]
            append request "    "  [util::request_info -with_headers=$with_headers]

            ns_log $severity {*}$args "\n[uplevel ad_get_tcl_call_stack]${request}\n"

            #
            # Optional deduplication.. not sure this should be done
            # always. Better to get rid of the error/warning
            #
            # set key $severity-$args
            # if {[nsv_get ad_log $key previous_thread_name]} {
            #     set cnt [nsv_incr ad_log $key-count]
            #     ns_log notice  #         "... repeated $severity #$cnt (see $previous_thread_name)"
            # } else {
            #     nsv_set ad_log $key [ns_thread name]
            #     set with_headers [expr {$severity in {error Error}}]
            #     set request ""
            #     append request "    "  #         [util::request_info -with_headers=$with_headers]
            #
            #     ns_log $severity {*}$args  #         "\n[uplevel ad_get_tcl_call_stack]${request}\n"
            # }
        }
    } finally {
        unset -nocomplain ::__ad_log_in_progress
    }
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-tcl/tcl/utilities-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: