Skip to content

Debug and Diagnostics

Qriist edited this page Sep 17, 2026 · 4 revisions

LibQurl provides tools for tracing network activity and managing time data, primarily for debugging complex transfers.

Debug Logging

By default, LibQurl does not log raw packet data. You must explicitly enable it on a per-handle basis:

curl.EnableDebug() ;if using the default easy_handle

curl.EnableDebug(easy_handle) ;for any other

Once enabled, the library intercepts libcurl's debug callback and stores it until asked.

Configuring Debug Output

ConfigureDebug controls which internal events are captured:

; Log everything (text, headers, SSL data, etc)
curl.ConfigureDebug("all")

; Log only SSL handshake data, verbosely
curl.ConfigureDebug("+ssl")

; Exclude header logging
curl.ConfigureDebug("-header")

; Configure multiple components at once via array
curl.ConfigureDebug(["ssl", "+header", "-dns"])

; Disable all logging
curl.ConfigureDebug() ;passes ["-all"]

Per the libcurl trace documentation, you can use no prefix ("all"), plus ("+all"), or minus ("-all") to control the debug level for any component. "-all" is equivalent to not calling this in the first place.

Also note that while logging itself is a per-easy_handle operation, specifically which items are configured to be logged is a global setting.

Retrieving Debug Logs

PollDebug formats the captured log entries into a readable string. It filters out raw binary data by default to keep the output clean:

; Returns formatted text log
logText := curl.PollDebug(easy_handle)

Date Handling

GetDate parses date strings (RFC 822, RFC 2822, ISO 8601, etc.) into either a native AHK date string or the equivalent Unix epoch time.

; Get AHK Date string (default)
dateStr := curl.GetDate("Thu, 01 Jan 1970 00:00:00 GMT")

; Get raw epoch seconds
epoch := curl.GetDate("Thu, 01 Jan 1970 00:00:00 GMT", 1)

PrintObj

PrintObj is a simple tool for recursively formatting AHK Objects, Maps, and Arrays into a human-readable string. It is designed for debugging, inspecting internal library state, and formatting complex data structures for output.

Example

; Inspect a caught error record
if (curl.caughtErrors.Length > 0)
    MsgBox curl.PrintObj(curl.caughtErrors[1])

; Inspect a specific handle's active options
MsgBox curl.PrintObj(curl.easyHandleMap[easy_handle]["options"])

; Inspect a custom nested structure
data := Map(
    "endpoint", "/api/v1",
    "payload", Map("id", 42, "tags", ["a", "b"])
)
MsgBox curl.PrintObj(data)

Type Handling

The method automatically detects the type of each value and formats it appropriately, truncating complex binary or file objects to a clear identifier instead of dumping raw bytes:

Type Output
Default (String, Integer, etc.) Raw value
Map / Array / Object Recursively indented, respects depth limit
Buffer / MemBuffer [BUFFER]
File [FILE]
"Magic" downloads [MAGIC]

Timestamp Generation

Timestamp generates the current time in various common formats:

; Default: Readable format (yyyy-MM-dd hh:mm:ss.mmm)
MsgBox curl.Timestamp()
Format Name(s) Example Output
Readable, SQL, ODBC 2025-07-27 15:36:07.746
RFC 3339 2025-07-27T15:36:07.746Z
Unix, NTP, GPS, Cocoa 1753630567.746
asctime Sun Jul 27 15:36:07 2025
RFC 1123 Sun, 27 Jul 2025 15:36:07 GMT
RFC 2822 Sun, 27 Jul 2025 15:36:07 +0000
FILETIME 133502602077460000
EXIF 2025:07:27 15:36:07
RFC 850 Sunday, 27-Jul-25 15:36:07 GMT

The Unix value also supports an optional second scale parameter to control its epoch granularity and output type.

curl.Timestamp("Unix") ;returns epoch in seconds = 1753630567
curl.Timestamp("Unix", "seconds") ;same as above = 1753630567
curl.Timestamp("Unix", "float-seconds") ;same but as float = 1753630567.746
Scale Value Type
seconds
(Default)
Integer
ms Integer
ns Integer
us Integer
float-seconds Float
float-ms Float
float-ns Float
float-us Float

Where to Go Next

Clone this wiki locally