Skip to content
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

src: add log API #135

Merged
merged 1 commit into from
May 30, 2024
Merged

src: add log API #135

merged 1 commit into from
May 30, 2024

Conversation

trevnorris
Copy link
Member

Add a C++ API to collect logs written with the nsolid JS API.

Log support for Winston and Pino will also be added.

@trevnorris trevnorris self-assigned this May 17, 2024
src/nsolid.h Outdated Show resolved Hide resolved
src/nsolid/nsolid_api.h Outdated Show resolved Hide resolved
src/nsolid.h Outdated Show resolved Hide resolved
@trevnorris trevnorris force-pushed the trevnorris/log-api branch 3 times, most recently from 0057589 to 2fc3e37 Compare May 22, 2024 18:02
Comment on lines +222 to +224
function writeLog(msg, sev) {
binding.writeLog(typeof msg === 'string' ? msg : JSONStringify(msg), sev);
}
Copy link
Member

Choose a reason for hiding this comment

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

Should we check other types as well such as Buffer? I don't really know tbh

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good idea, but I wasn't sure if we should match how console.log() works on output.

src/nsolid.h Outdated Show resolved Hide resolved
src/nsolid.h Outdated Show resolved Hide resolved
Add a C++ API to collect logs written with the nsolid JS API.

PR-UR: #135
Reviewed-by: Santiago Gimeno <santiago.gimeno@gmail.com>
Comment on lines +1828 to +1833
template <typename G>
void on_log_write_hook_proxy_(SharedEnvInst inst,
LogWriteInfo info,
void* data) {
(*static_cast<G*>(data))(inst, std::move(info));
}
Copy link
Member

Choose a reason for hiding this comment

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

Does the compiler know how to move LogWriteInfo or do we have to implement the move constructor ourselves?

Copy link
Member Author

Choose a reason for hiding this comment

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

LogWriteInfo contains only standard types that it knows how to move. So we should be fine.

@trevnorris trevnorris merged commit 9c79696 into node-v20.x-nsolid-v5.x May 30, 2024
18 of 19 checks passed
@trevnorris trevnorris deleted the trevnorris/log-api branch May 30, 2024 20:52
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.

None yet

2 participants