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

You could provide a way to explicitly pass locations #1

Open
gasche opened this issue May 27, 2015 · 1 comment
Open

You could provide a way to explicitly pass locations #1

gasche opened this issue May 27, 2015 · 1 comment
Assignees

Comments

@gasche
Copy link

gasche commented May 27, 2015

Using the calltrace information is a fragile way to get location information -- in particular it requires programs to be compiled with -g. You should consider also providing an API that allows user to pass a location explicitly (and I would argue that the short name on the "path of least effort" should be this function, with eg. journal_send_implicit for the callstack-inspecting version).

Locations can be passed manually after having been inserted automatically by a syntactic processing pass (eg. one could think of a [%located journal_send] foo bar extension).

As of 4.02, OCaml provides the (admittedly under-documented, and of debatable elegance) __LOC__, __FILE__ and __LINE__ macros. so you could just encourage users to consistently write journal_send __LOC__ ... without the syntactic sugar.

Note that beside removing the requirement to consistently use -g, this gives user more control on the reported location. In particular, if (as a library user) you define auxiliary functions to perform the logging, you may want to report the location of the caller function instead, and letting user explicitly manipulate location as first-class values gives them the flexibility to decide this.

@juergenhoetzel juergenhoetzel self-assigned this May 27, 2015
@juergenhoetzel
Copy link
Owner

@gasche Thanks for pointing that out. I wasn't aware of the new macros. I felt something was wrong after implementing get_callstack hack 😞

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

No branches or pull requests

2 participants