miniflux-legacy/vendor/PicoFeed/Logging.php

84 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace PicoFeed;
2014-05-20 20:20:27 +02:00
use DateTime;
use DateTimeZone;
/**
* Logging class
*
* @author Frederic Guillot
* @package picofeed
*/
class Logging
{
2014-05-20 20:20:27 +02:00
/**
* List of messages
*
* @static
* @access private
* @var array
*/
private static $messages = array();
/**
* Default timezone
*
* @static
* @access private
* @var array
*/
private static $timezone = 'UTC';
/**
* Add a new message
*
* @static
* @access public
* @param string $message Message
*/
public static function setMessage($message)
{
$date = new DateTime('now', new DateTimeZone(self::$timezone));
self::$messages[] = '['.$date->format('Y-m-d H:i:s').'] '.$message;
}
/**
* Get all logged messages
*
* @static
* @access public
* @return array
*/
public static function getMessages()
{
return self::$messages;
}
/**
* Remove all logged messages
*
* @static
* @access public
*/
public static function deleteMessages()
{
self::$messages = array();
}
2014-05-20 20:20:27 +02:00
/**
* Set a different timezone
*
* @static
* @see http://php.net/manual/en/timezones.php
* @access public
* @param string $timezone Timezone
*/
public static function setTimeZone($timezone)
{
2014-05-20 20:20:27 +02:00
self::$timezone = $timezone ?: self::$timezone;
}
2014-05-20 20:20:27 +02:00
}