ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Stats.php
Go to the documentation of this file.
1 <?php
2 
3 
12 {
13 
19  private static $initialized = false;
20 
21 
27  private static $outputs = null;
28 
29 
38  {
39  $cls = $config->getString('class');
40  $cls = SimpleSAML\Module::resolveClass($cls, 'Stats_Output', 'SimpleSAML_Stats_Output');
41 
42  $output = new $cls($config);
43  return $output;
44  }
45 
46 
50  private static function initOutputs()
51  {
52 
54  $outputCfgs = $config->getConfigList('statistics.out', array());
55 
56  self::$outputs = array();
57  foreach ($outputCfgs as $cfg) {
58  self::$outputs[] = self::createOutput($cfg);
59  }
60  }
61 
62 
71  public static function log($event, array $data = array())
72  {
73  assert('is_string($event)');
74  assert('!isset($data["op"])');
75  assert('!isset($data["time"])');
76  assert('!isset($data["_id"])');
77 
78  if (!self::$initialized) {
79  self::initOutputs();
80  self::$initialized = true;
81  }
82 
83  if (empty(self::$outputs)) {
84  // not enabled
85  return;
86  }
87 
88  $data['op'] = $event;
89  $data['time'] = microtime(true);
90 
91  // the ID generation is designed to cluster IDs related in time close together
92  $int_t = (int) $data['time'];
93  $hd = openssl_random_pseudo_bytes(16);
94  $data['_id'] = sprintf('%016x%s', $int_t, bin2hex($hd));
95 
96  foreach (self::$outputs as $out) {
97  $out->emit($data);
98  }
99  }
100 
101 }
static initOutputs()
Initialize the outputs.
Definition: Stats.php:50
static $initialized
Definition: Stats.php:19
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
static createOutput(SimpleSAML_Configuration $config)
Create an output from a configuration object.
Definition: Stats.php:37
catch(Exception $e) if(isset($_POST['cancel'])) if(isset($_POST['continue'])) $cfg
Create styles array
The data for the language used.
getString($name, $default=self::REQUIRED_OPTION)
This function retrieves a string configuration option.
static resolveClass($id, $type, $subclass=null)
Resolve module class.
Definition: Module.php:252
static $outputs
Definition: Stats.php:27
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static log($event, array $data=array())
Notify about an event.
Definition: Stats.php:71