Giter VIP home page Giter VIP logo

Comments (8)

tarleb avatar tarleb commented on June 1, 2024 2

The following might be a reasonable design:

New module pandoc.lua with three functions:

  • pandoc.log.warn -- like warn, but without support for control messages
  • pandoc.log.info -- like pandoc.log.warn, but raises a ScriptingInfo log message (requires an API change)
  • pandoc.log.silence -- applies a function, but returns the log messages generated by the call as the first result instead of logging them in the main log. The function's other results are returned as additional return values.

It would be enough to resolve this issues as well as #9077.

from pandoc.

tarleb avatar tarleb commented on June 1, 2024 1

I've creates #9668 for experimentation and as a proof of concept.

from pandoc.

jgm avatar jgm commented on June 1, 2024

If the output of warn currently does go into the log file, then I don't see what more is needed. We certainly don't want io.write to go to the log file in general. And error should create an error, not a warning (which is what the log file contains).

from pandoc.

tarleb avatar tarleb commented on June 1, 2024

My thought process when I suggested to open this issue was that warn can only produce warnings, but not info entries. What I had in mind was to allow something like this:

local orig_io_write = io.write
io.write = function (...)
  pandoc.report('This is an info', 'INFO')
  return orig_io_write(...)
end

I.e., allow users to redefine io.write such that additional info gets logged with severity INFO.

I believe that giving users more access to the logging system would generally be a good idea. But it's difficult to make it useful without just tying it to the internals, as those should probably remain hidden.

A suitable API design might be achievable, but I don't have one yet.

from pandoc.

jgm avatar jgm commented on June 1, 2024

When they use warn currently, what kind of LogMessage is generated? Is there a special log message for warnings from Lua filters?

from pandoc.

estedeahora avatar estedeahora commented on June 1, 2024

I understand @jgm's concern about not making pandoc too complex. But as @tarleb points out, I think it would be useful to have messages at the 'info' level (which is why I use io.write). In my particular use case, I use io.write to notify the user of some decisions that occur during filter execution, but which are not warnings. I understand that it would be very useful to have a pandoc.report function like the one proposed by @tarleb, that allows to make pandoc.report('This is an info', INFO') / pandoc.report('This is a warning', 'WARNING'), independently from what the final user is informed. Then each filter could customise it to print or not print console output (this way you don't interfere with the behaviour of io.write which can have other uses).

I want to clarify a few points regarding the behaviour of warn. On one hand, the @on / @off option, does not work as the first parameter of warn (i.e. warn('@on', 'my message'), but by setting the warn('@on') behaviour, and then using warn('my message') again with the message. On the other hand, even when warn('@off') is set, the function returns a message in the console (which can be intimidating to an 'ordinary' user). In fact what '@off' does is suppress 'clean' console messages. It is because of these limitations of warm`, that I would be interested in having another way of passing information to the user.

Thank you very much for the comments, they really help me also to clarify what is the behaviour I am asking for.

from pandoc.

tarleb avatar tarleb commented on June 1, 2024

When they use warn currently, what kind of LogMessage is generated? Is there a special log message for warnings from Lua filters?

Yes, pandoc generates a ScriptingWarning message, which was introduced specifically for that purpose. The relevant PR was #8685.

from pandoc.

tarleb avatar tarleb commented on June 1, 2024

The expectation is that users will use --silent if they don't want pandoc's warning messages to be printed in the terminal. However, setting warn '@on' will make sure that the warn message always gets printed to the terminal, as happens in the default lua executable. But I agree that it's confusing to see the same message twice, one time as-is, and another time with info about the location where warn was involved. There might be a better way.

from pandoc.

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.