ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
logcleaner.php
Go to the documentation of this file.
1#!/usr/bin/env php
2<?php
3
4// This is the base directory of the SimpleSAMLphp installation
5$baseDir = dirname(dirname(dirname(dirname(__FILE__))));
6
7// Add library autoloader.
8require_once($baseDir . '/lib/_autoload.php');
9
10// Initialize the configuration.
11$configdir = SimpleSAML\Utils\Config::getConfigDir();
13
14$progName = array_shift($argv);
15$debug = false;
16$dryrun = false;
17$output = '/tmp/simplesamlphp-new.log';
18$infile = null;
19
20foreach ($argv as $a) {
21 if (strlen($a) === 0) {
22 continue;
23 }
24 if (strpos($a, '=') !== false) {
25 $p = strpos($a, '=');
26 $v = substr($a, $p + 1);
27 $a = substr($a, 0, $p);
28 } else {
29 $v = null;
30 }
31
32 // Map short options to long options.
33 $shortOptMap = array('-d' => '--debug');
34 if (array_key_exists($a, $shortOptMap)) {
35 $a = $shortOptMap[$a];
36 }
37
38 switch ($a) {
39 case '--help':
40 printHelp();
41 exit(0);
42 case '--debug':
43 $debug = true;
44 break;
45 case '--dry-run':
46 $dryrun = true;
47 break;
48 case '--infile':
49 $infile = $v;
50 break;
51 case '--outfile':
52 $output = $v;
53 break;
54 default:
55 echo('Unknown option: ' . $a . "\n");
56 echo('Please run `' . $progName . ' --help` for usage information.' . "\n");
57 exit(1);
58 }
59}
60
62$cleaner->dumpConfig();
64
65echo "Cleaning these trackIDs: " . join(', ', $todelete) . "\n";
66
67if (!$dryrun) {
68 $cleaner->store($todelete, $output);
69}
70
75function printHelp() {
76 global $progName;
77
78 echo <<<END
79Usage: $progName [options]
80
81This program cleans logs. This script is experimental. Do not run it unless you have talked to Andreas about it.
82The script deletes log lines related to sessions that produce more than 200 lines.
83
84Options:
85 -d, --debug Used when configuring the log file syntax. See doc.
86 --dry-run Aggregate but do not store the results.
87 --infile File input.
88 --outfile File to output the results.
89
90END;
91}
92
exit
Definition: backend.php:16
An exception for terminatinating execution or to throw for unit testing.
static setConfigDir($path, $configSet='simplesaml')
Set the directory for configuration files for the given configuration set.
input
Definition: langcheck.php:166
$progName
Definition: logcleaner.php:14
$infile
Definition: logcleaner.php:18
$output
Definition: logcleaner.php:17
$debug
Definition: logcleaner.php:15
$baseDir
Definition: logcleaner.php:5
$todelete
Definition: logcleaner.php:63
foreach($argv as $a) $cleaner
Definition: logcleaner.php:61
if(! $dryrun) printHelp()
This function prints the help output.
Definition: logcleaner.php:75
$configdir
Definition: logcleaner.php:11
$dryrun
Definition: logcleaner.php:16
run()
Runs the loop.
Definition: functions.php:130
global $argv
Definition: svg-scanner.php:41