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

Lwt_log: how can we use it? #468

Closed
dannywillems opened this issue Sep 5, 2017 · 9 comments
Closed

Lwt_log: how can we use it? #468

dannywillems opened this issue Sep 5, 2017 · 9 comments
Labels

Comments

@dannywillems
Copy link
Member

dannywillems commented Sep 5, 2017

Are there simple examples to use Lwt_log to write logs? Do we need to initialize something before using Lwt_log.info "Hello, world!"?

Is it recommended to use it to log lots of information (to stdout and in files)?

@aantron
Copy link
Collaborator

aantron commented Sep 6, 2017

@dannywillems, try the code in this post: https://discuss.ocaml.org/t/about-lwt-concurrency-library/150/6:

let () =
  Lwt_log_core.default :=
    Lwt_log.channel
      ~template:"$(date).$(milliseconds) [$(level)] $(message)"
      ~close_mode:`Keep
      ~channel:Lwt_io.stdout
      ();

  Lwt_log_core.add_rule "*" Lwt_log_core.Info;

  Lwt_main.run begin
    Lwt_log_core.info "blah"
  end

(* ocamlfind opt -linkpkg -package lwt.unix foo.ml && ./a.out *)

As per that post, you would normally use module Lwt_log, not Lwt_log_core everywhere. I was just being explicit about what actual underlying module everything was coming from.

@aantron aantron added the docs label Sep 6, 2017
@aantron
Copy link
Collaborator

aantron commented Sep 6, 2017

Also, even if this answers your question, let's leave the issue open to remind about improving the docs.

@rgrinberg
Copy link
Contributor

@dannywillems Have a look at https://github.com/dbuenzli/logs for a logging solution. It has a better API for logging and isn't Lwt specific. Lwt_log should be deprecated IMO.

@dannywillems
Copy link
Member Author

Thanks @rgrinberg and @aantron. Sorry to answer now.

@aantron
Copy link
Collaborator

aantron commented Oct 12, 2017

No worries, most open source takes place at the rate at which people happen to by luck be available :)

@aantron
Copy link
Collaborator

aantron commented Oct 13, 2017

I'm in favor of deprecating Lwt_log in principle, as we evidently don't have the labor resources to properly maintain it. We would suggest people use logs, in particular Logs_lwt`.

I found the docs of Logs_lwt also a bit nebulous last December, so maybe they ought to be improved as well. Not sure what their current status is, and I don't remember the specific difficulties I was having. I did end up using it successfully, though.

@rgrinberg, any thoughts on what to do about Lwt_log in terms of packaging? Perhaps we could factor it out into its own package, and then constrain that package with an upper bound when Lwt_log becomes incompatible with Lwt?

@aantron
Copy link
Collaborator

aantron commented Oct 13, 2017

Ok, I added the example to the module description, stated the relation to Lwt_log_core (telling the reader that most of Lwt_log is documented in Lwt_log_core), and recommended checking out Logs_lwt (linking to it and the home page of logs). Given the theme is we don't have enough labor resources to work on Lwt_log, including factoring it, I think this should be good for now. Please let me know any thoughts.

@rgrinberg
Copy link
Contributor

any thoughts on what to do about Lwt_log in terms of packaging? Perhaps we could factor it out into its own package, and then constrain that package with an upper bound when Lwt_log becomes incompatible with Lwt?

Seems like it would be easier to just fix it rather than mess around with upper bounds?

I agree with splitting the package for the purpose of getting rid of more dotted findlib names.

@aantron
Copy link
Collaborator

aantron commented Oct 20, 2017

Factoring out Lwt_log is beginning in #484 by @hannesm, in particular see #484 (comment) for a plan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants