static function logDebug()
{
static $tps = 0;
$msg = "";
if (function_exists('debug_backtrace')) {
$bt = debug_backtrace();
$msg = ' From ';
if (count($bt) > 1) {
if (isset($bt[1]['class'])) {
$msg .= $bt[1]['class'] . '::';
}
$msg .= $bt[1]['function'] . '() in ';
}
$msg .= $bt[0]['file'] . ' line ' . $bt[0]['line'];
}
if ($tps && function_exists('memory_get_usage')) {
$msg .= ' (' . number_format(microtime(true) - $tps, 3) . '", ' . number_format(memory_get_usage() / 1024 / 1024, 2) . 'Mio)';
}
$msg .= "\n ";
foreach (func_get_args() as $arg) {
if (is_array($arg) || is_object($arg)) {
$msg .= str_replace("\n", "\n ", print_r($arg, true));
} else {
if (is_null($arg)) {
$msg .= 'NULL ';
} else {
if (is_bool($arg)) {
$msg .= ($arg ? 'true' : 'false') . ' ';
} else {
$msg .= $arg . ' ';
}
}
}
}
$tps = microtime(true);
self::logInFile('php-errors', $msg . "\n", true);
}
/** * @return int */ static function sendAlert() { global $DB, $CFG_GLPI; if (!$CFG_GLPI["use_mailing"]) { return 0; } $items_infos = array(); $query = "SELECT `glpi_plugin_ocsinventoryng_notimportedcomputers`.*\n FROM `glpi_plugin_ocsinventoryng_notimportedcomputers`\n LEFT JOIN `glpi_alerts`\n ON (`glpi_plugin_ocsinventoryng_notimportedcomputers`.`id` = `glpi_alerts`.`items_id`\n AND `glpi_alerts`.`itemtype` = 'PluginOcsinventoryngNotimportedcomputer'\n AND `glpi_alerts`.`type` = '" . Alert::END . "')\n WHERE `glpi_alerts`.`date` IS NULL"; foreach ($DB->request($query) as $notimported) { $items_infos[$notimported['entities_id']][$notimported['id']] = $notimported; } foreach ($items_infos as $entity => $items) { if (NotificationEvent::raiseEvent('not_imported', new PluginOcsinventoryngNotimportedcomputer(), array('entities_id' => $entity, 'notimported' => $items))) { $alert = new Alert(); $input["itemtype"] = 'PluginOcsinventoryngNotimportedcomputer'; $input["type"] = Alert::END; foreach ($items as $id => $item) { $input["items_id"] = $id; $alert->add($input); unset($alert->fields['id']); } } else { Toolbox::logDebug(__('%1$s: %2$s') . "\n", Dropdown::getDropdownName("glpi_entities", $entity), __('Send OCSNG not imported computers alert failed', 'ocsinventoryng')); } } }