Skip to content
Permalink
Browse files

Ensure no logging as part of a standard import

Ensure that the database code does not do any logging during module load.  This
is because it is frequently imported by other scripts, and those imports run
before any configuration (in `__main__`) for example is executed. This means
that the logging is configured to the default values, which, given the first
log message, is WARNING.

This change replaces the log with print.
BEFORE: logs only WARNINGS
AFTER: logs everything

+ bonus fix: mark the `-s` parameter as `type=int`. Otherwise it remains a
string and the batching fails later.
  • Loading branch information...
shankari committed Dec 15, 2017
1 parent fd79478 commit 48face01f3ae006aa7207afb4936c695ed0e30b8
Showing with 3 additions and 4 deletions.
  1. +1 −1 bin/debug/load_multi_timeline_for_range.py
  2. +2 −3 emission/core/get_database.py
@@ -80,7 +80,7 @@ def post_check(unique_user_list, all_rerun_list):
parser.add_argument("-i", "--info-only", default=False, action='store_true',
help="only print entry analysis")

parser.add_argument("-s", "--batch-size", default=10000,
parser.add_argument("-s", "--batch-size", default=10000, type=int,
help="batch size to use for the entries")

parser.add_argument("-p", "--prefix", default="user",
@@ -9,18 +9,17 @@
import pymongo
import os
import json
import logging

try:
config_file = open('conf/storage/db.conf')
except:
logging.warning("storage not configured, falling back to sample, default configuration")
print("storage not configured, falling back to sample, default configuration")
config_file = open('conf/storage/db.conf.sample')

config_data = json.load(config_file)
url = config_data["timeseries"]["url"]

logging.debug("Connecting to database URL "+url)
print("Connecting to database URL "+url)
_current_db = MongoClient(url).Stage_database

def _get_current_db():

0 comments on commit 48face0

Please sign in to comment.
You can’t perform that action at this time.