public static function log($msg, $data = NULL, $depth = 0, $severity = WATCHDOG_NOTICE, $tag = '') { if ($severity == WATCHDOG_WARNING && variable_get('lingotek_warning_log', self::getDefault())) { return; } else { if (strcasecmp($tag, 'api') == 0 && !variable_get('lingotek_api_debug', self::getDefault())) { return; } } $backtrace = debug_backtrace(); $location = $backtrace[$depth]['file'] . ':' . $backtrace[$depth]['line']; $function = $backtrace[$depth + 1]['function']; $args = @json_encode($backtrace[$depth + 1]['args']); $data_output = ""; if (isset($data)) { $data_output = json_encode($data); } $suffix = is_string($tag) && strlen($tag) ? ' - ' . $tag : ''; $data_array = array(); if (is_array($data)) { foreach ($data as $k => $v) { $data_array[$k] = LingotekLog::format($v); } } watchdog('lingotek' . $suffix, t($msg, $data_array) . ' <div style="word-break: break-all; padding-top: 10px; color: #666;"><b>FUNCTION:</b> %function<br /><b>ARGS:</b> %args<br /><b>FILE:</b> %location<br /><b>MESSAGE:</b> %msg <br /><b>DATA:</b> %data <br /></div>', array('%msg' => $msg, '%data' => $data_output, '%location' => $location, '%function' => $function, '%args' => $args), $severity); if (variable_get('lingotek_error_log', FALSE)) { error_log("FUNCTION: {$function} ARGS: {$args} FILE: {$location} MESSAGE: {$msg} DATA: {$data_output} "); } }
public static function log($msg, $data = NULL, $depth = 0, $severity = WATCHDOG_NOTICE, $tag = '') { $backtrace = debug_backtrace(); $location = $backtrace[$depth]['file'] . ':' . $backtrace[$depth]['line']; $function = $backtrace[$depth + 1]['function']; $args = @json_encode($backtrace[$depth + 1]['args']); $data_output = ""; if (isset($data)) { $data_output = json_encode($data); } $data_array = array(); if (is_array($data)) { foreach ($data as $k => $v) { $data_array[$k] = LingotekLog::format($v); } } watchdog('lingotek', format_string(empty($tag) ? $msg : '[' . $tag . '] ' . $msg, $data_array) . ' <div style="word-break: break-all; padding-top: 10px; color: #666;"><b>FUNCTION:</b> %function<br /><b>ARGS:</b> %args<br /><b>FILE:</b> %location<br /><b>MESSAGE:</b> %msg <br /><b>DATA:</b> %data <br /></div>', array('%msg' => $msg, '%data' => $data_output, '%location' => $location, '%function' => $function, '%args' => $args), $severity); if (variable_get('lingotek_error_log', FALSE) && $tag == 'error') { error_log("FUNCTION: {$function} ARGS: {$args} FILE: {$location} MESSAGE: {$msg} DATA: {$data_output} "); } }