Re: [Tutor] Create Logging module

2019-08-02 Thread Sinardy Xing
Thank you Alan, - from previous mail > if any(logleveltocheck.upper() in lf for lf in ['DEBUG', > 'INFO', 'WARNING', 'ERROR', 'CRITICAL']): > return logleveltocheck.upper() Are you sure that is what you want? It seems very complicated unless you are allowing

Re: [Tutor] Create Logging module

2019-08-02 Thread Sinardy Xing
Thanks Alan, I learn alot. logger.setLevel('INFO') <- If I did not include this in the code it not generating any log I am confuse because I have setLevel to file_handler and to stream_handler file_handler.setLevel('DEBUG') stream_handler.setLevel('DEBUG') On Fri, Aug 2, 2019 at 12:14 AM

Re: [Tutor] Create Logging module

2019-08-01 Thread Sinardy Xing
Hi I solve my problem, the decorator need to be above the function not when executed. :) Thanks for reading. :) On Thu, Aug 1, 2019 at 8:42 PM Steven D'Aprano wrote: > On Thu, Aug 01, 2019 at 05:11:04PM +0800, Sinardy Xing wrote: > > > I have error look like in the wrapper. > > > > Can some

Re: [Tutor] Create Logging module

2019-08-01 Thread Sinardy Xing
Hi Steven, Thanks for your reply, I was copy and paste the code in the email as a text. I dont know why it becoming photo or screen shot when you view it ? When I run the module individually it is no error only when I use as decorator I have error. $ cat mainapp.py from loggingme import logme

Re: [Tutor] Create Logging module

2019-08-01 Thread Peter Otten
Sinardy Xing wrote: > following is my main app > > -- start here-- > from loggingme import logme > > def say_hello(name, age): > print('Hello {}, I am {}'.format(name, age)) > > #say_hello=logme(say_hello('Sinardy')) > @logme > say_hello('Tonny', 8) Isn't this a SyntaxError? You can de

Re: [Tutor] Create Logging module

2019-08-01 Thread Alan Gauld via Tutor
On 01/08/2019 10:11, Sinardy Xing wrote: > start here--- > > import logging > > ..snip... > from functools import wraps > > def logme(func_to_log): > import logging You don't need the import, it's already done in the first line. > #Check log level within understanable paramet

Re: [Tutor] Create Logging module

2019-08-01 Thread Steven D'Aprano
On Thu, Aug 01, 2019 at 05:11:04PM +0800, Sinardy Xing wrote: > I have error look like in the wrapper. > > Can someone point to me where is the issue No, but you can. When the error occurs, Python will print a traceback containing a list of the lines of code being executed, and the final error

[Tutor] Create Logging module

2019-08-01 Thread Sinardy Xing
Hi, I am learning to create python logging. My goal is to create a logging module where I can use as decorator in my main app following is the logging code start here--- import logging #DEBUG: Detailed information, typically of interest only when diagnosing problems. #INFO : Conf