Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support verbose option again

  • Loading branch information...
commit 28f5de903a9521eaa7fb2cf339b16290fce844bf 1 parent b25df8b
@rubys authored
View
2  filters/mememe.plugin
@@ -25,7 +25,7 @@ from htmlentitydefs import entitydefs
import planet
from planet import config, feedparser
from planet.spider import filename
-log = planet.getLogger(config.log_level(),config.log_format())
+log = planet.logger
options = config.filter_options(sys.argv[0])
MEMES_ATOM = os.path.join(config.output_dir(),'memes.atom')
View
8 planet/__init__.py
@@ -1,6 +1,7 @@
xmlns = 'http://planet.intertwingly.net/'
logger = None
+loggerParms = None
import os, sys, re
import config
@@ -11,8 +12,8 @@
def getLogger(level, format):
""" get a logger with the specified log level """
- global logger
- if logger: return logger
+ global logger, loggerParms
+ if logger and loggerParms == (level,format): return logger
try:
import logging
@@ -21,13 +22,14 @@ def getLogger(level, format):
import compat_logging as logging
logging.basicConfig(format=format)
- logging.getLogger().setLevel(logging.getLevelName(level))
logger = logging.getLogger("planet.runner")
+ logger.setLevel(logging.getLevelName(level))
try:
logger.warning
except:
logger.warning = logger.warn
+ loggerParms = (level,format)
return logger
# Configure feed parser
View
4 planet/config.py
@@ -139,7 +139,9 @@ def load(config_file):
import config, planet
from planet import opml, foaf
- log = planet.getLogger(config.log_level(),config.log_format())
+ log = planet.logger
+ if not log:
+ log = planet.getLogger(config.log_level(),config.log_format())
# Theme support
theme = config.output_theme()
View
3  planet/expunge.py
@@ -5,8 +5,7 @@
def expungeCache():
""" Expunge old entries from a cache of entries """
- import planet
- log = planet.getLogger(config.log_level(),config.log_format())
+ log = planet.logger
log.info("Determining feed subscriptions")
entry_count = {}
View
2  planet/shell/__init__.py
@@ -6,7 +6,7 @@
def run(template_file, doc, mode='template'):
""" select a template module based on file extension and execute it """
- log = planet.getLogger(planet.config.log_level(),planet.config.log_format())
+ log = planet.logger
if mode == 'template':
dirs = planet.config.template_directories()
View
2  planet/spider.py
@@ -329,7 +329,7 @@ def httpThread(thread_index, input_queue, output_queue, log):
def spiderPlanet(only_if_new = False):
""" Spider (fetch) an entire planet """
- log = planet.getLogger(config.log_level(),config.log_format())
+ log = planet.logger
global index
index = True
View
4 planet/splice.py
@@ -9,7 +9,7 @@
def splice():
""" Splice together a planet from a cache of entries """
import planet
- log = planet.getLogger(config.log_level(),config.log_format())
+ log = planet.logger
log.info("Loading cached data")
cache = config.cache_directory()
@@ -109,7 +109,7 @@ def splice():
def apply(doc):
output_dir = config.output_dir()
if not os.path.exists(output_dir): os.makedirs(output_dir)
- log = planet.getLogger(config.log_level(),config.log_format())
+ log = planet.logger
planet_filters = config.filters('Planet')
View
3  tests/test_expunge.py
@@ -15,7 +15,7 @@
class ExpungeTest(unittest.TestCase):
def setUp(self):
# silence errors
- planet.logger = None
+ self.original_logger = planet.logger
planet.getLogger('CRITICAL',None)
try:
@@ -29,6 +29,7 @@ def setUp(self):
def tearDown(self):
shutil.rmtree(workdir)
os.removedirs(os.path.split(workdir)[0])
+ planet.logger = self.original_logger
def test_expunge(self):
config.load(configfile)
View
10 tests/test_idindex.py
@@ -1,18 +1,18 @@
#!/usr/bin/env python
-import unittest
-from planet import idindex, config, logger
+import unittest, planet
+from planet import idindex, config
class idIndexTest(unittest.TestCase):
def setUp(self):
# silence errors
- import planet
- planet.logger = None
+ self.original_logger = planet.logger
planet.getLogger('CRITICAL',None)
def tearDown(self):
idindex.destroy()
+ planet.logger = self.original_logger
def test_unicode(self):
from planet.spider import filename
@@ -69,6 +69,6 @@ def test_index_splice(self):
try:
module = 'dbhash'
except ImportError:
- logger.warn("dbhash is not available => can't test id index")
+ planet.logger.warn("dbhash is not available => can't test id index")
for method in dir(idIndexTest):
if method.startswith('test_'): delattr(idIndexTest,method)
View
3  tests/test_spider.py
@@ -12,7 +12,7 @@
class SpiderTest(unittest.TestCase):
def setUp(self):
# silence errors
- planet.logger = None
+ self.original_logger = planet.logger
planet.getLogger('CRITICAL',None)
try:
@@ -24,6 +24,7 @@ def setUp(self):
def tearDown(self):
shutil.rmtree(workdir)
os.removedirs(os.path.split(workdir)[0])
+ planet.logger = self.original_logger
def test_filename(self):
self.assertEqual(os.path.join('.', 'example.com,index.html'),
Please sign in to comment.
Something went wrong with that request. Please try again.