Changeset 3661


Ignore:
Timestamp:
Jul 21, 2009, 11:40:47 PM (15 years ago)
Author:
plg
Message:

feature 1071: improve log system on API calls. The log can be activated by a
configuration setting. The log file can be changed also with a configuration
setting.

improvement: pwg.images.add API methods gets a cleaner way to log received
parameters.

Location:
branches/2.0/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/include/config_default.inc.php

    r3381 r3661  
    654654// Web services are allowed (true) or completely forbidden (false)
    655655$conf['allow_web_services'] = true;
     656
     657// enable log for web services
     658$conf['ws_enable_log'] = false;
     659
     660// web services log file path
     661$conf['ws_log_filepath'] = '/tmp/piwigo_ws.log';
    656662
    657663// Maximum number of images to be returned foreach call to the web service
  • branches/2.0/include/ws_functions.inc.php

    r3659 r3661  
    991991  }
    992992
    993   // name
    994   // category_id
    995   // file_content
    996   // file_sum
    997   // thumbnail_content
    998   // thumbnail_sum
    999   // rank
    1000 
    1001   // $fh_log = fopen('/tmp/php.log', 'w');
    1002   // fwrite($fh_log, time()."\n");
    1003   // fwrite($fh_log, 'input rank :'.$params['rank']."\n");
    1004   // fwrite($fh_log, 'input:  '.$params['file_sum']."\n");
    1005   // fwrite($fh_log, 'input:  '.$params['thumbnail_sum']."\n");
     993  foreach ($params as $param_key => $param_value) {
     994    ws_logfile(
     995      sprintf(
     996        '[pwg.images.add] input param "%s" : "%s"',
     997        $param_key,
     998        is_null($param_value) ? 'NULL' : $param_value
     999        )
     1000      );
     1001  }
    10061002
    10071003  // does the image already exists ?
     
    10281024    $day
    10291025    );
    1030 
    1031   //fwrite($fh_log, $upload_dir."\n");
    10321026
    10331027  // create the upload directory tree if not exists
     
    12241218
    12251219  invalidate_user_cache();
    1226 
    1227   // fclose($fh_log);
    12281220}
    12291221
     
    17911783function ws_logfile($string)
    17921784{
    1793   return true;
     1785  global $conf;
     1786
     1787  if (!$conf['ws_enable_log']) {
     1788    return true;
     1789  }
    17941790 
    17951791  file_put_contents(
    1796     '/tmp/piwigo_ws.log',
     1792    $conf['ws_log_filepath'],
    17971793    '['.date('c').'] '.$string."\n",
    17981794    FILE_APPEND
Note: See TracChangeset for help on using the changeset viewer.