Skip to content

feat: Allow early logger initialization #804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 20, 2024
Merged

feat: Allow early logger initialization #804

merged 3 commits into from
Jun 20, 2024

Conversation

guybedford
Copy link
Contributor

@guybedford guybedford commented Jun 18, 2024

This resolves #225 in supporting lazy initialization of the logging endpoint allowing the logger to be created during preinitialization.

@LeslieCarr
Copy link

@jaskiratr

@guybedford guybedford requested a review from elliottt June 18, 2024 23:37
Copy link
Contributor

@elliottt elliottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this all seems reasonable, but I wonder if the additional logging to stderr should be configurable.

Comment on lines 43 to 45
fprintf(stdout, "Log [%s]: %s\n", endpoint_name_str.ptr.get(), msg.ptr.get());
fflush(stdout);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about making this behavior configurable? I know that enableDebugLogging() will be removed eventually, but this seems like a pretty ideal use of that.

My worry is that there are reasonable non-debugging uses of the logging api, and unconditionally logging to stderr without a way to disable that introduces additional unnecessary host calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently this behaviour is to match the Rust SDK, and that the behaviour is desireable by default for JS and Go.

Having a way to turn it off might well make sense, and agreed enableDebugLogging() sounds like a good integration point. I do not know about the design of enableDebugLogging() though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually enableDebugLogging is off by default so doesn't fit the requirements here unfortunately?

Copy link
Contributor

@elliottt elliottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is matching existing rust SDK behavior, it all seems good to me!

@guybedford
Copy link
Contributor Author

Looking into this further, it seems Viceroy does handle the logging to stdout as I would have expected, so this PR actually causes a double log when --verbose is set.

Instead I'm just going to refactor this to not do the stdout logging and just be a fix for #225.

@guybedford guybedford changed the title feat: Fastly logger to stdout, and allow early init feat: Allow early logger initialization Jun 19, 2024
@guybedford
Copy link
Contributor Author

I've updated this PR title and description to just be a fix for #225.

@guybedford guybedford requested a review from elliottt June 19, 2024 15:10
@guybedford guybedford merged commit 514d014 into main Jun 20, 2024
20 checks passed
@guybedford guybedford deleted the logger-stdout branch June 20, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow logger creation during initialization
4 participants