[R logs] Help in develop a simply logs package

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

[R logs] Help in develop a simply logs package

DataK - B. THIEURMEL
Hi,

With the use of R in production, it is necessary to have a system of
logs effective, and light.

Package exist as to futile.logger, but it require the additional coding
of logs. So it is thus impossible / very difficult to use it with all
package them used in the calculation

Our idea is to develop one packages global, simple, who would allow to
identify all the errors, warning, message generated by the functions
stop(), warning() and message() stop as well as by signals and
internally code, with log levels configurable later by package,
functions...

One way is to overwrite temporarily the functions stop(), warning() and
message() of base package, but I think is not a good thing, and
furthermore, we lose all signals and internally "message"...

A good use of options(error) seems to do the perfect job, but only for
error...

Our problem / question :
- At present, how it is possible to have the same features for messages
and warnings? (like options(errors)) (I don't find...)
- Would new options be possible in a near future R ?
- Have there better / other possibilities to handle all the warnings,
message of the way which we wish?

Hope is clear. Open to any suggestions.

Thank you in advance

--
Benoit Thieurmel
+33 6 69 04 06 11

DataKnowledge
46 rue Amsterdam - 75009 Paris

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

Duncan Murdoch-2
On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:

> Hi,
>
> With the use of R in production, it is necessary to have a system of
> logs effective, and light.
>
> Package exist as to futile.logger, but it require the additional coding
> of logs. So it is thus impossible / very difficult to use it with all
> package them used in the calculation
>
> Our idea is to develop one packages global, simple, who would allow to
> identify all the errors, warning, message generated by the functions
> stop(), warning() and message() stop as well as by signals and
> internally code, with log levels configurable later by package,
> functions...
>
> One way is to overwrite temporarily the functions stop(), warning() and
> message() of base package, but I think is not a good thing, and
> furthermore, we lose all signals and internally "message"...
>
> A good use of options(error) seems to do the perfect job, but only for
> error...
>
> Our problem / question :
> - At present, how it is possible to have the same features for messages
> and warnings? (like options(errors)) (I don't find...)
> - Would new options be possible in a near future R ?
> - Have there better / other possibilities to handle all the warnings,
> message of the way which we wish?
>

withCallingHandlers() lets you evaluate expressions with code to catch
messages, warnings and errors.

I don't know if there's a way to evaluate every expression entered at
the console within withCallingHandlers() for an effect like
options(error=), but you can certainly write code to read a file and
evaluate every expression in it within a withCallingHandlers() call.

Duncan Murdoch

> Hope is clear. Open to any suggestions.
>
> Thank you in advance
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

Gergely Daróczi
On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch <[hidden email]>
wrote:

> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
> > Hi,
> >
> > With the use of R in production, it is necessary to have a system of
> > logs effective, and light.
> >
> > Package exist as to futile.logger, but it require the additional coding
> > of logs. So it is thus impossible / very difficult to use it with all
> > package them used in the calculation
> >
> > Our idea is to develop one packages global, simple, who would allow to
> > identify all the errors, warning, message generated by the functions
> > stop(), warning() and message() stop as well as by signals and
> > internally code, with log levels configurable later by package,
> > functions...
> >
> > One way is to overwrite temporarily the functions stop(), warning() and
> > message() of base package, but I think is not a good thing, and
> > furthermore, we lose all signals and internally "message"...
> >
> > A good use of options(error) seems to do the perfect job, but only for
> > error...
> >
> > Our problem / question :
> > - At present, how it is possible to have the same features for messages
> > and warnings? (like options(errors)) (I don't find...)
> > - Would new options be possible in a near future R ?
> > - Have there better / other possibilities to handle all the warnings,
> > message of the way which we wish?
> >
>
> ​​
> withCallingHandlers() lets you evaluate expressions with code to catch
> messages, warnings and errors.
>

That's exactly what I'm using in "pander::evals" to capture all
error/warning/normal messages while evaluating an R command, and to also
capture the results (as R objects), stdout and the printed version of the
object -- which might be useful in a custom environment. E.g. I use this
function to evaluate all R chunks in markdown document and also to store
all R messages run at the rapporter.net API. Please let me know if anyone
is interested, and I will start cleaning up the related codebase and
publish on GH -- although "pander" and "evals" is already there:
https://github.com/Rapporter/pander

Quick demo: http://pastebin.com/jCUkgKim


>
> I don't know if there's a way to evaluate every expression entered at
> the console within withCallingHandlers() for an effect like
> options(error=), but you can certainly write code to read a file and
> evaluate every expression in it within a withCallingHandlers() call.
>
> Duncan Murdoch
>
> > Hope is clear. Open to any suggestions.
> >
> > Thank you in advance
> >
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

DataK - B. THIEURMEL
Thank. withCallingHandlers() and "pander::evals" seem to be very
interesting, but little adapted to the analysis of one or several
scripts R / of many lines of code. Our goal is one packages requiring no
modifications of code R to be able to get back all the desired
information.

Is-there a hope in seeing R core team adding two options warn and
message with the same features as options(error) ? Or if we try (and
succeed) to code a patch for it, to see it integrating in R ?

I think that it would be very useful.

Benoit

Le 2014-10-07 14:38, Gergely Daróczi a écrit :

> On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
> <[hidden email]> wrote:
>
>> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>>> Hi,
>>>
>>> With the use of R in production, it is necessary to have a system
>> of
>>> logs effective, and light.
>>>
>>> Package exist as to futile.logger, but it require the additional
>> coding
>>> of logs. So it is thus impossible / very difficult to use it with
>> all
>>> package them used in the calculation
>>>
>>> Our idea is to develop one packages global, simple, who would
>> allow to
>>> identify all the errors, warning, message generated by the
>> functions
>>> stop(), warning() and message() stop as well as by signals and
>>> internally code, with log levels configurable later by package,
>>> functions...
>>>
>>> One way is to overwrite temporarily the functions stop(),
>> warning() and
>>> message() of base package, but I think is not a good thing, and
>>> furthermore, we lose all signals and internally "message"...
>>>
>>> A good use of options(error) seems to do the perfect job, but
>> only for
>>> error...
>>>
>>> Our problem / question :
>>> - At present, how it is possible to have the same features for
>> messages
>>> and warnings? (like options(errors)) (I don't find...)
>>> - Would new options be possible in a near future R ?
>>> - Have there better / other possibilities to handle all the
>> warnings,
>>> message of the way which we wish?
>>>
>>
>> ​​withCallingHandlers() lets you evaluate expressions with code
>> to catch
>> messages, warnings and errors.
>
> That's exactly what I'm using in "pander::evals" to capture all
> error/warning/normal messages while evaluating an R command, and to
> also capture the results (as R objects), stdout and the printed
> version of the object -- which might be useful in a custom
> environment. E.g. I use this function to evaluate all R chunks in
> markdown document and also to store all R messages run at the
> rapporter.net [2] API. Please let me know if anyone is interested, and
> I will start cleaning up the related codebase and publish on GH --
> although "pander" and "evals" is already
> there: https://github.com/Rapporter/pander [3]
>
> Quick demo: http://pastebin.com/jCUkgKim [4]
>  
>
>> I don't know if there's a way to evaluate every expression entered
>> at
>> the console within withCallingHandlers() for an effect like
>> options(error=), but you can certainly write code to read a file
>> and
>> evaluate every expression in it within a withCallingHandlers()
>> call.
>>
>> Duncan Murdoch
>>
>>> Hope is clear. Open to any suggestions.
>>>
>>> Thank you in advance
>>>
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
>
>
>
> Links:
> ------
> [1] https://stat.ethz.ch/mailman/listinfo/r-devel
> [2] http://rapporter.net
> [3] https://github.com/Rapporter/pander
> [4] http://pastebin.com/jCUkgKim

--
Benoit Thieurmel
+33 6 69 04 06 11

DataKnowledge
46 rue Amsterdam - 75009 Paris

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

Duncan Murdoch-2
On 07/10/2014 10:16 AM, DataK - B. THIEURMEL wrote:
> Thank. withCallingHandlers() and "pander::evals" seem to be very
> interesting, but little adapted to the analysis of one or several
> scripts R / of many lines of code. Our goal is one packages requiring no
> modifications of code R to be able to get back all the desired
> information.
>
> Is-there a hope in seeing R core team adding two options warn and
> message with the same features as options(error) ? Or if we try (and
> succeed) to code a patch for it, to see it integrating in R ?

No, I don't think so.  withCallingHandlers is all you need for your purpose.

Duncan Murdoch

>
> I think that it would be very useful.
>
> Benoit
>
> Le 2014-10-07 14:38, Gergely Daróczi a écrit :
> > On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
> > <[hidden email]> wrote:
> >
> >> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
> >>> Hi,
> >>>
> >>> With the use of R in production, it is necessary to have a system
> >> of
> >>> logs effective, and light.
> >>>
> >>> Package exist as to futile.logger, but it require the additional
> >> coding
> >>> of logs. So it is thus impossible / very difficult to use it with
> >> all
> >>> package them used in the calculation
> >>>
> >>> Our idea is to develop one packages global, simple, who would
> >> allow to
> >>> identify all the errors, warning, message generated by the
> >> functions
> >>> stop(), warning() and message() stop as well as by signals and
> >>> internally code, with log levels configurable later by package,
> >>> functions...
> >>>
> >>> One way is to overwrite temporarily the functions stop(),
> >> warning() and
> >>> message() of base package, but I think is not a good thing, and
> >>> furthermore, we lose all signals and internally "message"...
> >>>
> >>> A good use of options(error) seems to do the perfect job, but
> >> only for
> >>> error...
> >>>
> >>> Our problem / question :
> >>> - At present, how it is possible to have the same features for
> >> messages
> >>> and warnings? (like options(errors)) (I don't find...)
> >>> - Would new options be possible in a near future R ?
> >>> - Have there better / other possibilities to handle all the
> >> warnings,
> >>> message of the way which we wish?
> >>>
> >>
> >> ​​withCallingHandlers() lets you evaluate expressions with code
> >> to catch
> >> messages, warnings and errors.
> >
> > That's exactly what I'm using in "pander::evals" to capture all
> > error/warning/normal messages while evaluating an R command, and to
> > also capture the results (as R objects), stdout and the printed
> > version of the object -- which might be useful in a custom
> > environment. E.g. I use this function to evaluate all R chunks in
> > markdown document and also to store all R messages run at the
> > rapporter.net [2] API. Please let me know if anyone is interested, and
> > I will start cleaning up the related codebase and publish on GH --
> > although "pander" and "evals" is already
> > there: https://github.com/Rapporter/pander [3]
> >
> > Quick demo: http://pastebin.com/jCUkgKim [4]
> >
> >
> >> I don't know if there's a way to evaluate every expression entered
> >> at
> >> the console within withCallingHandlers() for an effect like
> >> options(error=), but you can certainly write code to read a file
> >> and
> >> evaluate every expression in it within a withCallingHandlers()
> >> call.
> >>
> >> Duncan Murdoch
> >>
> >>> Hope is clear. Open to any suggestions.
> >>>
> >>> Thank you in advance
> >>>
> >>
> >> ______________________________________________
> >> [hidden email] mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
> >
> >
> >
> > Links:
> > ------
> > [1] https://stat.ethz.ch/mailman/listinfo/r-devel
> > [2] http://rapporter.net
> > [3] https://github.com/Rapporter/pander
> > [4] http://pastebin.com/jCUkgKim
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

DataK - B. THIEURMEL
OK, thank you for your answers. We are thus going to continue by
analyzing these features

Le 2014-10-07 16:29, Duncan Murdoch a écrit :

> On 07/10/2014 10:16 AM, DataK - B. THIEURMEL wrote:
>> Thank. withCallingHandlers() and "pander::evals" seem to be very
>> interesting, but little adapted to the analysis of one or several
>> scripts R / of many lines of code. Our goal is one packages requiring
>> no
>> modifications of code R to be able to get back all the desired
>> information.
>>
>> Is-there a hope in seeing R core team adding two options warn and
>> message with the same features as options(error) ? Or if we try (and
>> succeed) to code a patch for it, to see it integrating in R ?
>
> No, I don't think so.  withCallingHandlers is all you need for your
> purpose.
>
> Duncan Murdoch
>
>>
>> I think that it would be very useful.
>>
>> Benoit
>>
>> Le 2014-10-07 14:38, Gergely Daróczi a écrit :
>> > On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
>> > <[hidden email]> wrote:
>> >
>> >> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>> >>> Hi,
>> >>>
>> >>> With the use of R in production, it is necessary to have a system
>> >> of
>> >>> logs effective, and light.
>> >>>
>> >>> Package exist as to futile.logger, but it require the additional
>> >> coding
>> >>> of logs. So it is thus impossible / very difficult to use it with
>> >> all
>> >>> package them used in the calculation
>> >>>
>> >>> Our idea is to develop one packages global, simple, who would
>> >> allow to
>> >>> identify all the errors, warning, message generated by the
>> >> functions
>> >>> stop(), warning() and message() stop as well as by signals and
>> >>> internally code, with log levels configurable later by package,
>> >>> functions...
>> >>>
>> >>> One way is to overwrite temporarily the functions stop(),
>> >> warning() and
>> >>> message() of base package, but I think is not a good thing, and
>> >>> furthermore, we lose all signals and internally "message"...
>> >>>
>> >>> A good use of options(error) seems to do the perfect job, but
>> >> only for
>> >>> error...
>> >>>
>> >>> Our problem / question :
>> >>> - At present, how it is possible to have the same features for
>> >> messages
>> >>> and warnings? (like options(errors)) (I don't find...)
>> >>> - Would new options be possible in a near future R ?
>> >>> - Have there better / other possibilities to handle all the
>> >> warnings,
>> >>> message of the way which we wish?
>> >>>
>> >>
>> >> ​​withCallingHandlers() lets you evaluate expressions with code
>> >> to catch
>> >> messages, warnings and errors.
>> >
>> > That's exactly what I'm using in "pander::evals" to capture all
>> > error/warning/normal messages while evaluating an R command, and to
>> > also capture the results (as R objects), stdout and the printed
>> > version of the object -- which might be useful in a custom
>> > environment. E.g. I use this function to evaluate all R chunks in
>> > markdown document and also to store all R messages run at the
>> > rapporter.net [2] API. Please let me know if anyone is interested, and
>> > I will start cleaning up the related codebase and publish on GH --
>> > although "pander" and "evals" is already
>> > there: https://github.com/Rapporter/pander [3]
>> >
>> > Quick demo: http://pastebin.com/jCUkgKim [4]
>> >
>> >
>> >> I don't know if there's a way to evaluate every expression entered
>> >> at
>> >> the console within withCallingHandlers() for an effect like
>> >> options(error=), but you can certainly write code to read a file
>> >> and
>> >> evaluate every expression in it within a withCallingHandlers()
>> >> call.
>> >>
>> >> Duncan Murdoch
>> >>
>> >>> Hope is clear. Open to any suggestions.
>> >>>
>> >>> Thank you in advance
>> >>>
>> >>
>> >> ______________________________________________
>> >> [hidden email] mailing list
>> >> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
>> >
>> >
>> >
>> > Links:
>> > ------
>> > [1] https://stat.ethz.ch/mailman/listinfo/r-devel
>> > [2] http://rapporter.net
>> > [3] https://github.com/Rapporter/pander
>> > [4] http://pastebin.com/jCUkgKim
>>

--
Benoit Thieurmel
+33 6 69 04 06 11

DataKnowledge
46 rue Amsterdam - 75009 Paris

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

Duncan Murdoch-2
On 07/10/2014 10:41 AM, DataK - B. THIEURMEL wrote:
> OK, thank you for your answers. We are thus going to continue by
> analyzing these features

The general outline would be this:

1.  Call parse() on the whole file.  This will catch any syntax errors.  
If it parses okay, you'll get a vector of expressions to evaluate.

2.  Evaluate each expression in sequence within withCallingHandlers().  
You need to decide what to do if you get an error(); source() would quit
the script at that point, so that's probably a good idea.

Duncan Murdoch

>
> Le 2014-10-07 16:29, Duncan Murdoch a écrit :
> > On 07/10/2014 10:16 AM, DataK - B. THIEURMEL wrote:
> >> Thank. withCallingHandlers() and "pander::evals" seem to be very
> >> interesting, but little adapted to the analysis of one or several
> >> scripts R / of many lines of code. Our goal is one packages requiring
> >> no
> >> modifications of code R to be able to get back all the desired
> >> information.
> >>
> >> Is-there a hope in seeing R core team adding two options warn and
> >> message with the same features as options(error) ? Or if we try (and
> >> succeed) to code a patch for it, to see it integrating in R ?
> >
> > No, I don't think so.  withCallingHandlers is all you need for your
> > purpose.
> >
> > Duncan Murdoch
> >
> >>
> >> I think that it would be very useful.
> >>
> >> Benoit
> >>
> >> Le 2014-10-07 14:38, Gergely Daróczi a écrit :
> >> > On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
> >> > <[hidden email]> wrote:
> >> >
> >> >> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
> >> >>> Hi,
> >> >>>
> >> >>> With the use of R in production, it is necessary to have a system
> >> >> of
> >> >>> logs effective, and light.
> >> >>>
> >> >>> Package exist as to futile.logger, but it require the additional
> >> >> coding
> >> >>> of logs. So it is thus impossible / very difficult to use it with
> >> >> all
> >> >>> package them used in the calculation
> >> >>>
> >> >>> Our idea is to develop one packages global, simple, who would
> >> >> allow to
> >> >>> identify all the errors, warning, message generated by the
> >> >> functions
> >> >>> stop(), warning() and message() stop as well as by signals and
> >> >>> internally code, with log levels configurable later by package,
> >> >>> functions...
> >> >>>
> >> >>> One way is to overwrite temporarily the functions stop(),
> >> >> warning() and
> >> >>> message() of base package, but I think is not a good thing, and
> >> >>> furthermore, we lose all signals and internally "message"...
> >> >>>
> >> >>> A good use of options(error) seems to do the perfect job, but
> >> >> only for
> >> >>> error...
> >> >>>
> >> >>> Our problem / question :
> >> >>> - At present, how it is possible to have the same features for
> >> >> messages
> >> >>> and warnings? (like options(errors)) (I don't find...)
> >> >>> - Would new options be possible in a near future R ?
> >> >>> - Have there better / other possibilities to handle all the
> >> >> warnings,
> >> >>> message of the way which we wish?
> >> >>>
> >> >>
> >> >> ​​withCallingHandlers() lets you evaluate expressions with code
> >> >> to catch
> >> >> messages, warnings and errors.
> >> >
> >> > That's exactly what I'm using in "pander::evals" to capture all
> >> > error/warning/normal messages while evaluating an R command, and to
> >> > also capture the results (as R objects), stdout and the printed
> >> > version of the object -- which might be useful in a custom
> >> > environment. E.g. I use this function to evaluate all R chunks in
> >> > markdown document and also to store all R messages run at the
> >> > rapporter.net [2] API. Please let me know if anyone is interested, and
> >> > I will start cleaning up the related codebase and publish on GH --
> >> > although "pander" and "evals" is already
> >> > there: https://github.com/Rapporter/pander [3]
> >> >
> >> > Quick demo: http://pastebin.com/jCUkgKim [4]
> >> >
> >> >
> >> >> I don't know if there's a way to evaluate every expression entered
> >> >> at
> >> >> the console within withCallingHandlers() for an effect like
> >> >> options(error=), but you can certainly write code to read a file
> >> >> and
> >> >> evaluate every expression in it within a withCallingHandlers()
> >> >> call.
> >> >>
> >> >> Duncan Murdoch
> >> >>
> >> >>> Hope is clear. Open to any suggestions.
> >> >>>
> >> >>> Thank you in advance
> >> >>>
> >> >>
> >> >> ______________________________________________
> >> >> [hidden email] mailing list
> >> >> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
> >> >
> >> >
> >> >
> >> > Links:
> >> > ------
> >> > [1] https://stat.ethz.ch/mailman/listinfo/r-devel
> >> > [2] http://rapporter.net
> >> > [3] https://github.com/Rapporter/pander
> >> > [4] http://pastebin.com/jCUkgKim
> >>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

DataK - B. THIEURMEL
Do you think there is a way to apply a "global" withCallingHandlers() on
all environement / packages loaded, and then all R code will be executed
with the defined handler ? With this way, we can define what we want for
warning, message, error, ... one time, and apply it without needed of
parse() or added withCallingHandlers in initial code...

Something like this :

withCallingHandlersGlobal <- function(...) {
   handlers <- list(...)
   classes <- names(handlers)
   parentenv <- all.environment
   if (length(classes) != length(handlers))
     stop("bad handler specification")
   .Internal(.addCondHands(classes, handlers, parentenv, NULL, TRUE))
}

withCallingHandlersGlobal(warning = function(w) {print("Global
handler")})

warning("A")
> "Global handler"
rnorm("A")
> "Global handler"



Le 2014-10-07 16:51, Duncan Murdoch a écrit :

> On 07/10/2014 10:41 AM, DataK - B. THIEURMEL wrote:
>> OK, thank you for your answers. We are thus going to continue by
>> analyzing these features
>
> The general outline would be this:
>
> 1.  Call parse() on the whole file.  This will catch any syntax
> errors.  If it parses okay, you'll get a vector of expressions to
> evaluate.
>
> 2.  Evaluate each expression in sequence within withCallingHandlers().
>  You need to decide what to do if you get an error(); source() would
> quit the script at that point, so that's probably a good idea.
>
> Duncan Murdoch
>>
>> Le 2014-10-07 16:29, Duncan Murdoch a écrit :
>> > On 07/10/2014 10:16 AM, DataK - B. THIEURMEL wrote:
>> >> Thank. withCallingHandlers() and "pander::evals" seem to be very
>> >> interesting, but little adapted to the analysis of one or several
>> >> scripts R / of many lines of code. Our goal is one packages requiring
>> >> no
>> >> modifications of code R to be able to get back all the desired
>> >> information.
>> >>
>> >> Is-there a hope in seeing R core team adding two options warn and
>> >> message with the same features as options(error) ? Or if we try (and
>> >> succeed) to code a patch for it, to see it integrating in R ?
>> >
>> > No, I don't think so.  withCallingHandlers is all you need for your
>> > purpose.
>> >
>> > Duncan Murdoch
>> >
>> >>
>> >> I think that it would be very useful.
>> >>
>> >> Benoit
>> >>
>> >> Le 2014-10-07 14:38, Gergely Daróczi a écrit :
>> >> > On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
>> >> > <[hidden email]> wrote:
>> >> >
>> >> >> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>> >> >>> Hi,
>> >> >>>
>> >> >>> With the use of R in production, it is necessary to have a system
>> >> >> of
>> >> >>> logs effective, and light.
>> >> >>>
>> >> >>> Package exist as to futile.logger, but it require the additional
>> >> >> coding
>> >> >>> of logs. So it is thus impossible / very difficult to use it with
>> >> >> all
>> >> >>> package them used in the calculation
>> >> >>>
>> >> >>> Our idea is to develop one packages global, simple, who would
>> >> >> allow to
>> >> >>> identify all the errors, warning, message generated by the
>> >> >> functions
>> >> >>> stop(), warning() and message() stop as well as by signals and
>> >> >>> internally code, with log levels configurable later by package,
>> >> >>> functions...
>> >> >>>
>> >> >>> One way is to overwrite temporarily the functions stop(),
>> >> >> warning() and
>> >> >>> message() of base package, but I think is not a good thing, and
>> >> >>> furthermore, we lose all signals and internally "message"...
>> >> >>>
>> >> >>> A good use of options(error) seems to do the perfect job, but
>> >> >> only for
>> >> >>> error...
>> >> >>>
>> >> >>> Our problem / question :
>> >> >>> - At present, how it is possible to have the same features for
>> >> >> messages
>> >> >>> and warnings? (like options(errors)) (I don't find...)
>> >> >>> - Would new options be possible in a near future R ?
>> >> >>> - Have there better / other possibilities to handle all the
>> >> >> warnings,
>> >> >>> message of the way which we wish?
>> >> >>>
>> >> >>
>> >> >> ​​withCallingHandlers() lets you evaluate expressions with code
>> >> >> to catch
>> >> >> messages, warnings and errors.
>> >> >
>> >> > That's exactly what I'm using in "pander::evals" to capture all
>> >> > error/warning/normal messages while evaluating an R command, and to
>> >> > also capture the results (as R objects), stdout and the printed
>> >> > version of the object -- which might be useful in a custom
>> >> > environment. E.g. I use this function to evaluate all R chunks in
>> >> > markdown document and also to store all R messages run at the
>> >> > rapporter.net [2] API. Please let me know if anyone is interested, and
>> >> > I will start cleaning up the related codebase and publish on GH --
>> >> > although "pander" and "evals" is already
>> >> > there: https://github.com/Rapporter/pander [3]
>> >> >
>> >> > Quick demo: http://pastebin.com/jCUkgKim [4]
>> >> >
>> >> >
>> >> >> I don't know if there's a way to evaluate every expression entered
>> >> >> at
>> >> >> the console within withCallingHandlers() for an effect like
>> >> >> options(error=), but you can certainly write code to read a file
>> >> >> and
>> >> >> evaluate every expression in it within a withCallingHandlers()
>> >> >> call.
>> >> >>
>> >> >> Duncan Murdoch
>> >> >>
>> >> >>> Hope is clear. Open to any suggestions.
>> >> >>>
>> >> >>> Thank you in advance
>> >> >>>
>> >> >>
>> >> >> ______________________________________________
>> >> >> [hidden email] mailing list
>> >> >> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
>> >> >
>> >> >
>> >> >
>> >> > Links:
>> >> > ------
>> >> > [1] https://stat.ethz.ch/mailman/listinfo/r-devel
>> >> > [2] http://rapporter.net
>> >> > [3] https://github.com/Rapporter/pander
>> >> > [4] http://pastebin.com/jCUkgKim
>> >>
>>

--
Benoit Thieurmel
+33 6 69 04 06 11

DataKnowledge
46 rue Amsterdam - 75009 Paris

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

Gergely Daróczi
In reply to this post by Duncan Murdoch-2
On Tue, Oct 7, 2014 at 4:51 PM, Duncan Murdoch <[hidden email]>
wrote:

> On 07/10/2014 10:41 AM, DataK - B. THIEURMEL wrote:
>
>> OK, thank you for your answers. We are thus going to continue by
>> analyzing these features
>>
>
> The general outline would be this:
>
> 1.  Call parse() on the whole file.  This will catch any syntax errors.
> If it parses okay, you'll get a vector of expressions to evaluate.
>
> 2.  Evaluate each expression in sequence within withCallingHandlers().
> You need to decide what to do if you get an error(); source() would quit
> the script at that point, so that's probably a good idea.


Quick demo with "pander::evals":
https://gist.github.com/daroczig/480af8ad766e96dd25f4


>
>
> Duncan Murdoch
>
>
>> Le 2014-10-07 16:29, Duncan Murdoch a écrit :
>> > On 07/10/2014 10:16 AM, DataK - B. THIEURMEL wrote:
>> >> Thank. withCallingHandlers() and "pander::evals" seem to be very
>> >> interesting, but little adapted to the analysis of one or several
>> >> scripts R / of many lines of code. Our goal is one packages requiring
>> >> no
>> >> modifications of code R to be able to get back all the desired
>> >> information.
>> >>
>> >> Is-there a hope in seeing R core team adding two options warn and
>> >> message with the same features as options(error) ? Or if we try (and
>> >> succeed) to code a patch for it, to see it integrating in R ?
>> >
>> > No, I don't think so.  withCallingHandlers is all you need for your
>> > purpose.
>> >
>> > Duncan Murdoch
>> >
>> >>
>> >> I think that it would be very useful.
>> >>
>> >> Benoit
>> >>
>> >> Le 2014-10-07 14:38, Gergely Daróczi a écrit :
>> >> > On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
>> >> > <[hidden email]> wrote:
>> >> >
>> >> >> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>> >> >>> Hi,
>> >> >>>
>> >> >>> With the use of R in production, it is necessary to have a system
>> >> >> of
>> >> >>> logs effective, and light.
>> >> >>>
>> >> >>> Package exist as to futile.logger, but it require the additional
>> >> >> coding
>> >> >>> of logs. So it is thus impossible / very difficult to use it with
>> >> >> all
>> >> >>> package them used in the calculation
>> >> >>>
>> >> >>> Our idea is to develop one packages global, simple, who would
>> >> >> allow to
>> >> >>> identify all the errors, warning, message generated by the
>> >> >> functions
>> >> >>> stop(), warning() and message() stop as well as by signals and
>> >> >>> internally code, with log levels configurable later by package,
>> >> >>> functions...
>> >> >>>
>> >> >>> One way is to overwrite temporarily the functions stop(),
>> >> >> warning() and
>> >> >>> message() of base package, but I think is not a good thing, and
>> >> >>> furthermore, we lose all signals and internally "message"...
>> >> >>>
>> >> >>> A good use of options(error) seems to do the perfect job, but
>> >> >> only for
>> >> >>> error...
>> >> >>>
>> >> >>> Our problem / question :
>> >> >>> - At present, how it is possible to have the same features for
>> >> >> messages
>> >> >>> and warnings? (like options(errors)) (I don't find...)
>> >> >>> - Would new options be possible in a near future R ?
>> >> >>> - Have there better / other possibilities to handle all the
>> >> >> warnings,
>> >> >>> message of the way which we wish?
>> >> >>>
>> >> >>
>> >> >> ​​withCallingHandlers() lets you evaluate expressions with code
>> >> >> to catch
>> >> >> messages, warnings and errors.
>> >> >
>> >> > That's exactly what I'm using in "pander::evals" to capture all
>> >> > error/warning/normal messages while evaluating an R command, and to
>> >> > also capture the results (as R objects), stdout and the printed
>> >> > version of the object -- which might be useful in a custom
>> >> > environment. E.g. I use this function to evaluate all R chunks in
>> >> > markdown document and also to store all R messages run at the
>> >> > rapporter.net [2] API. Please let me know if anyone is interested,
>> and
>> >> > I will start cleaning up the related codebase and publish on GH --
>> >> > although "pander" and "evals" is already
>> >> > there: https://github.com/Rapporter/pander [3]
>> >> >
>> >> > Quick demo: http://pastebin.com/jCUkgKim [4]
>> >> >
>> >> >
>> >> >> I don't know if there's a way to evaluate every expression entered
>> >> >> at
>> >> >> the console within withCallingHandlers() for an effect like
>> >> >> options(error=), but you can certainly write code to read a file
>> >> >> and
>> >> >> evaluate every expression in it within a withCallingHandlers()
>> >> >> call.
>> >> >>
>> >> >> Duncan Murdoch
>> >> >>
>> >> >>> Hope is clear. Open to any suggestions.
>> >> >>>
>> >> >>> Thank you in advance
>> >> >>>
>> >> >>
>> >> >> ______________________________________________
>> >> >> [hidden email] mailing list
>> >> >> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
>> >> >
>> >> >
>> >> >
>> >> > Links:
>> >> > ------
>> >> > [1] https://stat.ethz.ch/mailman/listinfo/r-devel
>> >> > [2] http://rapporter.net
>> >> > [3] https://github.com/Rapporter/pander
>> >> > [4] http://pastebin.com/jCUkgKim
>> >>
>>
>>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

Duncan Murdoch-2
In reply to this post by DataK - B. THIEURMEL
On 07/10/2014 11:11 AM, DataK - B. THIEURMEL wrote:
> Do you think there is a way to apply a "global" withCallingHandlers() on
> all environement / packages loaded, and then all R code will be executed
> with the defined handler ?

That question makes no sense.  withCallingHandlers is not applied to
environments or packages, it is applied to expressions.

> With this way, we can define what we want for
> warning, message, error, ... one time, and apply it without needed of
> parse() or added withCallingHandlers in initial code...
>
> Something like this :
>
> withCallingHandlersGlobal <- function(...) {
>     handlers <- list(...)
>     classes <- names(handlers)
>     parentenv <- all.environment
>     if (length(classes) != length(handlers))
>       stop("bad handler specification")
>     .Internal(.addCondHands(classes, handlers, parentenv, NULL, TRUE))
> }
>
> withCallingHandlersGlobal(warning = function(w) {print("Global
> handler")})
>
> warning("A")
> > "Global handler"
> rnorm("A")
> > "Global handler"
>

You would need to write the read-eval-print loop.  Read text from the
console until you have a complete expression, then evaluate it in
withCallingHandlers.  Repeat.

Duncan Murdoch

>
> Le 2014-10-07 16:51, Duncan Murdoch a écrit :
> > On 07/10/2014 10:41 AM, DataK - B. THIEURMEL wrote:
> >> OK, thank you for your answers. We are thus going to continue by
> >> analyzing these features
> >
> > The general outline would be this:
> >
> > 1.  Call parse() on the whole file.  This will catch any syntax
> > errors.  If it parses okay, you'll get a vector of expressions to
> > evaluate.
> >
> > 2.  Evaluate each expression in sequence within withCallingHandlers().
> >  You need to decide what to do if you get an error(); source() would
> > quit the script at that point, so that's probably a good idea.
> >
> > Duncan Murdoch
> >>
> >> Le 2014-10-07 16:29, Duncan Murdoch a écrit :
> >> > On 07/10/2014 10:16 AM, DataK - B. THIEURMEL wrote:
> >> >> Thank. withCallingHandlers() and "pander::evals" seem to be very
> >> >> interesting, but little adapted to the analysis of one or several
> >> >> scripts R / of many lines of code. Our goal is one packages requiring
> >> >> no
> >> >> modifications of code R to be able to get back all the desired
> >> >> information.
> >> >>
> >> >> Is-there a hope in seeing R core team adding two options warn and
> >> >> message with the same features as options(error) ? Or if we try (and
> >> >> succeed) to code a patch for it, to see it integrating in R ?
> >> >
> >> > No, I don't think so.  withCallingHandlers is all you need for your
> >> > purpose.
> >> >
> >> > Duncan Murdoch
> >> >
> >> >>
> >> >> I think that it would be very useful.
> >> >>
> >> >> Benoit
> >> >>
> >> >> Le 2014-10-07 14:38, Gergely Daróczi a écrit :
> >> >> > On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
> >> >> > <[hidden email]> wrote:
> >> >> >
> >> >> >> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
> >> >> >>> Hi,
> >> >> >>>
> >> >> >>> With the use of R in production, it is necessary to have a system
> >> >> >> of
> >> >> >>> logs effective, and light.
> >> >> >>>
> >> >> >>> Package exist as to futile.logger, but it require the additional
> >> >> >> coding
> >> >> >>> of logs. So it is thus impossible / very difficult to use it with
> >> >> >> all
> >> >> >>> package them used in the calculation
> >> >> >>>
> >> >> >>> Our idea is to develop one packages global, simple, who would
> >> >> >> allow to
> >> >> >>> identify all the errors, warning, message generated by the
> >> >> >> functions
> >> >> >>> stop(), warning() and message() stop as well as by signals and
> >> >> >>> internally code, with log levels configurable later by package,
> >> >> >>> functions...
> >> >> >>>
> >> >> >>> One way is to overwrite temporarily the functions stop(),
> >> >> >> warning() and
> >> >> >>> message() of base package, but I think is not a good thing, and
> >> >> >>> furthermore, we lose all signals and internally "message"...
> >> >> >>>
> >> >> >>> A good use of options(error) seems to do the perfect job, but
> >> >> >> only for
> >> >> >>> error...
> >> >> >>>
> >> >> >>> Our problem / question :
> >> >> >>> - At present, how it is possible to have the same features for
> >> >> >> messages
> >> >> >>> and warnings? (like options(errors)) (I don't find...)
> >> >> >>> - Would new options be possible in a near future R ?
> >> >> >>> - Have there better / other possibilities to handle all the
> >> >> >> warnings,
> >> >> >>> message of the way which we wish?
> >> >> >>>
> >> >> >>
> >> >> >> ​​withCallingHandlers() lets you evaluate expressions with code
> >> >> >> to catch
> >> >> >> messages, warnings and errors.
> >> >> >
> >> >> > That's exactly what I'm using in "pander::evals" to capture all
> >> >> > error/warning/normal messages while evaluating an R command, and to
> >> >> > also capture the results (as R objects), stdout and the printed
> >> >> > version of the object -- which might be useful in a custom
> >> >> > environment. E.g. I use this function to evaluate all R chunks in
> >> >> > markdown document and also to store all R messages run at the
> >> >> > rapporter.net [2] API. Please let me know if anyone is interested, and
> >> >> > I will start cleaning up the related codebase and publish on GH --
> >> >> > although "pander" and "evals" is already
> >> >> > there: https://github.com/Rapporter/pander [3]
> >> >> >
> >> >> > Quick demo: http://pastebin.com/jCUkgKim [4]
> >> >> >
> >> >> >
> >> >> >> I don't know if there's a way to evaluate every expression entered
> >> >> >> at
> >> >> >> the console within withCallingHandlers() for an effect like
> >> >> >> options(error=), but you can certainly write code to read a file
> >> >> >> and
> >> >> >> evaluate every expression in it within a withCallingHandlers()
> >> >> >> call.
> >> >> >>
> >> >> >> Duncan Murdoch
> >> >> >>
> >> >> >>> Hope is clear. Open to any suggestions.
> >> >> >>>
> >> >> >>> Thank you in advance
> >> >> >>>
> >> >> >>
> >> >> >> ______________________________________________
> >> >> >> [hidden email] mailing list
> >> >> >> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
> >> >> >
> >> >> >
> >> >> >
> >> >> > Links:
> >> >> > ------
> >> >> > [1] https://stat.ethz.ch/mailman/listinfo/r-devel
> >> >> > [2] http://rapporter.net
> >> >> > [3] https://github.com/Rapporter/pander
> >> >> > [4] http://pastebin.com/jCUkgKim
> >> >>
> >>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

William Dunlap
In reply to this post by DataK - B. THIEURMEL
R has support for options(warning.expression=...), but it acts
differently than the options(error=...).

S (and S+) let the user override the default '.Program' expression.
Its default value was essentially
   print(.Last.value <- eval(parse(file=stdin())))
but a replacement could add stuff like print the time it took to do
the evaluation, put errors and warnings
into a log file, or even read input expressions from an alternate source.

R has some hook functions that let you do some of that, but I don't
know how much they let you do.



Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Tue, Oct 7, 2014 at 7:16 AM, DataK - B. THIEURMEL <[hidden email]> wrote:

> Thank. withCallingHandlers() and "pander::evals" seem to be very
> interesting, but little adapted to the analysis of one or several scripts R
> / of many lines of code. Our goal is one packages requiring no modifications
> of code R to be able to get back all the desired information.
>
> Is-there a hope in seeing R core team adding two options warn and message
> with the same features as options(error) ? Or if we try (and succeed) to
> code a patch for it, to see it integrating in R ?
>
> I think that it would be very useful.
>
> Benoit
>
> Le 2014-10-07 14:38, Gergely Daróczi a écrit :
>>
>> On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
>> <[hidden email]> wrote:
>>
>>> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>>>>
>>>> Hi,
>>>>
>>>> With the use of R in production, it is necessary to have a system
>>>
>>> of
>>>>
>>>> logs effective, and light.
>>>>
>>>> Package exist as to futile.logger, but it require the additional
>>>
>>> coding
>>>>
>>>> of logs. So it is thus impossible / very difficult to use it with
>>>
>>> all
>>>>
>>>> package them used in the calculation
>>>>
>>>> Our idea is to develop one packages global, simple, who would
>>>
>>> allow to
>>>>
>>>> identify all the errors, warning, message generated by the
>>>
>>> functions
>>>>
>>>> stop(), warning() and message() stop as well as by signals and
>>>> internally code, with log levels configurable later by package,
>>>> functions...
>>>>
>>>> One way is to overwrite temporarily the functions stop(),
>>>
>>> warning() and
>>>>
>>>> message() of base package, but I think is not a good thing, and
>>>> furthermore, we lose all signals and internally "message"...
>>>>
>>>> A good use of options(error) seems to do the perfect job, but
>>>
>>> only for
>>>>
>>>> error...
>>>>
>>>> Our problem / question :
>>>> - At present, how it is possible to have the same features for
>>>
>>> messages
>>>>
>>>> and warnings? (like options(errors)) (I don't find...)
>>>> - Would new options be possible in a near future R ?
>>>> - Have there better / other possibilities to handle all the
>>>
>>> warnings,
>>>>
>>>> message of the way which we wish?
>>>>
>>>
>>> withCallingHandlers() lets you evaluate expressions with code
>>> to catch
>>> messages, warnings and errors.
>>
>>
>> That's exactly what I'm using in "pander::evals" to capture all
>> error/warning/normal messages while evaluating an R command, and to
>> also capture the results (as R objects), stdout and the printed
>> version of the object -- which might be useful in a custom
>> environment. E.g. I use this function to evaluate all R chunks in
>> markdown document and also to store all R messages run at the
>> rapporter.net [2] API. Please let me know if anyone is interested, and
>> I will start cleaning up the related codebase and publish on GH --
>> although "pander" and "evals" is already
>> there: https://github.com/Rapporter/pander [3]
>>
>> Quick demo: http://pastebin.com/jCUkgKim [4]
>>
>>
>>> I don't know if there's a way to evaluate every expression entered
>>> at
>>> the console within withCallingHandlers() for an effect like
>>> options(error=), but you can certainly write code to read a file
>>> and
>>> evaluate every expression in it within a withCallingHandlers()
>>> call.
>>>
>>> Duncan Murdoch
>>>
>>>> Hope is clear. Open to any suggestions.
>>>>
>>>> Thank you in advance
>>>>
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
>>
>>
>>
>>
>> Links:
>> ------
>> [1] https://stat.ethz.ch/mailman/listinfo/r-devel
>> [2] http://rapporter.net
>> [3] https://github.com/Rapporter/pander
>> [4] http://pastebin.com/jCUkgKim
>
>
> --
> Benoit Thieurmel
> +33 6 69 04 06 11
>
> DataKnowledge
> 46 rue Amsterdam - 75009 Paris
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

Thomas J. Leeper
In reply to this post by DataK - B. THIEURMEL
Maybe this isn't what you're going for, but to implement the
"ritesink" widget in my package rite (which is a colored tcltk widget
to display output, messages, warnings, and errors), I use a
combination of `sink`, `addTaskCallback`, and a modification of
`options("error")`. In short, the task callback is executed after
every top-level evaluation. The function in that callback reads
contents from `sink`ed output and message streams and, if anything new
has been added to either, it writes those contents to the widget. The
custom error handler similarly writes to the widget instead of the
console. Following this design, instead of writing to the widget, you
could write all of that to some kind of formatted log file.

The package is on CRAN and you can take quick look at the source code
on GitHub: https://github.com/leeper/rite/blob/master/R/ritesink.r

Thomas J. Leeper
http://www.thomasleeper.com


On Wed, Oct 8, 2014 at 12:00 PM,  <[hidden email]> wrote:

> Message: 2
> Date: Tue, 07 Oct 2014 13:04:34 +0200
> From: "DataK - B. THIEURMEL" <[hidden email]>
> To: [hidden email]
> Subject: [Rd] [R logs] Help in develop a simply logs package
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Hi,
>
> With the use of R in production, it is necessary to have a system of
> logs effective, and light.
>
> Package exist as to futile.logger, but it require the additional coding
> of logs. So it is thus impossible / very difficult to use it with all
> package them used in the calculation
>
> Our idea is to develop one packages global, simple, who would allow to
> identify all the errors, warning, message generated by the functions
> stop(), warning() and message() stop as well as by signals and
> internally code, with log levels configurable later by package,
> functions...
>
> One way is to overwrite temporarily the functions stop(), warning() and
> message() of base package, but I think is not a good thing, and
> furthermore, we lose all signals and internally "message"...
>
> A good use of options(error) seems to do the perfect job, but only for
> error...
>
> Our problem / question :
> - At present, how it is possible to have the same features for messages
> and warnings? (like options(errors)) (I don't find...)
> - Would new options be possible in a near future R ?
> - Have there better / other possibilities to handle all the warnings,
> message of the way which we wish?
>
> Hope is clear. Open to any suggestions.
>
> Thank you in advance
>
> --
> Benoit Thieurmel
> +33 6 69 04 06 11
>
> DataKnowledge
> 46 rue Amsterdam - 75009 Paris
>
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 07 Oct 2014 08:21:36 -0400
> From: Duncan Murdoch <[hidden email]>
> To: "DataK - B. THIEURMEL" <[hidden email]>, [hidden email]
> Subject: Re: [Rd] [R logs] Help in develop a simply logs package
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>> Hi,
>>
>> With the use of R in production, it is necessary to have a system of
>> logs effective, and light.
>>
>> Package exist as to futile.logger, but it require the additional coding
>> of logs. So it is thus impossible / very difficult to use it with all
>> package them used in the calculation
>>
>> Our idea is to develop one packages global, simple, who would allow to
>> identify all the errors, warning, message generated by the functions
>> stop(), warning() and message() stop as well as by signals and
>> internally code, with log levels configurable later by package,
>> functions...
>>
>> One way is to overwrite temporarily the functions stop(), warning() and
>> message() of base package, but I think is not a good thing, and
>> furthermore, we lose all signals and internally "message"...
>>
>> A good use of options(error) seems to do the perfect job, but only for
>> error...
>>
>> Our problem / question :
>> - At present, how it is possible to have the same features for messages
>> and warnings? (like options(errors)) (I don't find...)
>> - Would new options be possible in a near future R ?
>> - Have there better / other possibilities to handle all the warnings,
>> message of the way which we wish?
>>
>
> withCallingHandlers() lets you evaluate expressions with code to catch
> messages, warnings and errors.
>
> I don't know if there's a way to evaluate every expression entered at
> the console within withCallingHandlers() for an effect like
> options(error=), but you can certainly write code to read a file and
> evaluate every expression in it within a withCallingHandlers() call.
>
> Duncan Murdoch
>
>> Hope is clear. Open to any suggestions.
>>
>> Thank you in advance
>>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 07 Oct 2014 16:16:53 +0200
> From: "DataK - B. THIEURMEL" <[hidden email]>
> To: Gergely Dar?czi <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [Rd] [R logs] Help in develop a simply logs package
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Thank. withCallingHandlers() and "pander::evals" seem to be very
> interesting, but little adapted to the analysis of one or several
> scripts R / of many lines of code. Our goal is one packages requiring no
> modifications of code R to be able to get back all the desired
> information.
>
> Is-there a hope in seeing R core team adding two options warn and
> message with the same features as options(error) ? Or if we try (and
> succeed) to code a patch for it, to see it integrating in R ?
>
> I think that it would be very useful.
>
> Benoit
>
> Le 2014-10-07 14:38, Gergely Dar?czi a ?crit?:
>> On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
>> <[hidden email]> wrote:
>>
>>> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>>>> Hi,
>>>>
>>>> With the use of R in production, it is necessary to have a system
>>> of
>>>> logs effective, and light.
>>>>
>>>> Package exist as to futile.logger, but it require the additional
>>> coding
>>>> of logs. So it is thus impossible / very difficult to use it with
>>> all
>>>> package them used in the calculation
>>>>
>>>> Our idea is to develop one packages global, simple, who would
>>> allow to
>>>> identify all the errors, warning, message generated by the
>>> functions
>>>> stop(), warning() and message() stop as well as by signals and
>>>> internally code, with log levels configurable later by package,
>>>> functions...
>>>>
>>>> One way is to overwrite temporarily the functions stop(),
>>> warning() and
>>>> message() of base package, but I think is not a good thing, and
>>>> furthermore, we lose all signals and internally "message"...
>>>>
>>>> A good use of options(error) seems to do the perfect job, but
>>> only for
>>>> error...
>>>>
>>>> Our problem / question :
>>>> - At present, how it is possible to have the same features for
>>> messages
>>>> and warnings? (like options(errors)) (I don't find...)
>>>> - Would new options be possible in a near future R ?
>>>> - Have there better / other possibilities to handle all the
>>> warnings,
>>>> message of the way which we wish?
>>>>
>>>
>>> ??withCallingHandlers() lets you evaluate expressions with code
>>> to catch
>>> messages, warnings and errors.
>>
>> That's exactly what I'm using in "pander::evals" to capture all
>> error/warning/normal messages while evaluating an R command, and to
>> also capture the results (as R objects), stdout and the printed
>> version of the object -- which might be useful in a custom
>> environment. E.g. I use this function to evaluate all R chunks in
>> markdown document and also to store all R messages run at the
>> rapporter.net [2] API. Please let me know if anyone is interested, and
>> I will start cleaning up the related codebase and publish on GH --
>> although "pander" and "evals" is already
>> there:?https://github.com/Rapporter/pander [3]
>>
>> Quick demo:?http://pastebin.com/jCUkgKim [4]
>> ?
>>
>>> I don't know if there's a way to evaluate every expression entered
>>> at
>>> the console within withCallingHandlers() for an effect like
>>> options(error=), but you can certainly write code to read a file
>>> and
>>> evaluate every expression in it within a withCallingHandlers()
>>> call.
>>>
>>> Duncan Murdoch
>>>
>>>> Hope is clear. Open to any suggestions.
>>>>
>>>> Thank you in advance
>>>>
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
>>
>>
>>
>> Links:
>> ------
>> [1] https://stat.ethz.ch/mailman/listinfo/r-devel
>> [2] http://rapporter.net
>> [3] https://github.com/Rapporter/pander
>> [4] http://pastebin.com/jCUkgKim
>
> --
> Benoit Thieurmel
> +33 6 69 04 06 11
>
> DataKnowledge
> 46 rue Amsterdam - 75009 Paris
>
>
>
> ------------------------------
>
> Message: 5
> Date: Tue, 7 Oct 2014 14:38:50 +0200
> From: Gergely Dar?czi <[hidden email]>
> To: Duncan Murdoch <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [Rd] [R logs] Help in develop a simply logs package
> Message-ID:
>         <CAPvvxJV=[hidden email]>
> Content-Type: text/plain; charset="UTF-8"
>
> On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch <[hidden email]>
> wrote:
>
>> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>> > Hi,
>> >
>> > With the use of R in production, it is necessary to have a system of
>> > logs effective, and light.
>> >
>> > Package exist as to futile.logger, but it require the additional coding
>> > of logs. So it is thus impossible / very difficult to use it with all
>> > package them used in the calculation
>> >
>> > Our idea is to develop one packages global, simple, who would allow to
>> > identify all the errors, warning, message generated by the functions
>> > stop(), warning() and message() stop as well as by signals and
>> > internally code, with log levels configurable later by package,
>> > functions...
>> >
>> > One way is to overwrite temporarily the functions stop(), warning() and
>> > message() of base package, but I think is not a good thing, and
>> > furthermore, we lose all signals and internally "message"...
>> >
>> > A good use of options(error) seems to do the perfect job, but only for
>> > error...
>> >
>> > Our problem / question :
>> > - At present, how it is possible to have the same features for messages
>> > and warnings? (like options(errors)) (I don't find...)
>> > - Would new options be possible in a near future R ?
>> > - Have there better / other possibilities to handle all the warnings,
>> > message of the way which we wish?
>> >
>>
>> ??
>> withCallingHandlers() lets you evaluate expressions with code to catch
>> messages, warnings and errors.
>>
>
> That's exactly what I'm using in "pander::evals" to capture all
> error/warning/normal messages while evaluating an R command, and to also
> capture the results (as R objects), stdout and the printed version of the
> object -- which might be useful in a custom environment. E.g. I use this
> function to evaluate all R chunks in markdown document and also to store
> all R messages run at the rapporter.net API. Please let me know if anyone
> is interested, and I will start cleaning up the related codebase and
> publish on GH -- although "pander" and "evals" is already there:
> https://github.com/Rapporter/pander
>
> Quick demo: http://pastebin.com/jCUkgKim
>
>
>>
>> I don't know if there's a way to evaluate every expression entered at
>> the console within withCallingHandlers() for an effect like
>> options(error=), but you can certainly write code to read a file and
>> evaluate every expression in it within a withCallingHandlers() call.
>>
>> Duncan Murdoch
>>
>> > Hope is clear. Open to any suggestions.
>> >
>> > Thank you in advance
>> >
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>         [[alternative HTML version deleted]]
>
>
>
> ------------------------------
>
> Message: 6
> Date: Tue, 07 Oct 2014 10:29:48 -0400
> From: Duncan Murdoch <[hidden email]>
> To: "DataK - B. THIEURMEL" <[hidden email]>, Gergely Dar?czi
>         <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [Rd] [R logs] Help in develop a simply logs package
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> On 07/10/2014 10:16 AM, DataK - B. THIEURMEL wrote:
>> Thank. withCallingHandlers() and "pander::evals" seem to be very
>> interesting, but little adapted to the analysis of one or several
>> scripts R / of many lines of code. Our goal is one packages requiring no
>> modifications of code R to be able to get back all the desired
>> information.
>>
>> Is-there a hope in seeing R core team adding two options warn and
>> message with the same features as options(error) ? Or if we try (and
>> succeed) to code a patch for it, to see it integrating in R ?
>
> No, I don't think so.  withCallingHandlers is all you need for your purpose.
>
> Duncan Murdoch
>
>>
>> I think that it would be very useful.
>>
>> Benoit
>>
>> Le 2014-10-07 14:38, Gergely Dar?czi a ?crit :
>> > On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
>> > <[hidden email]> wrote:
>> >
>> >> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>> >>> Hi,
>> >>>
>> >>> With the use of R in production, it is necessary to have a system
>> >> of
>> >>> logs effective, and light.
>> >>>
>> >>> Package exist as to futile.logger, but it require the additional
>> >> coding
>> >>> of logs. So it is thus impossible / very difficult to use it with
>> >> all
>> >>> package them used in the calculation
>> >>>
>> >>> Our idea is to develop one packages global, simple, who would
>> >> allow to
>> >>> identify all the errors, warning, message generated by the
>> >> functions
>> >>> stop(), warning() and message() stop as well as by signals and
>> >>> internally code, with log levels configurable later by package,
>> >>> functions...
>> >>>
>> >>> One way is to overwrite temporarily the functions stop(),
>> >> warning() and
>> >>> message() of base package, but I think is not a good thing, and
>> >>> furthermore, we lose all signals and internally "message"...
>> >>>
>> >>> A good use of options(error) seems to do the perfect job, but
>> >> only for
>> >>> error...
>> >>>
>> >>> Our problem / question :
>> >>> - At present, how it is possible to have the same features for
>> >> messages
>> >>> and warnings? (like options(errors)) (I don't find...)
>> >>> - Would new options be possible in a near future R ?
>> >>> - Have there better / other possibilities to handle all the
>> >> warnings,
>> >>> message of the way which we wish?
>> >>>
>> >>
>> >> ??withCallingHandlers() lets you evaluate expressions with code
>> >> to catch
>> >> messages, warnings and errors.
>> >
>> > That's exactly what I'm using in "pander::evals" to capture all
>> > error/warning/normal messages while evaluating an R command, and to
>> > also capture the results (as R objects), stdout and the printed
>> > version of the object -- which might be useful in a custom
>> > environment. E.g. I use this function to evaluate all R chunks in
>> > markdown document and also to store all R messages run at the
>> > rapporter.net [2] API. Please let me know if anyone is interested, and
>> > I will start cleaning up the related codebase and publish on GH --
>> > although "pander" and "evals" is already
>> > there: https://github.com/Rapporter/pander [3]
>> >
>> > Quick demo: http://pastebin.com/jCUkgKim [4]
>> >
>> >
>> >> I don't know if there's a way to evaluate every expression entered
>> >> at
>> >> the console within withCallingHandlers() for an effect like
>> >> options(error=), but you can certainly write code to read a file
>> >> and
>> >> evaluate every expression in it within a withCallingHandlers()
>> >> call.
>> >>
>> >> Duncan Murdoch
>> >>
>> >>> Hope is clear. Open to any suggestions.
>> >>>
>> >>> Thank you in advance
>> >>>
>> >>
>> >> ______________________________________________
>> >> [hidden email] mailing list
>> >> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
>> >
>> >
>> >
>> > Links:
>> > ------
>> > [1] https://stat.ethz.ch/mailman/listinfo/r-devel
>> > [2] http://rapporter.net
>> > [3] https://github.com/Rapporter/pander
>> > [4] http://pastebin.com/jCUkgKim
>>
>
>
>
> ------------------------------
>
> Message: 7
> Date: Tue, 07 Oct 2014 16:41:05 +0200
> From: "DataK - B. THIEURMEL" <[hidden email]>
> To: Duncan Murdoch <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [Rd] [R logs] Help in develop a simply logs package
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> OK, thank you for your answers. We are thus going to continue by
> analyzing these features
>
> Le 2014-10-07 16:29, Duncan Murdoch a ?crit?:
>> On 07/10/2014 10:16 AM, DataK - B. THIEURMEL wrote:
>>> Thank. withCallingHandlers() and "pander::evals" seem to be very
>>> interesting, but little adapted to the analysis of one or several
>>> scripts R / of many lines of code. Our goal is one packages requiring
>>> no
>>> modifications of code R to be able to get back all the desired
>>> information.
>>>
>>> Is-there a hope in seeing R core team adding two options warn and
>>> message with the same features as options(error) ? Or if we try (and
>>> succeed) to code a patch for it, to see it integrating in R ?
>>
>> No, I don't think so.  withCallingHandlers is all you need for your
>> purpose.
>>
>> Duncan Murdoch
>>
>>>
>>> I think that it would be very useful.
>>>
>>> Benoit
>>>
>>> Le 2014-10-07 14:38, Gergely Dar?czi a ?crit :
>>> > On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
>>> > <[hidden email]> wrote:
>>> >
>>> >> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>>> >>> Hi,
>>> >>>
>>> >>> With the use of R in production, it is necessary to have a system
>>> >> of
>>> >>> logs effective, and light.
>>> >>>
>>> >>> Package exist as to futile.logger, but it require the additional
>>> >> coding
>>> >>> of logs. So it is thus impossible / very difficult to use it with
>>> >> all
>>> >>> package them used in the calculation
>>> >>>
>>> >>> Our idea is to develop one packages global, simple, who would
>>> >> allow to
>>> >>> identify all the errors, warning, message generated by the
>>> >> functions
>>> >>> stop(), warning() and message() stop as well as by signals and
>>> >>> internally code, with log levels configurable later by package,
>>> >>> functions...
>>> >>>
>>> >>> One way is to overwrite temporarily the functions stop(),
>>> >> warning() and
>>> >>> message() of base package, but I think is not a good thing, and
>>> >>> furthermore, we lose all signals and internally "message"...
>>> >>>
>>> >>> A good use of options(error) seems to do the perfect job, but
>>> >> only for
>>> >>> error...
>>> >>>
>>> >>> Our problem / question :
>>> >>> - At present, how it is possible to have the same features for
>>> >> messages
>>> >>> and warnings? (like options(errors)) (I don't find...)
>>> >>> - Would new options be possible in a near future R ?
>>> >>> - Have there better / other possibilities to handle all the
>>> >> warnings,
>>> >>> message of the way which we wish?
>>> >>>
>>> >>
>>> >> ??withCallingHandlers() lets you evaluate expressions with code
>>> >> to catch
>>> >> messages, warnings and errors.
>>> >
>>> > That's exactly what I'm using in "pander::evals" to capture all
>>> > error/warning/normal messages while evaluating an R command, and to
>>> > also capture the results (as R objects), stdout and the printed
>>> > version of the object -- which might be useful in a custom
>>> > environment. E.g. I use this function to evaluate all R chunks in
>>> > markdown document and also to store all R messages run at the
>>> > rapporter.net [2] API. Please let me know if anyone is interested, and
>>> > I will start cleaning up the related codebase and publish on GH --
>>> > although "pander" and "evals" is already
>>> > there: https://github.com/Rapporter/pander [3]
>>> >
>>> > Quick demo: http://pastebin.com/jCUkgKim [4]
>>> >
>>> >
>>> >> I don't know if there's a way to evaluate every expression entered
>>> >> at
>>> >> the console within withCallingHandlers() for an effect like
>>> >> options(error=), but you can certainly write code to read a file
>>> >> and
>>> >> evaluate every expression in it within a withCallingHandlers()
>>> >> call.
>>> >>
>>> >> Duncan Murdoch
>>> >>
>>> >>> Hope is clear. Open to any suggestions.
>>> >>>
>>> >>> Thank you in advance
>>> >>>
>>> >>
>>> >> ______________________________________________
>>> >> [hidden email] mailing list
>>> >> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
>>> >
>>> >
>>> >
>>> > Links:
>>> > ------
>>> > [1] https://stat.ethz.ch/mailman/listinfo/r-devel
>>> > [2] http://rapporter.net
>>> > [3] https://github.com/Rapporter/pander
>>> > [4] http://pastebin.com/jCUkgKim
>>>
>
> --
> Benoit Thieurmel
> +33 6 69 04 06 11
>
> DataKnowledge
> 46 rue Amsterdam - 75009 Paris
>
>
>
> ------------------------------
>
> Message: 8
> Date: Tue, 07 Oct 2014 10:51:44 -0400
> From: Duncan Murdoch <[hidden email]>
> To: "DataK - B. THIEURMEL" <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [Rd] [R logs] Help in develop a simply logs package
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> On 07/10/2014 10:41 AM, DataK - B. THIEURMEL wrote:
>> OK, thank you for your answers. We are thus going to continue by
>> analyzing these features
>
> The general outline would be this:
>
> 1.  Call parse() on the whole file.  This will catch any syntax errors.
> If it parses okay, you'll get a vector of expressions to evaluate.
>
> 2.  Evaluate each expression in sequence within withCallingHandlers().
> You need to decide what to do if you get an error(); source() would quit
> the script at that point, so that's probably a good idea.
>
> Duncan Murdoch
>>
>> Le 2014-10-07 16:29, Duncan Murdoch a ?crit :
>> > On 07/10/2014 10:16 AM, DataK - B. THIEURMEL wrote:
>> >> Thank. withCallingHandlers() and "pander::evals" seem to be very
>> >> interesting, but little adapted to the analysis of one or several
>> >> scripts R / of many lines of code. Our goal is one packages requiring
>> >> no
>> >> modifications of code R to be able to get back all the desired
>> >> information.
>> >>
>> >> Is-there a hope in seeing R core team adding two options warn and
>> >> message with the same features as options(error) ? Or if we try (and
>> >> succeed) to code a patch for it, to see it integrating in R ?
>> >
>> > No, I don't think so.  withCallingHandlers is all you need for your
>> > purpose.
>> >
>> > Duncan Murdoch
>> >
>> >>
>> >> I think that it would be very useful.
>> >>
>> >> Benoit
>> >>
>> >> Le 2014-10-07 14:38, Gergely Dar?czi a ?crit :
>> >> > On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
>> >> > <[hidden email]> wrote:
>> >> >
>> >> >> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>> >> >>> Hi,
>> >> >>>
>> >> >>> With the use of R in production, it is necessary to have a system
>> >> >> of
>> >> >>> logs effective, and light.
>> >> >>>
>> >> >>> Package exist as to futile.logger, but it require the additional
>> >> >> coding
>> >> >>> of logs. So it is thus impossible / very difficult to use it with
>> >> >> all
>> >> >>> package them used in the calculation
>> >> >>>
>> >> >>> Our idea is to develop one packages global, simple, who would
>> >> >> allow to
>> >> >>> identify all the errors, warning, message generated by the
>> >> >> functions
>> >> >>> stop(), warning() and message() stop as well as by signals and
>> >> >>> internally code, with log levels configurable later by package,
>> >> >>> functions...
>> >> >>>
>> >> >>> One way is to overwrite temporarily the functions stop(),
>> >> >> warning() and
>> >> >>> message() of base package, but I think is not a good thing, and
>> >> >>> furthermore, we lose all signals and internally "message"...
>> >> >>>
>> >> >>> A good use of options(error) seems to do the perfect job, but
>> >> >> only for
>> >> >>> error...
>> >> >>>
>> >> >>> Our problem / question :
>> >> >>> - At present, how it is possible to have the same features for
>> >> >> messages
>> >> >>> and warnings? (like options(errors)) (I don't find...)
>> >> >>> - Would new options be possible in a near future R ?
>> >> >>> - Have there better / other possibilities to handle all the
>> >> >> warnings,
>> >> >>> message of the way which we wish?
>> >> >>>
>> >> >>
>> >> >> ??withCallingHandlers() lets you evaluate expressions with code
>> >> >> to catch
>> >> >> messages, warnings and errors.
>> >> >
>> >> > That's exactly what I'm using in "pander::evals" to capture all
>> >> > error/warning/normal messages while evaluating an R command, and to
>> >> > also capture the results (as R objects), stdout and the printed
>> >> > version of the object -- which might be useful in a custom
>> >> > environment. E.g. I use this function to evaluate all R chunks in
>> >> > markdown document and also to store all R messages run at the
>> >> > rapporter.net [2] API. Please let me know if anyone is interested, and
>> >> > I will start cleaning up the related codebase and publish on GH --
>> >> > although "pander" and "evals" is already
>> >> > there: https://github.com/Rapporter/pander [3]
>> >> >
>> >> > Quick demo: http://pastebin.com/jCUkgKim [4]
>> >> >
>> >> >
>> >> >> I don't know if there's a way to evaluate every expression entered
>> >> >> at
>> >> >> the console within withCallingHandlers() for an effect like
>> >> >> options(error=), but you can certainly write code to read a file
>> >> >> and
>> >> >> evaluate every expression in it within a withCallingHandlers()
>> >> >> call.
>> >> >>
>> >> >> Duncan Murdoch
>> >> >>
>> >> >>> Hope is clear. Open to any suggestions.
>> >> >>>
>> >> >>> Thank you in advance
>> >> >>>
>> >> >>
>> >> >> ______________________________________________
>> >> >> [hidden email] mailing list
>> >> >> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
>> >> >
>> >> >
>> >> >
>> >> > Links:
>> >> > ------
>> >> > [1] https://stat.ethz.ch/mailman/listinfo/r-devel
>> >> > [2] http://rapporter.net
>> >> > [3] https://github.com/Rapporter/pander
>> >> > [4] http://pastebin.com/jCUkgKim
>> >>
>>
>
>
>
> ------------------------------
>
> Message: 9
> Date: Tue, 07 Oct 2014 17:11:08 +0200
> From: "DataK - B. THIEURMEL" <[hidden email]>
> To: Duncan Murdoch <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [Rd] [R logs] Help in develop a simply logs package
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Do you think there is a way to apply a "global" withCallingHandlers() on
> all environement / packages loaded, and then all R code will be executed
> with the defined handler ? With this way, we can define what we want for
> warning, message, error, ... one time, and apply it without needed of
> parse() or added withCallingHandlers in initial code...
>
> Something like this :
>
> withCallingHandlersGlobal <- function(...) {
>    handlers <- list(...)
>    classes <- names(handlers)
>    parentenv <- all.environment
>    if (length(classes) != length(handlers))
>      stop("bad handler specification")
>    .Internal(.addCondHands(classes, handlers, parentenv, NULL, TRUE))
> }
>
> withCallingHandlersGlobal(warning = function(w) {print("Global
> handler")})
>
> warning("A")
>> "Global handler"
> rnorm("A")
>> "Global handler"
>
>
>
> Le 2014-10-07 16:51, Duncan Murdoch a ?crit?:
>> On 07/10/2014 10:41 AM, DataK - B. THIEURMEL wrote:
>>> OK, thank you for your answers. We are thus going to continue by
>>> analyzing these features
>>
>> The general outline would be this:
>>
>> 1.  Call parse() on the whole file.  This will catch any syntax
>> errors.  If it parses okay, you'll get a vector of expressions to
>> evaluate.
>>
>> 2.  Evaluate each expression in sequence within withCallingHandlers().
>>  You need to decide what to do if you get an error(); source() would
>> quit the script at that point, so that's probably a good idea.
>>
>> Duncan Murdoch
>>>
>>> Le 2014-10-07 16:29, Duncan Murdoch a ?crit :
>>> > On 07/10/2014 10:16 AM, DataK - B. THIEURMEL wrote:
>>> >> Thank. withCallingHandlers() and "pander::evals" seem to be very
>>> >> interesting, but little adapted to the analysis of one or several
>>> >> scripts R / of many lines of code. Our goal is one packages requiring
>>> >> no
>>> >> modifications of code R to be able to get back all the desired
>>> >> information.
>>> >>
>>> >> Is-there a hope in seeing R core team adding two options warn and
>>> >> message with the same features as options(error) ? Or if we try (and
>>> >> succeed) to code a patch for it, to see it integrating in R ?
>>> >
>>> > No, I don't think so.  withCallingHandlers is all you need for your
>>> > purpose.
>>> >
>>> > Duncan Murdoch
>>> >
>>> >>
>>> >> I think that it would be very useful.
>>> >>
>>> >> Benoit
>>> >>
>>> >> Le 2014-10-07 14:38, Gergely Dar?czi a ?crit :
>>> >> > On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
>>> >> > <[hidden email]> wrote:
>>> >> >
>>> >> >> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>>> >> >>> Hi,
>>> >> >>>
>>> >> >>> With the use of R in production, it is necessary to have a system
>>> >> >> of
>>> >> >>> logs effective, and light.
>>> >> >>>
>>> >> >>> Package exist as to futile.logger, but it require the additional
>>> >> >> coding
>>> >> >>> of logs. So it is thus impossible / very difficult to use it with
>>> >> >> all
>>> >> >>> package them used in the calculation
>>> >> >>>
>>> >> >>> Our idea is to develop one packages global, simple, who would
>>> >> >> allow to
>>> >> >>> identify all the errors, warning, message generated by the
>>> >> >> functions
>>> >> >>> stop(), warning() and message() stop as well as by signals and
>>> >> >>> internally code, with log levels configurable later by package,
>>> >> >>> functions...
>>> >> >>>
>>> >> >>> One way is to overwrite temporarily the functions stop(),
>>> >> >> warning() and
>>> >> >>> message() of base package, but I think is not a good thing, and
>>> >> >>> furthermore, we lose all signals and internally "message"...
>>> >> >>>
>>> >> >>> A good use of options(error) seems to do the perfect job, but
>>> >> >> only for
>>> >> >>> error...
>>> >> >>>
>>> >> >>> Our problem / question :
>>> >> >>> - At present, how it is possible to have the same features for
>>> >> >> messages
>>> >> >>> and warnings? (like options(errors)) (I don't find...)
>>> >> >>> - Would new options be possible in a near future R ?
>>> >> >>> - Have there better / other possibilities to handle all the
>>> >> >> warnings,
>>> >> >>> message of the way which we wish?
>>> >> >>>
>>> >> >>
>>> >> >> ??withCallingHandlers() lets you evaluate expressions with code
>>> >> >> to catch
>>> >> >> messages, warnings and errors.
>>> >> >
>>> >> > That's exactly what I'm using in "pander::evals" to capture all
>>> >> > error/warning/normal messages while evaluating an R command, and to
>>> >> > also capture the results (as R objects), stdout and the printed
>>> >> > version of the object -- which might be useful in a custom
>>> >> > environment. E.g. I use this function to evaluate all R chunks in
>>> >> > markdown document and also to store all R messages run at the
>>> >> > rapporter.net [2] API. Please let me know if anyone is interested, and
>>> >> > I will start cleaning up the related codebase and publish on GH --
>>> >> > although "pander" and "evals" is already
>>> >> > there: https://github.com/Rapporter/pander [3]
>>> >> >
>>> >> > Quick demo: http://pastebin.com/jCUkgKim [4]
>>> >> >
>>> >> >
>>> >> >> I don't know if there's a way to evaluate every expression entered
>>> >> >> at
>>> >> >> the console within withCallingHandlers() for an effect like
>>> >> >> options(error=), but you can certainly write code to read a file
>>> >> >> and
>>> >> >> evaluate every expression in it within a withCallingHandlers()
>>> >> >> call.
>>> >> >>
>>> >> >> Duncan Murdoch
>>> >> >>
>>> >> >>> Hope is clear. Open to any suggestions.
>>> >> >>>
>>> >> >>> Thank you in advance
>>> >> >>>
>>> >> >>
>>> >> >> ______________________________________________
>>> >> >> [hidden email] mailing list
>>> >> >> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
>>> >> >
>>> >> >
>>> >> >
>>> >> > Links:
>>> >> > ------
>>> >> > [1] https://stat.ethz.ch/mailman/listinfo/r-devel
>>> >> > [2] http://rapporter.net
>>> >> > [3] https://github.com/Rapporter/pander
>>> >> > [4] http://pastebin.com/jCUkgKim
>>> >>
>>>
>
> --
> Benoit Thieurmel
> +33 6 69 04 06 11
>
> DataKnowledge
> 46 rue Amsterdam - 75009 Paris
>
>
>
> ------------------------------
>
> Message: 10
> Date: Tue, 7 Oct 2014 18:05:03 +0200
> From: Gergely Dar?czi <[hidden email]>
> To: Duncan Murdoch <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [Rd] [R logs] Help in develop a simply logs package
> Message-ID:
>         <CAPvvxJX-cs7se4cicZ+BZyzPbAL02OmQq-z662e=[hidden email]>
> Content-Type: text/plain; charset="UTF-8"
>
> On Tue, Oct 7, 2014 at 4:51 PM, Duncan Murdoch <[hidden email]>
> wrote:
>
>> On 07/10/2014 10:41 AM, DataK - B. THIEURMEL wrote:
>>
>>> OK, thank you for your answers. We are thus going to continue by
>>> analyzing these features
>>>
>>
>> The general outline would be this:
>>
>> 1.  Call parse() on the whole file.  This will catch any syntax errors.
>> If it parses okay, you'll get a vector of expressions to evaluate.
>>
>> 2.  Evaluate each expression in sequence within withCallingHandlers().
>> You need to decide what to do if you get an error(); source() would quit
>> the script at that point, so that's probably a good idea.
>
>
> Quick demo with "pander::evals":
> https://gist.github.com/daroczig/480af8ad766e96dd25f4
>
>
>>
>>
>> Duncan Murdoch
>>
>>
>>> Le 2014-10-07 16:29, Duncan Murdoch a ?crit :
>>> > On 07/10/2014 10:16 AM, DataK - B. THIEURMEL wrote:
>>> >> Thank. withCallingHandlers() and "pander::evals" seem to be very
>>> >> interesting, but little adapted to the analysis of one or several
>>> >> scripts R / of many lines of code. Our goal is one packages requiring
>>> >> no
>>> >> modifications of code R to be able to get back all the desired
>>> >> information.
>>> >>
>>> >> Is-there a hope in seeing R core team adding two options warn and
>>> >> message with the same features as options(error) ? Or if we try (and
>>> >> succeed) to code a patch for it, to see it integrating in R ?
>>> >
>>> > No, I don't think so.  withCallingHandlers is all you need for your
>>> > purpose.
>>> >
>>> > Duncan Murdoch
>>> >
>>> >>
>>> >> I think that it would be very useful.
>>> >>
>>> >> Benoit
>>> >>
>>> >> Le 2014-10-07 14:38, Gergely Dar?czi a ?crit :
>>> >> > On Tue, Oct 7, 2014 at 2:21 PM, Duncan Murdoch
>>> >> > <[hidden email]> wrote:
>>> >> >
>>> >> >> On 07/10/2014, 7:04 AM, DataK - B. THIEURMEL wrote:
>>> >> >>> Hi,
>>> >> >>>
>>> >> >>> With the use of R in production, it is necessary to have a system
>>> >> >> of
>>> >> >>> logs effective, and light.
>>> >> >>>
>>> >> >>> Package exist as to futile.logger, but it require the additional
>>> >> >> coding
>>> >> >>> of logs. So it is thus impossible / very difficult to use it with
>>> >> >> all
>>> >> >>> package them used in the calculation
>>> >> >>>
>>> >> >>> Our idea is to develop one packages global, simple, who would
>>> >> >> allow to
>>> >> >>> identify all the errors, warning, message generated by the
>>> >> >> functions
>>> >> >>> stop(), warning() and message() stop as well as by signals and
>>> >> >>> internally code, with log levels configurable later by package,
>>> >> >>> functions...
>>> >> >>>
>>> >> >>> One way is to overwrite temporarily the functions stop(),
>>> >> >> warning() and
>>> >> >>> message() of base package, but I think is not a good thing, and
>>> >> >>> furthermore, we lose all signals and internally "message"...
>>> >> >>>
>>> >> >>> A good use of options(error) seems to do the perfect job, but
>>> >> >> only for
>>> >> >>> error...
>>> >> >>>
>>> >> >>> Our problem / question :
>>> >> >>> - At present, how it is possible to have the same features for
>>> >> >> messages
>>> >> >>> and warnings? (like options(errors)) (I don't find...)
>>> >> >>> - Would new options be possible in a near future R ?
>>> >> >>> - Have there better / other possibilities to handle all the
>>> >> >> warnings,
>>> >> >>> message of the way which we wish?
>>> >> >>>
>>> >> >>
>>> >> >> ??withCallingHandlers() lets you evaluate expressions with code
>>> >> >> to catch
>>> >> >> messages, warnings and errors.
>>> >> >
>>> >> > That's exactly what I'm using in "pander::evals" to capture all
>>> >> > error/warning/normal messages while evaluating an R command, and to
>>> >> > also capture the results (as R objects), stdout and the printed
>>> >> > version of the object -- which might be useful in a custom
>>> >> > environment. E.g. I use this function to evaluate all R chunks in
>>> >> > markdown document and also to store all R messages run at the
>>> >> > rapporter.net [2] API. Please let me know if anyone is interested,
>>> and
>>> >> > I will start cleaning up the related codebase and publish on GH --
>>> >> > although "pander" and "evals" is already
>>> >> > there: https://github.com/Rapporter/pander [3]
>>> >> >
>>> >> > Quick demo: http://pastebin.com/jCUkgKim [4]
>>> >> >
>>> >> >
>>> >> >> I don't know if there's a way to evaluate every expression entered
>>> >> >> at
>>> >> >> the console within withCallingHandlers() for an effect like
>>> >> >> options(error=), but you can certainly write code to read a file
>>> >> >> and
>>> >> >> evaluate every expression in it within a withCallingHandlers()
>>> >> >> call.
>>> >> >>
>>> >> >> Duncan Murdoch
>>> >> >>
>>> >> >>> Hope is clear. Open to any suggestions.
>>> >> >>>
>>> >> >>> Thank you in advance
>>> >> >>>
>>> >> >>
>>> >> >> ______________________________________________
>>> >> >> [hidden email] mailing list
>>> >> >> https://stat.ethz.ch/mailman/listinfo/r-devel [1]
>>> >> >
>>> >> >
>>> >> >
>>> >> > Links:
>>> >> > ------
>>> >> > [1] https://stat.ethz.ch/mailman/listinfo/r-devel
>>> >> > [2] http://rapporter.net
>>> >> > [3] https://github.com/Rapporter/pander
>>> >> > [4] http://pastebin.com/jCUkgKim
>>> >>
>>>
>>>
>>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R logs] Help in develop a simply logs package

Simon Urbanek
In reply to this post by DataK - B. THIEURMEL
On Oct 7, 2014, at 7:04 AM, DataK - B. THIEURMEL <[hidden email]> wrote:

>
> Hi,
>
> With the use of R in production, it is necessary to have a system of logs effective, and light.
>
> Package exist as to futile.logger, but it require the additional coding of logs. So it is thus impossible / very difficult to use it with all package them used in the calculation
>
> Our idea is to develop one packages global, simple, who would allow to identify all the errors, warning, message generated by the functions stop(), warning() and message() stop as well as by signals and internally code, with log levels configurable later by package, functions...
>
> One way is to overwrite temporarily the functions stop(), warning() and message() of base package, but I think is not a good thing, and furthermore, we lose all signals and internally "message"...
>
> A good use of options(error) seems to do the perfect job, but only for error...
>
> Our problem / question :
> - At present, how it is possible to have the same features for messages and warnings? (like options(errors)) (I don't find...)
> - Would new options be possible in a near future R ?
> - Have there better / other possibilities to handle all the warnings, message of the way which we wish?
>
> Hope is clear. Open to any suggestions.
>

It really depends on what you're after. If you really mean log as in recording errors/message that go to the console the you can use the console interface API to override WriteConsole and ShowMessage to tie the messages to another place in addition to printing it out. But what is feasible really depends on how you run R in the first place (and on which OS).

Cheers,
Simon


> Thank you in advance
>
> --
> Benoit Thieurmel
> +33 6 69 04 06 11
>
> DataKnowledge
> 46 rue Amsterdam - 75009 Paris
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel