Skip to content

iOS PrintLoggerPlugin uses wrong log level and is not available in apply #772

@KVSRoyal

Description

@KVSRoyal

Describe the bug

When using the iOS PrintLoggerPlugin:

  1. Logs from the apply of core plugins will be ignored unless they are in a hook.
  2. All logs will incorrectly use the plugin's log level (i.e. PrintLoggerPlugin(level: .trace)) instead of their intended level. E.g. this log:
    player.logger.debug('[REPRO] [CORE] In view hook');
    is showing up as "trace" even though it's "debug":
    [Player] [trace]: [[REPRO] [CORE] In view hook]

To Reproduce

  1. Use this branch
  2. Run the demo. Filter console output by "repro". Observe the logs. You should see these logs:
[Player] [trace]: ["[REPRO] Entered ReproPlugin"]
[Player] [trace]: ["[REPRO] Exiting ReproPlugin"]
[Player] [trace]: [[REPRO] [CORE] In view hook]
[Player] [trace]: ["[REPRO] In view hook"]
[Player] [trace]: ["[REPRO] In view hook"]
[Player] [trace]: ["[REPRO] In view hook"]

There are 2 logs missing, marked with comments here on the branch.

Expected behavior

I expect the actual log level to be reflected, i.e. debug instead of trace. I also expect the log messages from the core apply to actually show up.

I expect to see these logs:

[Player] [debug]: [[REPRO] [CORE] ReproPlugin entered]
[Player] [debug]: [[REPRO] [CORE] ReproPlugin exited]
[Player] [debug]: ["[REPRO] Entered ReproPlugin"]
[Player] [debug]: ["[REPRO] Exiting ReproPlugin"]
[Player] [debug]: [[REPRO] [CORE] In view hook]
[Player] [debug]: ["[REPRO] In view hook"]
[Player] [debug]: ["[REPRO] In view hook"]
[Player] [debug]: ["[REPRO] In view hook"]

Environment:

  • iPhone 16, iOS 18.5 simulator
  • Xcode 16.4

Additional context

Suspected cause of ignored logs

The logs are ignored because the PrintLoggerPlugin is not a JSBasePlugin and is applied after the JSBasePlugins. This means that the log methods have not actually been added by the time that the apply of the core is called. Here/here is where the JSBasePlugins are loaded. Then later, the native plugins are applied too.

Suspected cause of logLevel issue

This is using the log level of the plugin instead of the calling function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions