I am trying to implement my own logger and I have noticed that the AdapterInterface defines methods that are in my opinion redundant. Here is my proposal for the interface:
Following methods should be added to the \Phalcon\Logger\Adapter and removed from \Phalcon\Logger\Adapter\File
abstract public setFormat (string $format)
abstract public format getFormat ()
abstract public string getTypeString (integer $type)
abstract public setDateFormat (string $date)
abstract public string getDateFormat ()
I think that setting format and date format is not specific only for file adapter but can also be used while developing other adapters. This way I can either extend from \Phalcon\Logger\Adapter and implement \Phalcon\Logger\Adapter\AdapterInterface. In this case I can only concentrate on implementing my custom log storage.
class CustomLogger extends \Phalcon\Logger\Adapter implements \Phalcon\Logger\AdapterInterface {
public function log($message, $type)
{}
public function begin()
{}
public function commit()
{}
public function rollback()
{}
public function close()
{}
}
If I need custom implementation of methods mentioned above I will just implement the interface without extending the adapter.