From bt at datak.fr  Tue Oct  7 16:41:05 2014
From: bt at datak.fr (DataK - B. THIEURMEL)
Date: Tue, 07 Oct 2014 16:41:05 +0200
Subject: [Rd] [R logs] Help in develop a simply logs package
In-Reply-To: <5433F8DC.8040009@gmail.com>
References: <4726f6636a227512e8a3ec4ae1562e73@datak.fr>
	<5433DAD0.8080305@gmail.com>
	<CAPvvxJV=P4Hj3hL+cic2XN1CRtH5BrQROZHb8AHWY501Pq5FBw@mail.gmail.com>
	<50055615b4a67b88787ba18dc0c607b8@datak.fr>
	<5433F8DC.8040009@gmail.com>
Message-ID: <e630f94c1003f37cc1eb9a47ff8b5152@datak.fr>

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
>> > <murdoch.duncan at gmail.com> 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
>> >>>
>> >>
>> >> ______________________________________________
>> >> R-devel at r-project.org 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



[Rd] [R logs] Help in develop a simply logs package
DataK - B. THIEURMEL