Skip to content

Browser Modules ReportCaller() replaces global log formatter #6335

Open

Description

@janHildebrandt98

Problem

When K6_BROWSER_LOG_CALLER is set, the browser module will add the function name to log entries.
The way it is implemented right now creates some problems:

  1. We are replacing the global log formatter in ReportCaller()
    func (l *Logger) ReportCaller() {
    . This means all previously applied config is discarded (JSON log format, no color etc)
  2. ReportCaller() is called once per browser init which means we are modifying global state concurrently. This is dangerous and unnecessary.

Suggestion:

Make K6_BROWSER_LOG_CALLER a core feature, detached from the browser module and handle it in setupLoggers() where all the other logging setup already takes place. K6_BROWSER_LOG_CALLER is already modifying global behavior outside the browser module so it wouldn't be too big of a change. This allows us to combine the setup with other log related setup and get rid of the concurrency.

Add a new env var K6_LOG_CALLER and remove K6_BROWSER_LOG_CALLER in the next major.

Open Questions

  1. Should the fallback logger also respect K6_BROWSER_LOG_CALLER? (I suggest no)
  2. Should we also log callers when the user selected the raw log format (I suggest no)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions