~ubuntu-branches/ubuntu/lucid/gwibber/lucid-proposed

« back to all changes in this revision

Viewing changes to gwibber/microblog/util/log.py

  • Committer: Bazaar Package Importer
  • Author(s): Ken VanDine, Ken VanDine, Didier Roche
  • Date: 2010-02-17 14:47:15 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100217144715-emnd56aqicc3hone
Tags: 2.29.90-0ubuntu1
[ Ken VanDine ]
* New upstream release 2.29.90
  - ported Qaiku, StatusNet and Digg to 2.29.x
  - Added logging, now outputs logs in $HOME/.cache/gwibber/
  - Added url shortening to the python API
  - Updated docstrings for epydoc friendly API docs

[ Didier Roche ]
* debian/control:
  - bump Standard-Version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from os.path import join, isdir, realpath
 
2
from os import mkdir
 
3
import logging, logging.handlers
 
4
 
 
5
import xdg.BaseDirectory
 
6
 
 
7
cache_dir = realpath(join(xdg.BaseDirectory.xdg_cache_home, "gwibber"))
 
8
if not isdir(cache_dir):
 
9
  mkdir(cache_dir)
 
10
 
 
11
LOG_FILENAME = join(cache_dir, "gwibber.log")
 
12
loghandler = logging.handlers.RotatingFileHandler(
 
13
       LOG_FILENAME, maxBytes=20971520, backupCount=5)
 
14
logger = logging.getLogger('Gwibber')
 
15
logformatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
 
16
loghandler.setFormatter(logformatter)
 
17
logger.setLevel(logging.INFO)
 
18
logger.addHandler(loghandler)