*/ class _state { public static $outputs = []; } /** * @author Christian Fraß */ function add_output( interface_output $output ) : void { array_push(_state::$outputs, $output); } /** * @author Christian Fraß */ function _submit( int $level, \alveolata\report\struct_report $report ) : void { foreach (_state::$outputs as $output) { $output->process($level, $report); } } /** * @param \alveolata\report\type $report * @author Christian Fraß */ function error_( \alveolata\report\struct_report $report ) : void { _submit(enum_level::error, $report); } /** * @param string $incident * @param map [$details] * @author Christian Fraß */ function error( string $incident, array $details = [] ) : void { error_(\alveolata\report\make($incident, $details)); } /** * @param \alveolata\report\type $report * @author Christian Fraß */ function warning_( \alveolata\report\struct_report $report ) : void { _submit(enum_level::warning, $report); } /** * @param string $incident * @param map [$details] * @author Christian Fraß */ function warning( string $incident, array $details = [] ) : void { warning_(\alveolata\report\make($incident, $details)); } /** * @param \alveolata\report\type $report * @author Christian Fraß */ function notice_( \alveolata\report\struct_report $report ) : void { _submit(enum_level::notice, $report); } /** * @param string $incident * @param map [$details] * @author Christian Fraß */ function notice( string $incident, array $details = [] ) : void { notice_(\alveolata\report\make($incident, $details)); } /** * @param \alveolata\report\type $report * @author Christian Fraß */ function info_( \alveolata\report\struct_report $report ) : void { _submit(enum_level::info, $report); } /** * @param string $incident * @param map [$details] * @author Christian Fraß */ function info( string $incident, array $details = [] ) : void { info_(\alveolata\report\make($incident, $details)); } /** * @param \alveolata\report\type $report * @author Christian Fraß */ function debug_( \alveolata\report\struct_report $report ) : void { _submit(enum_level::debug, $report); } /** * @param string $incident * @param map [$details] * @author Christian Fraß */ function debug( string $incident, array $details = [] ) : void { debug_(\alveolata\report\make($incident, $details)); } /** * @author Christian Fraß */ function make_output( string $kind, array $parameters ) : interface_output { switch ($kind) { case 'console': { return ( new implementation_restricted( new implementation_console(), level_decode($parameters['level_threshold'] ?? 'notice') ) ); break; } case 'file': { return ( new implementation_restricted( new implementation_file( $parameters['path'], [ 'human_readable' => ($parameters['human_readable'] ?? false), ] ), level_decode($parameters['level_threshold'] ?? 'notice') ) ); break; } case 'email': { return ( new implementation_restricted( new implementation_email( $parameters['auth'], $parameters['receivers'], $parameters['sender'], $parameters['tags'], $parameters['implementation'] ), level_decode($parameters['level_threshold'] ?? 'notice') ) ); break; } case 'libnotify': { return ( new implementation_restricted( new implementation_libnotify(), level_decode($parameters['level_threshold'] ?? 'notice') ) ); break; } default: { throw (new \Exception(sprintf('invalid logoutput kind "%s"', $kind))); break; } } } ?>