Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Data Fields | Protected Attributes
Zend_Log_Formatter_Simple Class Reference
Inheritance diagram for Zend_Log_Formatter_Simple:
Zend_Log_Formatter_Abstract Zend_Log_Formatter_Interface Zend_Log_FactoryInterface

Public Member Functions

 __construct ($format=null)
 
 format ($event)
 

Static Public Member Functions

static factory ($options)
 

Data Fields

const DEFAULT_FORMAT = '%timestamp% %priorityName% (%priority%): %message%'
 

Protected Attributes

 $_format
 

Detailed Description

Definition at line 34 of file Simple.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $format = null)

Class constructor

Parameters
null | string$formatFormat specifier for log messages
Returns
void
Exceptions
Zend_Log_Exception

Definition at line 50 of file Simple.php.

51  {
52  if ($format === null) {
53  $format = self::DEFAULT_FORMAT . PHP_EOL;
54  }
55 
56  if (!is_string($format)) {
57  #require_once 'Zend/Log/Exception.php';
58  throw new Zend_Log_Exception('Format must be a string');
59  }
60 
61  $this->_format = $format;
62  }
$format
Definition: list.phtml:12

Member Function Documentation

◆ factory()

static factory (   $options)
static

Factory for Zend_Log_Formatter_Simple classe

Parameters
array | Zend_Config$options
Returns
Zend_Log_Formatter_Simple

Implements Zend_Log_FactoryInterface.

Definition at line 70 of file Simple.php.

71  {
72  $format = null;
73  if (null !== $options) {
74  if ($options instanceof Zend_Config) {
75  $options = $options->toArray();
76  }
77 
78  if (array_key_exists('format', $options)) {
79  $format = $options['format'];
80  }
81  }
82 
83  return new self($format);
84  }
$format
Definition: list.phtml:12

◆ format()

format (   $event)

Formats data into a single line to be written by the writer.

Parameters
array$eventevent data
Returns
string formatted line to write to the log

Implements Zend_Log_Formatter_Interface.

Definition at line 92 of file Simple.php.

93  {
95 
96  foreach ($event as $name => $value) {
97  if ((is_object($value) && !method_exists($value,'__toString'))
98  || is_array($value)
99  ) {
100  $value = gettype($value);
101  }
102 
103  $output = str_replace("%$name%", $value, $output);
104  }
105 
106  return $output;
107  }
$value
Definition: gender.phtml:16
if(!isset($_GET['name'])) $name
Definition: log.php:14

Field Documentation

◆ $_format

$_format
protected

Definition at line 39 of file Simple.php.

◆ DEFAULT_FORMAT

const DEFAULT_FORMAT = '%timestamp% %priorityName% (%priority%): %message%'

Definition at line 41 of file Simple.php.


The documentation for this class was generated from the following file: