2

I have created a large python script at the end. But now I need a logger for it. I have input steps, prompts.. Function calls.. While Loops.., etc. in the script.

And also, the logger is have to log success operations too.

I couldn't find a suitable answer for me. I'm searching on the internet again, and wanted to ask you too.

Whats your opinion?

Thanks

5
  • 1
    so you mean saving a trace of the operating code or just a logging library? Commented Dec 15, 2011 at 14:32
  • Actually yes, I want to save (actually mail) trace of the operation but not the print part (output), background part too.. (Like if I execute os.system ('sleep 5') it will log like system is going to sleep 5 seconds. or whatever the system default thinking is.) Commented Dec 15, 2011 at 14:41
  • You'd better search on internet and ask us if you don't find an answer... SO is for unanswered questions... Commented Dec 15, 2011 at 14:47
  • 1
    I would think that this is a good start: docs.python.org/library/trace.html Commented Dec 15, 2011 at 14:48
  • I have already searched @gecco, asked to SO and now re-searching (again). I couldn't find a suitable answer for me. Commented Dec 15, 2011 at 14:54

1 Answer 1

2

There's a module logging in the standard library. Basic usage is very simple; in every module that needs to do logging, put

logger = logging.getLogger(__name__)

and log with, e.g.,

logger.info("Doing something interesting")
logger.warn("Oops, something's not right")

Then in the main module, put something like

logging.basicConfig(level=logging.INFO)

to print all logs with a severity of INFO or worse to standard error. The module is very configurable, see its documentation for details.

Sign up to request clarification or add additional context in comments.

1 Comment

I didn't had chance to implement it. Sorry for delay.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.