Review main Abandoned

70014[FEATURE] Adopt Monolog for injected loggers.

crell CR 0 V 0 Expert +2068 −386 updated 02/04/23, 11:25

Commit message

Add the Monolog library and use that for all DI-based loggers.
Configuration is controlled by a typo3conf/logging.yaml file.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 23

Show 3 more files

Review log 3862

Show 2037 earlier messages
  1. crell uploaded patch set 1 07/20/21, 20:26

  2. crell marked it work in progress 07/20/21, 20:27

  3. core-ci voted on patch set 1 V -1 07/20/21, 20:36 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/13610

  4. crell uploaded patch set 2 07/22/21, 15:40

  5. core-ci voted on patch set 2 V +1 07/22/21, 15:55 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/13673

  6. crell marked it ready for review 07/22/21, 16:58

  7. crell uploaded patch set 3 07/23/21, 15:49

  8. core-ci voted on patch set 3 V -1 07/23/21, 16:01 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/13696

  9. crell uploaded patch set 4 07/26/21, 21:12

  10. core-ci voted on patch set 4 V -1 07/26/21, 21:16 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/13783

  11. crell uploaded patch set 5 07/26/21, 21:36

  12. core-ci voted on patch set 5 V -1 07/26/21, 21:48 Core CI is not happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/13784

  13. crell uploaded patch set 6 07/26/21, 22:21

  14. core-ci voted on patch set 6 V +1 07/26/21, 22:34 Core CI is happy: https://gitlab.typo3.org/TYPO3/CI/cms/-/pipelines/13785

  15. crell uploaded patch set 7 07/31/21, 00:09

  16. core-ci voted on patch set 7 V -1 07/31/21, 00:12 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/13938

  17. crell uploaded patch set 8 08/02/21, 13:33

  18. core-ci voted on patch set 8 V -1 08/02/21, 13:59 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/13998

  19. crell uploaded patch set 9 08/02/21, 15:53

  20. core-ci voted on patch set 9 V -1 08/02/21, 16:23 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14008

  21. core-ci voted on patch set 9 V +1 08/02/21, 17:11 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14008

  22. Georg Ringer commented on patch set 9 08/02/21, 18:02

    MonologHandlerDef.php:3

    license header is missing, also at other files

    Feature-94600-AdoptMonologForInjectedLoggers.rst:39

    can we call it $dependency?

    Feature-94600-AdoptMonologForInjectedLoggers.rst:50

    should we give it the same name as in the php example?
  23. crell commented on patch set 9 08/02/21, 18:10

    MonologHandlerDef.php:3 Reply

    Done

    Feature-94600-AdoptMonologForInjectedLoggers.rst:39 Reply

    Done

    Feature-94600-AdoptMonologForInjectedLoggers.rst:50 Reply

    Done
  24. crell uploaded patch set 10 08/02/21, 18:16

  25. core-ci voted on patch set 10 V +1 08/02/21, 18:36 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14019

  26. crell uploaded patch set 11 08/03/21, 21:36

  27. core-ci voted on patch set 11 V -1 08/03/21, 21:55 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14064

  28. crell uploaded patch set 12 08/04/21, 14:14

  29. core-ci voted on patch set 12 V -1 08/04/21, 14:36 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14095

  30. crell uploaded patch set 13 08/04/21, 17:05

  31. core-ci voted on patch set 13 V +1 08/04/21, 17:17 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14100

  32. crell uploaded patch set 14 08/05/21, 16:14

  33. core-ci voted on patch set 14 V -1 08/05/21, 16:18 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/14154

  34. crell uploaded patch set 15 08/19/21, 15:19

  35. core-ci voted on patch set 15 V -1 08/19/21, 15:22 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15305

  36. crell uploaded patch set 16 08/19/21, 15:33

  37. core-ci voted on patch set 16 V +1 08/19/21, 15:52 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15306

  1. Jonas Eberle uploaded patch set 17 08/19/21, 19:54

  2. core-ci voted on patch set 17 V +1 08/19/21, 20:09 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15313

  3. Mathias Brodala commented on patch set 17 08/20/21, 07:09

    Feature-94600-AdoptMonologForInjectedLoggers.rst:13

    Micro nitpick: we do not use the ". " pattern anywhere in TYPO3, please always use a single space after punctuation.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:25

    TYPO3

    Feature-94600-AdoptMonologForInjectedLoggers.rst:33

    There must be a newline after .. code-block:: <role> https://docs.typo3.org/m/typo3/docs-how-to-document/master/en-us/WritingReST/CheatSheet.html#code-blocks Also code blocks must be indented by 3 spaces (which aligns to the ".. " of ".. code-block::")

    Feature-94600-AdoptMonologForInjectedLoggers.rst:87

    Here we should clarify the relation to "trigger_error(..., E_USER_DEPRECATED)". It sounds like developers can use any of these but we should stick to a single way.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:104

    Feature-94600-AdoptMonologForInjectedLoggers.rst:105

    many (This document will be left unchanged forever so referring to a specific number doesn't make much sense.)

    Feature-94600-AdoptMonologForInjectedLoggers.rst:107

    Feature-94600-AdoptMonologForInjectedLoggers.rst:124

    Should be "arguments: []" just like the processor afterwards I guess. Without explanation that these are constructor arguments we should maybe skip this altogether though.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:132

    Here the :php: role should be used.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:140

    Here we should use inline code formatting.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:144

    Administrators

    Feature-94600-AdoptMonologForInjectedLoggers.rst:154

    Here the :yaml: role should be used.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:163

    General question: are there plans to support other non-monolog logging options here? I'm used to Symfony where there's a config/packages/monolog.yaml which clearly hints at the implementation.
  4. Jonas Eberle uploaded patch set 18 08/20/21, 07:32

  5. Jonas Eberle commented on patch set 17 08/20/21, 07:32

    Feature-94600-AdoptMonologForInjectedLoggers.rst:13 Reply

    Done

    Feature-94600-AdoptMonologForInjectedLoggers.rst:25 Reply

    Done

    Feature-94600-AdoptMonologForInjectedLoggers.rst:33 Reply

    Done

    Feature-94600-AdoptMonologForInjectedLoggers.rst:104 Reply

    Done

    Feature-94600-AdoptMonologForInjectedLoggers.rst:107 Reply

    Done

    Feature-94600-AdoptMonologForInjectedLoggers.rst:132 Reply

    Done

    Feature-94600-AdoptMonologForInjectedLoggers.rst:140 Reply

    Done

    Feature-94600-AdoptMonologForInjectedLoggers.rst:144 Reply

    Done

    Feature-94600-AdoptMonologForInjectedLoggers.rst:154 Reply

    Done
  6. core-ci voted on patch set 18 V +1 08/20/21, 07:51 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15320

  7. crell uploaded patch set 19 08/20/21, 15:05

  8. crell commented on patch set 19 08/20/21, 15:05

    Feature-94600-AdoptMonologForInjectedLoggers.rst:33 Reply

    3? That should be enforced by the .editorconfig file, then. Right now, .editorconfig says the indent is 4.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:87 Reply

    Calling trigger_error() isn't really relevant here. This is about what happens when you call trigger_error(). Extensions can call trigger_error() themselves whenever, that's unrelated. The point here is that they should almost never use the `deprecated` log channel. Only the core error handler will do that.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:105 Reply

    Ack

    Feature-94600-AdoptMonologForInjectedLoggers.rst:124 Reply

    Mm, actually I think I'm wrong there anyway, it shouldn't be arguments. The formatter uses the same "everything is an arg except for the magic names" logic. I'll change that.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:163 Reply Unresolved

    Not that I'm aware of. I am highly impartial about what the file is named and where it lives, just that it's a YAML file that gets parsed at container build time. Where that file lives and what it's called I don't much care.
  9. Nikita Hovratov commented on patch set 19 08/20/21, 15:19

    Feature-94600-AdoptMonologForInjectedLoggers.rst:33 Reply

    afaik this was recently changed, so that it is easier to paste code examples. Strictly speaking there should also be 3 spaces in lists (including the asterisk symbol).
  10. core-ci voted on patch set 19 V +1 08/20/21, 15:25 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15331

  11. Benjamin Franzke commented on patch set 19 08/23/21, 19:56

    Services.php:32

    I personally strongly dislike parsing another configuration in services.php That makes Services.php heavily depend on "side-effects". This is implicit, hard to discover service configuration and if the config causes DI to break, the integrator will have a hard time to fix it via installtool. And it's unclear that DI caches need to be cleared for logging config to be reflected. Also I think that logging information is possibly sensitive and shouldn't be located in a possibly publicly readable yaml file. I'd much prefer logging factories that read from $GLOBALS['TYPO3_CONF_VARS']['monolog'][$channel] Example for such a factory, as prototypes back in 2019: https://github.com/bnf/TYPO3.CMS/commit/monolog-alex-patchset-5-with-handler-factory Why? We need a generic config overhaul anyway, so introducing yet another config-form, just for loggers, isn't really helpful – sorry.

    Services.yaml:326

    Can you explain why it is a placeholder? It's a service alias and is actually used, so not a placeholder, right?

    Feature-94600-AdoptMonologForInjectedLoggers.rst:5 Unresolved

    Too many equal signs.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:12

    It's not really replaced, it's added as an alternative, right?

    Feature-94600-AdoptMonologForInjectedLoggers.rst:13

    Auto-configuration in Symfony DI terms would be to auto-configure based on class names. The currently implemented approach (that this patch implements) uses explicit configuration via arguments in Services.yaml or PHP 8 annotation. So I think we shouldn't talk about auto-confguration. Did you experiment to actually autowire LoggerInterface to the default channel, if not explicitly configured to another channel? I think that would be nice, and since we currently do that in core (we only autowire LoggerAwareInterface) that wouldn't be breaking.
  12. crell commented on patch set 19 08/24/21, 00:58

    Services.php:32 Reply Unresolved

    Because this configuration affects the container, it simply cannot be done through the global config array. That is not an option on the table if we want to use DI without a great deal of runtime overhead and complexity. I fully agree on the need for a larger configuration overhaul, although that's out of scope here. (I have a proposal for part of that in another issue.) If anything, I would push hard on moving away from the global config array. My proposal in https://decisions.typo3.org/t/object-interface-to-typo3-conf-vars/706 makes portions of the configuration injectable, which could lead to all configuration being injectable in the future. Having compile-time information available in YAML is a common pattern, and this is effectively how Symfony wires up Monolog, too. (That goes through the Symfony Config system, which is not used here and would just complicate matters even more.) As for where the file lives, I am very flexible on that and have no particular preference. Ideally we would have a configuration system that supports per-environment (dev/prod) overrides, a la Symfony, all of which can be stored in Git. Lacking that for now, I could see a good argument for the file being in a Git-stored location or a not-Git-stored location. I defer to the consensus on that front. At that point, "YAML file that gets pulled into the CI config" can, and probably should, become a part of a new config system in v12. (With less manual parsing than I have here, courtesy of a proper serialization library as discussed in the Decisions link above.)

    Services.yaml:326 Reply

    Other loggers are cloned off of this one, and declaring this as a dependency is what triggers the auto-configuration for channels. However, this service itself is never actually injected. The generated `monolog.logger.$channel` services are.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:12 Reply Unresolved

    The plan is to deprecate the old logging system, add a bridge inside LoggerManager (probably a separate patch to keep things reviewable, but I could stick it in this one if desired), and then remove the current one in v12 or v13.

    Feature-94600-AdoptMonologForInjectedLoggers.rst:13 Reply Unresolved

    I struggle to come up with a different name than "auto configuration" or "auto wiring", both of which Symfony already uses. If you have an alternative I am open to it. At the moment, the auto-whatever logic is keyed off of depending on the @logger placeholder service. However, that's a single method so it should be pretty easy to change the trigger to latch on by variable name or type as well. I didn't want to go too far without checking to see what people were comfortable with.
  13. crell uploaded patch set 20 08/26/21, 01:54

  14. core-ci voted on patch set 20 V -1 08/26/21, 01:58 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15645

  15. crell commented on patch set 20 08/26/21, 02:00

    This version will fail, but I'm about to sign off for a few days for vacation so I'm posting what I've got in case someone wants to continue while I'm gone. This version now detects places to inject a logger based on the type of a constructor parameter, not just the name. It also has a lot more error handling to account for the Symfony container, frankly, doing all kinds of weird things that make any sort of predictability impossible. :-( There's now a functional test as well, which isn't quite working for reasons I do not understand. The error from the container makes it seem like the auto-wiring logic is getting confused by the interface type declaration and fighting with the logic I'm adding, but I'm not clear why. If someone wants to answer that for me while I'm gone, that would be much appreciated.
  16. Benjamin Franzke commented on patch set 20 08/31/21, 17:25

    MonologPass.php:65 Unresolved

    So this is basically a service iterator. That's what the base class AbstractRecursivePass is usually used for, example in typo3/sysext/core/Classes/DependencyInjection/AutowireInjectMethodsPass.php That works on $container->getDefinitons() and allows to work on the concrete Definition instances and will recursively processes all definitons. …and it would allow to drop the $skipIds and the !$container->hasDefiniton($id) hacks.
  17. crell uploaded patch set 21 09/01/21, 19:32

  18. core-ci voted on patch set 21 V -1 09/01/21, 19:38 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16033

  19. crell uploaded patch set 22 09/01/21, 20:48

  20. core-ci voted on patch set 22 V -1 09/01/21, 22:52 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16039

  21. Benni Mack wrote 11/29/21, 10:10

    Change destination moved from master to main
  22. Benni Mack updated the commit message in patch set 23 11/29/21, 13:29

  23. core-ci voted on patch set 23 V -1 11/29/21, 18:02 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20039

  24. Christian Kuhn commented on patch set 23 02/04/23, 11:25

    Hey. It seems the logging topic is stuck again for a while. We may need a fresh restart *again*. I hope it's ok to abandon here for the time being.
  25. Christian Kuhn abandoned the change 02/04/23, 11:25