Propel2 logging #1871
-
Sorry @mringler but you keep creating more questions for me. Setting up Propel2 logging, now I did get this working and it's nice, but there are some probs with Intelephense understanding your coding. There are two entries, this is the first. Intelephense is having trouble locating the function setLogger(), and so was I: Propel::getServiceContainer returns a "ServiceContainerInterface". Well, that seems odd, returning an interface. Shouldn't it return a substantiating class rather than an interface? ie Should it return the StandardServiceContainer. ServiceContainerInterface doesn't implement "setLogger()" and hence why Intelephense doesn't understand the function. This a similar problem. Propel::getWriteConnection() returns a ConnectionInterface. ConnectionInterface does not implement "useDebug()" and hence why Intelephense doesn't understand the function. The code does actually work, but only because those function don't return an interface so much as a class that implements the interface. I guess that works, for now, but how many versions of PHP until support for this functionality is deprecated and removed. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Yes, I agree completely, this hidden functionality is very annoying. I think the idea behind the structure was to allow users to replace these classes with their own implementations, a feature that probably next to no one uses, at the price of obscuring access to very common and important functionality. Then again, the problem ultimately comes down to the limited type system in PHP. Speaking of hidden functionality, I just found out that there is an easier way to set the logger: $loggerConfiguration = [
'type' => 'stream',
'path' => 'path/to/file'
'level' => Logger::INFO, // Defaults to Logger::CRITICAL,
'bubble' => true, // Defaults to true
];
Propel::getServiceContainer()->setLoggerConfiguration('defaultLogger', $loggerConfiguration); |
Beta Was this translation helpful? Give feedback.
-
I have created two small PRs to address the issues with type checking (and IDE support): |
Beta Was this translation helpful? Give feedback.
I have created two small PRs to address the issues with type checking (and IDE support):
#1872
#1873
Let's see how that goes. If you have time for a review, it is surely appreciated.