You are here

function lingotek_error in Lingotek Translation 7.2

Same name and namespace in other branches
  1. 6 lingotek.util.inc \lingotek_error()
7 calls to lingotek_error()
LingotekSession::login in ./lingotek.session.inc
LingotekSession::logout in ./lingotek.session.inc
LingotekSession::request in ./lingotek.session.inc
lingotek_download_document in ./lingotek.api.inc
lingotek_lingonode in ./lingotek.util.inc

... See full list

File

./lingotek.util.inc, line 241
Utility functions.

Code

function lingotek_error($msg, $data = NULL, $depth = 0, $severity = WATCHDOG_ERROR) {
  if ($severity == WATCHDOG_WARNING && variable_get('lingotek_warning_log', FALSE)) {
    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);
  }
  watchdog('lingotek', '<span style="word-break: break-all;"><b>MESSAGE:</b> %msg <br /><b>DATA:</b> %data <br /><b>FILE:</b> %location<br /><b>FUNCTION:</b>%function<br /><b>ARGS:</b> %args</span>', array(
    '%msg' => $msg,
    '%data' => $data_output,
    '%location' => $location,
    '%function' => $function,
    '%args' => $args,
  ), $severity);
  if (variable_get('lingotek_error_log', FALSE)) {
    error_log("MESSAGE: {$msg} DATA: {$data_output} FILE: {$location} FUNCTION: {$function} ARGS: {$args}");
  }
}