[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Removing default logging handler (causes duplicate logging

Gal Aviel

3/4/2008 12:30:00 PM

Hello All,

I want to add a logger to my application, then addHandler to it to log to a
special destination.

Unfortunately when I use logging.getLogger("my_logger") to create the new
logger, it apparently comes with a default handler that logs to STDOUT (or
STDERR?). When I add my special handler it works Ok, but still logs to terminal,
which I do not want.

The only way I found to remove the default handler is by using
'logger.removeHandler(logger.handlers[0])'.

Is there a more elegant solution that uses the logging API?

my setup: Python 2.5.1 on Linux Suse 9.

P.S.I am not using Basic config, just 'import logging' and then regular
logging.* calls.

Thanks in advance,
Gal Aviel.

4 Answers

Gerard Flanagan

3/4/2008 3:36:00 PM

0

On Mar 4, 1:29 pm, Gal Aviel <galav...@yahoo.com> wrote:
> Hello All,
>
> I want to add a logger to my application, then addHandler to it to log to a
> special destination.
>
> Unfortunately when I use logging.getLogger("my_logger") to create the new
> logger, it apparently comes with a default handler that logs to STDOUT (or
> STDERR?). When I add my special handler it works Ok, but still logs to terminal,
> which I do not want.
>

from docs:
------------------
getLogger( [name])

Return a logger with the specified name or, if no name is specified,
return a logger which is the root logger of the hierarchy.
------------------

so you should do 'root = getlogger()', then append your own logger to
the root.

Gerard

pbart

3/24/2010 11:06:00 PM

0

Cel1.Precedents.Select

will activate a range which is the union of cells appearing in the formula
(Excel 2007).

If you have trace arrows showing on your sheet then NavigateArrow will allow
you to select a particular one to follow.



"Ron Rosenfeld" wrote:

> On Tue, 23 Mar 2010 22:10:08 -0700 (PDT), Jim Luedke <baobob@my-deja.com>
> wrote:
>
> >This is a simple and possibly embarrassing question.
> >
> >In Excel 2002 SP3, cell 1 is on ProfitSheet and depends on cell 2, on
> >a different sheet.
> >
> >Cell 1 has a UDF, so it looks like:
> >
> >"=MassageData(SalesSheet!$A$1)"
> >
> >Given that I know cell 1 at runtime, what VBA function returns cell 2?
> >
> >I have tried:
> >
> >Set Cel2 = Cel1.Precedents(1)
> >Set Cel2 = Cel1.Precedents.Cells(1, 1)
> >etc.
> >
> >but that only seems to return Cel1 itself (at least that's what the
> >Debug Window shows).
> >
> >1) Is my syntax wrong?
> >
> >2) Is Excel's lack of external dependent/precedent functionality in my
> >old version, the reason?
> >
> >3) If so, has that un-feature ever been fixed?
> >
> >I guess I could manually remove the UDF and do:
> >
> >Set Cel2 = Range(StripTheEqualSignAndUDFFrom(Cel1.Formula))
> >
> >or maybe this sickness (if I have the syntax right):
> >
> >Set Cel2 =
> >Application.WorksheetFunction.INDIRECT(StripDitto(Cel1.Formula))
> >
> >But what's the simple way that's staring me in the face?
> >
> >Thanks much.
> >
> >***
>
> For the address, perhaps:
>
> rg.Precedents.Worksheet.Name & "!" & rg.Precedents.Address
>
> --ron
> .
>

Rick Rothstein \(MVP - VB\)

3/24/2010 11:41:00 PM

0

As far as I know, that will only work for Precedent cells on the same
worksheet as the cell (Cel1 in this case)... Precedents will not work on
cells referencing other sheets. The only way I know to do that is how I
showed in my post... show the precedent arrows, then use NavigateArrow to
find the cell on the foreign sheet that you want and the turn the arrows
off. The code for this can get complicated if there are several cells on
other sheets, especially if there are multiple other sheets involved.

--
Rick (MVP - Excel)


"pbart" <pbart@discussions.microsoft.com> wrote in message
news:585812DF-6C7F-47D1-9343-777F2226D0AE@microsoft.com...
> Cel1.Precedents.Select
>
> will activate a range which is the union of cells appearing in the formula
> (Excel 2007).
>
> If you have trace arrows showing on your sheet then NavigateArrow will
> allow
> you to select a particular one to follow.
>
>
>
> "Ron Rosenfeld" wrote:
>
>> On Tue, 23 Mar 2010 22:10:08 -0700 (PDT), Jim Luedke <baobob@my-deja.com>
>> wrote:
>>
>> >This is a simple and possibly embarrassing question.
>> >
>> >In Excel 2002 SP3, cell 1 is on ProfitSheet and depends on cell 2, on
>> >a different sheet.
>> >
>> >Cell 1 has a UDF, so it looks like:
>> >
>> >"=MassageData(SalesSheet!$A$1)"
>> >
>> >Given that I know cell 1 at runtime, what VBA function returns cell 2?
>> >
>> >I have tried:
>> >
>> >Set Cel2 = Cel1.Precedents(1)
>> >Set Cel2 = Cel1.Precedents.Cells(1, 1)
>> >etc.
>> >
>> >but that only seems to return Cel1 itself (at least that's what the
>> >Debug Window shows).
>> >
>> >1) Is my syntax wrong?
>> >
>> >2) Is Excel's lack of external dependent/precedent functionality in my
>> >old version, the reason?
>> >
>> >3) If so, has that un-feature ever been fixed?
>> >
>> >I guess I could manually remove the UDF and do:
>> >
>> >Set Cel2 = Range(StripTheEqualSignAndUDFFrom(Cel1.Formula))
>> >
>> >or maybe this sickness (if I have the syntax right):
>> >
>> >Set Cel2 =
>> >Application.WorksheetFunction.INDIRECT(StripDitto(Cel1.Formula))
>> >
>> >But what's the simple way that's staring me in the face?
>> >
>> >Thanks much.
>> >
>> >***
>>
>> For the address, perhaps:
>>
>> rg.Precedents.Worksheet.Name & "!" & rg.Precedents.Address
>>
>> --ron
>> .
>>

pbart

3/25/2010 11:23:00 AM

0

Rick

You are right; my apologies!

A different strand of thinking could be to cheat and record the address of
predecessor cell (SalesSheet!$A$1) as a string on ProfitSheet at the time the
data is set up; the string could be used in the formula
"=MassageData(INDIRECT(Cel3)) much as one would a database 'foreign key'. I
would only suggest this as a potential solution if it fits well into the
spirit of the workbook in question.



"Rick Rothstein" wrote:

> As far as I know, that will only work for Precedent cells on the same
> worksheet as the cell (Cel1 in this case)... Precedents will not work on
> cells referencing other sheets. The only way I know to do that is how I
> showed in my post... show the precedent arrows, then use NavigateArrow to
> find the cell on the foreign sheet that you want and the turn the arrows
> off. The code for this can get complicated if there are several cells on
> other sheets, especially if there are multiple other sheets involved.
>
> --
> Rick (MVP - Excel)
>
>
> "pbart" <pbart@discussions.microsoft.com> wrote in message
> news:585812DF-6C7F-47D1-9343-777F2226D0AE@microsoft.com...
> > Cel1.Precedents.Select
> >
> > will activate a range which is the union of cells appearing in the formula
> > (Excel 2007).
> >
> > If you have trace arrows showing on your sheet then NavigateArrow will
> > allow
> > you to select a particular one to follow.
> >
> >
> >
> > "Ron Rosenfeld" wrote:
> >
> >> On Tue, 23 Mar 2010 22:10:08 -0700 (PDT), Jim Luedke <baobob@my-deja.com>
> >> wrote:
> >>
> >> >This is a simple and possibly embarrassing question.
> >> >
> >> >In Excel 2002 SP3, cell 1 is on ProfitSheet and depends on cell 2, on
> >> >a different sheet.
> >> >
> >> >Cell 1 has a UDF, so it looks like:
> >> >
> >> >"=MassageData(SalesSheet!$A$1)"
> >> >
> >> >Given that I know cell 1 at runtime, what VBA function returns cell 2?
> >> >
> >> >I have tried:
> >> >
> >> >Set Cel2 = Cel1.Precedents(1)
> >> >Set Cel2 = Cel1.Precedents.Cells(1, 1)
> >> >etc.
> >> >
> >> >but that only seems to return Cel1 itself (at least that's what the
> >> >Debug Window shows).
> >> >
> >> >1) Is my syntax wrong?
> >> >
> >> >2) Is Excel's lack of external dependent/precedent functionality in my
> >> >old version, the reason?
> >> >
> >> >3) If so, has that un-feature ever been fixed?
> >> >
> >> >I guess I could manually remove the UDF and do:
> >> >
> >> >Set Cel2 = Range(StripTheEqualSignAndUDFFrom(Cel1.Formula))
> >> >
> >> >or maybe this sickness (if I have the syntax right):
> >> >
> >> >Set Cel2 =
> >> >Application.WorksheetFunction.INDIRECT(StripDitto(Cel1.Formula))
> >> >
> >> >But what's the simple way that's staring me in the face?
> >> >
> >> >Thanks much.
> >> >
> >> >***
> >>
> >> For the address, perhaps:
> >>
> >> rg.Precedents.Worksheet.Name & "!" & rg.Precedents.Address
> >>
> >> --ron
> >> .
> >>
> .
>