Skip to content

Logging & Debugging

Jordan Brauer edited this page Dec 10, 2018 · 1 revision

If you ever require some sort of debugging output for your conversions, there is a method available for that, on the converter which can be used it like so,

var_dump($converter->getConversionLog());

Using the same example conversion from the converting units section, our dump would output the following

array:1 [
  "130d9d5" => array:6 [
    "calculation" => "2.54 = (1 × 0.0254) ÷ 0.01"
    "value" => 1
    "precision" => null
    "from" => "in"
    "to" => "cm"
    "result" => 2.54
  ]
]

Note: having the conversion log enabled will greatly hinder performance. If you find yourself running out of memory, you can disable the conversion log (it is enabled, by default), like so;

$converter->disableConversionLog();

The conversion log tries it's best to be economical by checking for repeat calculations & returning the previous result if one already exists. This prevents the array that stores the data from getting too large. However, generally speaking, this will not be a problem for most users.

Clone this wiki locally