summaryrefslogtreecommitdiffstats
path: root/vendor/fguillot/picofeed/lib/PicoFeed/Logging/Logger.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/fguillot/picofeed/lib/PicoFeed/Logging/Logger.php')
m---------vendor/fguillot/picofeed0
-rw-r--r--vendor/fguillot/picofeed/lib/PicoFeed/Logging/Logger.php116
2 files changed, 116 insertions, 0 deletions
diff --git a/vendor/fguillot/picofeed b/vendor/fguillot/picofeed
deleted file mode 160000
-Subproject 0a1d0d3950f7f047dc8fb1d80aa6296e15f306d
diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Logging/Logger.php b/vendor/fguillot/picofeed/lib/PicoFeed/Logging/Logger.php
new file mode 100644
index 000000000..fe5295377
--- /dev/null
+++ b/vendor/fguillot/picofeed/lib/PicoFeed/Logging/Logger.php
@@ -0,0 +1,116 @@
+<?php
+
+namespace PicoFeed\Logging;
+
+use DateTime;
+use DateTimeZone;
+
+/**
+ * Logging class
+ *
+ * @author Frederic Guillot
+ * @package Logging
+ */
+class Logger
+{
+ /**
+ * List of messages
+ *
+ * @static
+ * @access private
+ * @var array
+ */
+ private static $messages = array();
+
+ /**
+ * Default timezone
+ *
+ * @static
+ * @access private
+ * @var string
+ */
+ private static $timezone = 'UTC';
+
+ /**
+ * Enable or disable logging
+ *
+ * @static
+ * @access public
+ * @var boolean
+ */
+ public static $enable = false;
+
+ /**
+ * Enable logging
+ *
+ * @static
+ * @access public
+ */
+ public static function enable()
+ {
+ self::$enable = true;
+ }
+
+ /**
+ * Add a new message
+ *
+ * @static
+ * @access public
+ * @param string $message Message
+ */
+ public static function setMessage($message)
+ {
+ if (self::$enable) {
+ $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();
+ }
+
+ /**
+ * Set a different timezone
+ *
+ * @static
+ * @see http://php.net/manual/en/timezones.php
+ * @access public
+ * @param string $timezone Timezone
+ */
+ public static function setTimeZone($timezone)
+ {
+ self::$timezone = $timezone ?: self::$timezone;
+ }
+
+ /**
+ * Get all messages serialized into a string
+ *
+ * @static
+ * @access public
+ * @return string
+ */
+ public static function toString()
+ {
+ return implode(PHP_EOL, self::$messages).PHP_EOL;
+ }
+}
d='n453' href='#n453'>453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655