Skip to content

Migrate from Lwt_log to Logs #256

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 8 commits into from
May 6, 2025
Merged

Conversation

Julow
Copy link
Contributor

@Julow Julow commented Apr 7, 2025

Based on top of these other PRs,

The Eliom side work is,

This replaces all uses of the Lwt_log library by Logs. Lwt_log is
deprecated and its README suggest to use Logs instead so it seems like a
good choice.

The bulk of the change was done with the lwt-log-to-logs tool: Julow/lwt-to-direct-style#5

This is almost a 1 to 1 translation as the two libraries are very
similar but there are some differences:

  • The "Fatal" log level doesn't exist in Logs. "Error" is used instead.

  • Log messages are formatted with Format.

  • Logs has no equivalent of "broadcast" and "dispatch" available out of
    the box. These operations are easily supported by generating more
    code.

  • There is no equivalent for Lwt_log.add_rule in Logs. Luckily it can be
    avoided in this project. This might cause more work in Ocsigen
    applications that use their own log sections.

  • Syslog support is done by the "logs-syslog" library.

  • There is no equivalent for Lwt_log.close. Ocsigen_messages is still
    able to close its reporters, except for the syslog reporter, which
    doesn't support this operation.

; "ocsigenserver" ]
in
let packages =
"lwt_ssl,bytes,lwt.unix,logs,logs-syslog,syslog-message,ipaddr,findlib,cryptokit,re,str,xml-light,dynlink,cohttp-lwt-unix,hmap"
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be updated as follows:

Suggested change
"lwt_ssl,bytes,lwt.unix,logs,logs-syslog,syslog-message,ipaddr,findlib,cryptokit,re,str,xml-light,dynlink,cohttp-lwt-unix,hmap"
"lwt_ssl,bytes,lwt.unix,logs,logs-syslog.unix,syslog-message,ipaddr,findlib,cryptokit,re,str,xml-light,dynlink,cohttp-lwt-unix"

I suspect the computation of the dependencies fail silently when hmap is not installed. This is why ocsigenserver tries (unsuccessfully) to load unix.cma. One should check the return value of Unix.close_process_in inp below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a failure case when this happens so it should now be noticed. Thanks for the debugging !

Julow and others added 5 commits April 24, 2025 11:14
This replaces all uses of the Lwt_log library by Logs. Lwt_log is
deprecated and its README suggest to use Logs instead so it seems like a
good choice.

The bulk of the change was done with the lwt-log-to-logs tool.

This is almost a 1 to 1 translation as the two libraries are very
similar but there are some differences:

- The "Fatal" log level doesn't exist in Logs. "Error" is used instead.

- Log messages are formatted with Format.

- Logs has no equivalent of "broadcast" and "dispatch" available out of
  the box. These operations are easily supported by generating more
  code.

- There is no equivalent for Lwt_log.add_rule in Logs. Luckily it can be
  avoided in this project. This might cause more work in Ocsigen
  applications that use their own log sections.

- Syslog support is done by the "logs-syslog" library.

- There is no equivalent for Lwt_log.close. Ocsigen_messages is still
  able to close its reporters, except for the syslog reporter, which
  doesn't support this operation.
This restores Ocsigen's message format, including the date and section
name.

This adds the log level to the message, which was missing before.
Co-authored-by: Jérôme Vouillon <[email protected]>
This caused the config to be generated with the wrong dependency list,
which caused errors while loading server plugins at runtime.
@Julow Julow force-pushed the remove-lwt-logs branch from 103999d to 8802573 Compare April 24, 2025 10:09
@smorimoto
Copy link
Member

I think we can merge both if you fix the build and resolve the conflict of ocsigen/eliom#822.

Julow added 3 commits May 6, 2025 11:48
The comments are not replaced as any generic comment would be less
useful than the signature itself.
@Julow
Copy link
Contributor Author

Julow commented May 6, 2025

Thanks for reviewing :) I think it's all fixed now.

@smorimoto smorimoto merged commit 395125c into ocsigen:master May 6, 2025
37 of 40 checks passed
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.

4 participants