-
Notifications
You must be signed in to change notification settings - Fork 148
Conversation
a343db3
to
c804a0d
Compare
"symfony/css-selector": "2.8.* || ^3.0", | ||
"facebook/graph-sdk": "~5.0", | ||
"apache/log4php": "2.3.0" | ||
"symfony/css-selector": "2.8.*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we upgrade this to latest one(i guess 4.0.3) if no dependency with this version(2.8.*)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone is able to upgrade it, but we cannot move to 3.2 and up since it is not php 5.4 compatible.
We need to re-think the need of keeping php 5.4 compatibility
/** | ||
* @var string[] $logs The log messages generated during the transformation process. | ||
*/ | ||
private $logs = ['Possible log levels: OFF, ERROR, INFO or DEBUG']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about WARN or FATAL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warnings are all ready to be accessed from $transformer->getWarnings()
.
Fatals I see as the Exception handling being the best approach.
README.md
Outdated
@@ -82,7 +82,7 @@ If you are encountering problems, the following tips may help in troubleshooting | |||
|
|||
- If content is missing from your transformed article, more likely than not there isn't a **Transformer Rule** matching an element in your source markup. See how to configure appropriate rules for your content in the [Transformer Rules documentation](https://developers.facebook.com/docs/instant-articles/sdk/transformer-rules). | |||
|
|||
- Set the `threshold` in the [configuration of the Logger](https://logging.apache.org/log4php/docs/configuration.html#PHP) to `DEBUG` to expose more details about the items processed by the Transformer. | |||
- Set the `threshold` in the transformer Logger level to `DEBUG` to expose more details about the items processed by the Transformer. `$transformer->setLogLevel(Transformer::LOG_DEBUG);` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just Curious, What will be the advantage of using Logger implemented within the same code, instead of using the log4php library which already has lot of functionality.
@@ -73,8 +73,6 @@ public static function fromLevel($level, $message) | |||
if ($validLevel) { | |||
return new self($level, $message); | |||
} else { | |||
\Logger::getLogger('facebook-instantarticles-client') | |||
->info('Unknown message level "$level". Are you using the last SDK version?'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this file functions will be used over Transformer.php implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
All the package /Client
is on SDK for making it easier to call all APIs for the IA ingestion. See more here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd put all the logging methods/logic in a different class 'logger' or something similar just as a matter of separation of concerns. And then inject that class in the transformer and use it. What do you think?
c804a0d
to
51d5261
Compare
*[x] Implemented a simple internal logging structure. *[x] Removed log4php *[x] Fixed #302 *[x] Fixed #245 *[x] Fixed #240 Calls to Transformer have now stored all logging messages: ``` $json_file = file_get_contents(__DIR__ . '/simple-rules.json'); $instant_article = InstantArticle::create(); $transformer = new Transformer(); $transformer->loadRules($json_file); $html_file = file_get_contents(__DIR__ . '/simple.html'); $transformer->setLogLevel(Transformer::LOG_DEBUG); $transformer->transformString($instant_article, $html_file); $result = $transformer->getLogs(); ```
51d5261
to
b65ce8c
Compare
hey @everton-rosario, it still looks a little bit coupled for me. What if instead of having the logs being added (that logic) in the Tranformer class we do that in the TransformerLog class (and maybe TranformerLogger is a better naming?). So instead of having this: we could have something like this: so in this case we leave all the logging logic on the TransformerLogger class. I'm also adding an abstraction here so we don't use the different enums for each level and we just have a different method for each level logging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3
(consider @mburak's comments, though)
@mburak This is not a Logger tool. It was intended and built only for transformer, thats why I coupled it to the Transformer instance. Here, with this simple structure, we have a log structure that isolates only transformation debug info, to improve depuration on the transformer. Since it has all logging about transformation only, users of the SDK can optionally use their own logging system to output the transformation Log that occurred if they intend to, leaving it as optional. Also I don't see this logging system being used to anything else but Transformation debug. |
@everton-rosario gotcha. We could still handle each transformation in different logs even when having a decoupled logger. You pass the log array to the logger so the transformer still keeps the log state. |
Issue filed so we can treat it evenly not only for the logs, but also for the warnings: |
Calls to Transformer have now stored all logging messages: