Обсуждение: Is there a way to add a detail message in a warning with pl/Python?
Hello,
I build a function and added some warnings where the id of the affected
rows are inside it; and would be nice to put it into a detail, not in
the message, since pgbadger can group it and I can see clearly what is
wrong in my cluster.
I read the manual and tried something with no success:
plpy.warning('test', 'detail') -> output both values
plpy.warning({'message': 'test', 'detail': 'detail'}) -> output the dict
plpy.warning('test', detail='detail') -> fail
Am I missing something?
I would read the code, but I had no time right now...
Thanks,
--
Daniel Cristian Cruz
Unidade de Tecnologia da Informação
Sistema FIESC
Rod. Admar Gonzaga, 2765 - Itacorubi - 88034-001 - Florianópolis - SC
Fone (48) 3239-1422 - e-mail: daniel.cruz@sc.senai.br
site: http://www.sistemafiesc.org.br
Вложения
On 01/29/2013 05:03 AM, DANIEL CRISTIAN CRUZ wrote:
> Hello,
>
> I build a function and added some warnings where the id of the affected
> rows are inside it; and would be nice to put it into a detail, not in
> the message, since pgbadger can group it and I can see clearly what is
> wrong in my cluster.
>
> I read the manual and tried something with no success:
>
> plpy.warning('test', 'detail') -> output both values
> plpy.warning({'message': 'test', 'detail': 'detail'}) -> output the dict
> plpy.warning('test', detail='detail') -> fail
>
> Am I missing something?
Why not:
DO $$
plpy.warning('test, detail')
$$ LANGUAGE plpythonu;
In log:
WARNING: test, detail
>
> I would read the code, but I had no time right now...
>
> Thanks,
>
--
Adrian Klaver
adrian.klaver@gmail.com
On 01/30/2013 02:49 AM, DANIEL CRISTIAN CRUZ wrote:
>
>
> Em 29/01/2013 17:30, Adrian Klaver escreveu:
>> Why not:
>>
>> DO $$
>> plpy.warning('test, detail')
>> $$ LANGUAGE plpythonu;
>>
>> In log:
>>
>> WARNING: test, detail
>>
>
> Because pgBadger doesn't use it this way:
>
> http://dalibo.github.com/pgbadger/example.html#NormalizedErrorsMostFrequentReport
I am not sure how you can determine that from the above. Looks like
pgBadger is searching the detail string and applying a mask when
appropriate i.e ERROR: relation "..." does not exist.
When you use plpy.warning it is going to output WARNING:"Your string".
If you are consistent in your naming of warnings I see no reason it
would not sort.
Worse come to worse you could always ask on the the pgBadger mailing list:
https://listes.dalibo.com/cgi-bin/mailman/listinfo/pgbadger
>
> I read the code yesterday, and didn't find how to get a detail through
> it. Maybe my C knowledge is somewhat broken...
>
--
Adrian Klaver
adrian.klaver@gmail.com
Re: Is there a way to add a detail message in a warning with pl/Python?
От
DANIEL CRISTIAN CRUZ
Дата:
Em 29/01/2013 17:30, Adrian Klaver escreveu:
> Why not:
>
> DO $$
> plpy.warning('test, detail')
> $$ LANGUAGE plpythonu;
>
> In log:
>
> WARNING: test, detail
>
Because pgBadger doesn't use it this way:
http://dalibo.github.com/pgbadger/example.html#NormalizedErrorsMostFrequentReport
I read the code yesterday, and didn't find how to get a detail through
it. Maybe my C knowledge is somewhat broken...
--
Daniel Cristian Cruz
Unidade de Tecnologia da Informação
Sistema FIESC
Rod. Admar Gonzaga, 2765 - Itacorubi - 88034-001 - Florianópolis - SC
Fone (48) 3239-1422 - e-mail: daniel.cruz@sc.senai.br
site: http://www.sistemafiesc.org.br
Вложения
On Tue, Jan 29, 2013 at 8:03 PM, DANIEL CRISTIAN CRUZ
<daniel.cruz@sc.senai.br> wrote:
> Hello,
>
> I build a function and added some warnings where the id of the affected
> rows are inside it; and would be nice to put it into a detail, not in
> the message, since pgbadger can group it and I can see clearly what is
> wrong in my cluster.
>
> I read the manual and tried something with no success:
>
> plpy.warning('test', 'detail') -> output both values
> plpy.warning({'message': 'test', 'detail': 'detail'}) -> output the dict
> plpy.warning('test', detail='detail') -> fail
>
> Am I missing something?
>
> I would read the code, but I had no time right now...
You might be able to get it for errors by raising plpy.SPIError(error,
detail), but that doesn't help for warnings. I think for warnings you
would need to write a helper in PL/pgSQL or similar and use it to log
the warnings using plpy.prepare/plpy.execute.
--
Stuart Bishop <stuart@stuartbishop.net>
http://www.stuartbishop.net/
On 2013-01-30, Adrian Klaver <adrian.klaver@gmail.com> wrote:
> On 01/30/2013 02:49 AM, DANIEL CRISTIAN CRUZ wrote:
>>
>>
>> Em 29/01/2013 17:30, Adrian Klaver escreveu:
>>> Why not:
>>>
>>> DO $$
>>> plpy.warning('test, detail')
>>> $$ LANGUAGE plpythonu;
>>>
>>> In log:
>>>
>>> WARNING: test, detail
>>>
>>
>> Because pgBadger doesn't use it this way:
>>
>> http://dalibo.github.com/pgbadger/example.html#NormalizedErrorsMostFrequentReport
>
> I am not sure how you can determine that from the above. Looks like
> pgBadger is searching the detail string and applying a mask when
> appropriate i.e ERROR: relation "..." does not exist.
>
> When you use plpy.warning it is going to output WARNING:"Your string".
> If you are consistent in your naming of warnings I see no reason it
> would not sort.
>
note also that the "ERROR" "WARNING" "NOTICE" parts are subject to i18n
--
ââ 100% natural