streams = array(); } /** * Log a message * * @param \string $message Message to log * @param \array[\core\log\Tag] $tags Tags associated to the log * * @return \int Number of logs written */ public static function log(string $message, \core\log\TagsType $tags) : int { $counter = 0; foreach ($tags as $tag) { if (!($tag instanceof \core\log\Tag)) { throw new \core\log\LogException(\core\substitute( \_('{tag} is not a correct tag'), array('tag' => $tag::class), )); } $stream = self::build_stream($tag); if (!\is_null($stream)) { $stream->push(new \core\log\Event($message), $tags); $counter += 1; } } return $counter; } /** * Build a stream * * @param \core\log\Tag $tag Tag of the stream to manage * * @throws \core\log\StreamException * * @return \core\log\Stream | null */ protected static function build_stream(\core\log\Tag $tag) : \core\log\Stream | null { return \core\log\StreamFactory::build(tag: $tag); # NOTE: can throw \core\log\StreamException too } } ?>