/**
  * Add log when needed
  * @param string $key Key of the log item to handle.
  * @param array $data Array of data to log for this item.
  *
  */
 function addLog($key, $data)
 {
     // Get log item properties
     $logItem = lizmap::getLogItem($key);
     // Optionnaly log detail
     if ($logItem->getData('logDetail')) {
         // user who modified the line
         if (!array_key_exists('user', $data)) {
             $juser = jAuth::getUserSession();
             $data['user'] = $juser->login;
         }
         // Add IP if needed
         if ($logItem->getData('logIp')) {
             $data['ip'] = $_SERVER['REMOTE_ADDR'];
         }
         // Insert log
         $logItem->insertLogDetail($data);
     }
     // Optionnaly log count
     if ($logItem->getData('logCounter')) {
         $logItem->increaseLogCounter($data['repository'], $data['project']);
     }
 }