synthicity/urbansim — pull request #41 by jiffyclub (2014-06-23 23:11:39+00:00)
Title: Logging

Adds logging statements (all at the debug level) in parts of urbansim used by regression, LCM, transition, and relocation models. I didn't touch developer stuff.

To get logging output do something like this:

```python
import logging

from urbansim.utils import logutil

logutil.set_log_level(logging.DEBUG)
logutil.log_to_stream() # logs to stderr
logutil.log_to_file('urbansim.log')
```

If you use those utility methods you'll get log statements with formats like:

```
2014-06-23 16:00:29|DEBUG|urbansim.urbanchoice.mnl|mnl_simulate|mnl.py|122|start: MNL simulation with len(data)=10 and numalts=10
```

Feel free to add more logging anywhere at any time, more logging is almost always better than less.

The pattern for logging is at the top of a file to `import logging` and then define a global logger via `logger = logging.getLogger(__name__)`. Then use the `logger.debug`, `logger.info`, etc. methods to send messages to the logs.