You are here

public static function LingotekLog::log in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.7 lib/Drupal/lingotek/LingotekLog.php \LingotekLog::log()
  2. 7.3 lib/Drupal/lingotek/LingotekLog.php \LingotekLog::log()
  3. 7.4 lib/Drupal/lingotek/LingotekLog.php \LingotekLog::log()
  4. 7.5 lib/Drupal/lingotek/LingotekLog.php \LingotekLog::log()
5 calls to LingotekLog::log()
LingotekLog::api in lib/Drupal/lingotek/LingotekLog.php
LingotekLog::error in lib/Drupal/lingotek/LingotekLog.php
LingotekLog::info in lib/Drupal/lingotek/LingotekLog.php
LingotekLog::trace in lib/Drupal/lingotek/LingotekLog.php
LingotekLog::warning in lib/Drupal/lingotek/LingotekLog.php

File

lib/Drupal/lingotek/LingotekLog.php, line 66
LingotekLog

Class

LingotekLog
Wrapper logging class for watchdog

Code

public static function log($msg, $data = NULL, $depth = 0, $severity = WATCHDOG_NOTICE, $tag = 'general') {
  $backtrace = debug_backtrace();
  $location = $backtrace[$depth]['file'] . ':' . $backtrace[$depth]['line'];
  $function = $backtrace[$depth + 1]['function'];
  $args = @json_encode($backtrace[$depth + 1]['args']);
  if (!$data) {
    $data = array();
  }
  $data_output = json_encode($data);
  $data_array = array(
    '@tag' => $tag,
    '%location' => $location,
    '%function' => $function,
    '%args' => $args,
  );

  // format the passed-in arguments
  foreach ($data as $k => $v) {
    $data_array[$k] = LingotekLog::format($v);
  }
  watchdog('lingotek', '[@tag] <div style="word-break: break-all; padding-top: 10px; color: #666;">' . $msg . '<br /><b>FUNCTION:</b> %function<br /><b>ARGS:</b> %args<br /><b>FILE:</b> %location<br /></div>', $data_array, $severity);
  if (variable_get('lingotek_error_log', FALSE) && $tag == 'error') {
    error_log("FUNCTION: {$function} ARGS: {$args}  FILE: {$location} MESSAGE: {$msg} DATA: {$data_output} ");
  }
}