Coder Social home page Coder Social logo

'line' is a tuple on OTP-24 about lager HOT 14 CLOSED

rlipscombe avatar rlipscombe commented on July 23, 2024
'line' is a tuple on OTP-24

from lager.

Comments (14)

rlipscombe avatar rlipscombe commented on July 23, 2024 2

I'm going to be explicit here. I've got an example program: https://github.com/rlipscombe/lager_loc. It uses 'line' in the formatter config for lager_default_formatter.

When compiled with OTP-23, it logs the following:

2021-06-11 20:05:27.411 [info] <0.119.0>@lager_loc_app:start:13 Hello World!

When compiled with OTP-24.0.2, it logs the following:

2021-06-11 20:08:15.284 [info] <0.118.0>@lager_loc_app:start:{13,5} Hello World!

The column information appears to be the start of the lager token in lager:info, so it's potentially useful.

from lager.

rlipscombe avatar rlipscombe commented on July 23, 2024 1

This was fixed in #560

from lager.

rlipscombe avatar rlipscombe commented on July 23, 2024

Should probably also rename Line to Loc, but that would be a very noisy diff.

from lager.

jadeallenx avatar jadeallenx commented on July 23, 2024

Is there some reason why you want to throw away the column information? Or is it that it breaks some kind of reporting tool that you're using?

from lager.

rlipscombe avatar rlipscombe commented on July 23, 2024
  1. It looks unusual when formatted as a tuple. For consistency with most other tools, it should be Line:Col. For this, the metadata ought to have line and col attributes.
  2. The column information doesn't mean anything, as far as I can tell, because it's been run through a parse transform.

from lager.

rlipscombe avatar rlipscombe commented on July 23, 2024

Oh, yes. It also occurs to me that custom backends might be surprised to see a tuple in the 'line' metadata. Consider the cases where they're converting it to a fixed schema that's expecting an integer.

Rollbar, for example (see https://explorer.docs.rollbar.com/#operation/create-item) has separate fields for lineno and colno. So, while it'd be useful to have both in the metadata, having them in the same metadata attribute is likely to break any lager->rollbar backends that currently expect an integer.

from lager.

paulo-ferraz-oliveira avatar paulo-ferraz-oliveira commented on July 23, 2024

Following what Erlang did with error_location, would an option be suitable? This would keep existing behaviour while allowing for opt-in "line only". I'd prefer it if lager didn't eat up potentially useful info.

from lager.

paulo-ferraz-oliveira avatar paulo-ferraz-oliveira commented on July 23, 2024

Oh, yeah, on the other hand, as @rlipscombe states, if the column is wrong it's not useful and could/should be discarded.

from lager.

rlipscombe avatar rlipscombe commented on July 23, 2024

It's entirely possible that the column is not wrong, and I've just been reading it wrong. If it's useful, I don't want to throw it away.

But: in the interests of not breaking any custom backend, the 'line' metadata should be unchanged. I propose that, on OTP-24, the parse transform, should add a new metadata item 'column' in addition.

from lager.

paulo-ferraz-oliveira avatar paulo-ferraz-oliveira commented on July 23, 2024

I agree that if it's considered a breaking change (e.g. a callback signature is spec'ed wrong) AND the column info. is OK, your approach of adding metadata is reasonable.

from lager.

rlipscombe avatar rlipscombe commented on July 23, 2024

^^ pull request that shows what I'm suggesting.

from lager.

paulo-ferraz-oliveira avatar paulo-ferraz-oliveira commented on July 23, 2024

FWIW (even as a fast workaround), you can achieve non-column log by adding {error_location, line} to your rebar.config's erl_opts (I tested this on your lager_loc repo.), but I do agree separating the two is more useful.

from lager.

0k-1 avatar 0k-1 commented on July 23, 2024

{error_location, line}FWIW(即使作为一种快速的解决方法),您可以通过添加到您rebar.config的 's来实现非列日志erl_opts(我在您的lager_locrepo 上对此进行了测试。),但我同意将两者分开更有用。

If LINE is Tuple type, although it is no problem to generate beam, the use of a function erl_prettypr: format (erl_synntax: form_list (AC)) to code will report an error:
{var,{13,13},'String'},
{atom,{13,2},none},
{integer,{13,2},4096},
{integer,{13,2},64},
{var,{13,2},'__Leveltest113'},
{var,{13,2},'__Tracestest113'},
{atom,{13,2},lager_event},
{var,{13,2},'__Pidtest113'}]}]},
{clause,{13,2},[{var,{13,2},'_'}],[],[{atom,{13,2},ok}]}]}]}]},
{eof,{42,30}}]** exception error: bad argument
in function integer_to_list/1
called as integer_to_list({13,2})
*** argument 1: not an integer
in call from erl_syntax:integer_literal/1 (erl_syntax.erl, line 1699)
in call from erl_prettypr:lay_2/2 (erl_prettypr.erl, line 460)
in call from erl_prettypr:seq/4 (erl_prettypr.erl, line 1437)
in call from erl_prettypr:seq/4 (erl_prettypr.erl, line 1440)
in call from erl_prettypr:lay_2/2 (erl_prettypr.erl, line 475)
in call from erl_prettypr:seq/4 (erl_prettypr.erl, line 1439)
in call from erl_prettypr:seq/4 (erl_prettypr.erl, line 1440)

from lager.

0k-1 avatar 0k-1 commented on July 23, 2024

{error_location, line}FWIW(即使有一种快速的解决方法),您也可以通过添加到您rebar.config实现的非测试列日志erl_opts(我在您的lager_loc回购上进行的)。 。

Convert {Integer, Line, LINE} to
{l, c} = line,
{table, line, [{integer, line, l}, {integer, line, c}]}
Is it a correct way?

from lager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.