Example #1
0
 def config_mongolog(self, db_uri, db_name, log_col_name, log_level):
     c_sync = pymongo.MongoClient(db_uri, w=0)
     col = c_sync[db_name][log_col_name]
     logging.getLogger().addHandler(MongoHandler.to(collection=col))
     logging.getLogger().setLevel(log_level)
Example #2
0
import logging
import os
from mongolog import MongoHandler

DEFAULT_PREFIX = '$'

if os.getenv('DEBUG'):
    DB = ''
else:
    DB = ''

log = logging.getLogger('discord')
log.setLevel(logging.INFO)
log.addHandler(MongoHandler.to(db=DB, collection='logs', level=logging.INFO))
handler_stdout = logging.StreamHandler()
handler_stdout.setFormatter(logging.Formatter(logging.BASIC_FORMAT))
log.addHandler(handler_stdout)
Example #3
0
# -*- coding: utf-8 *-*
import sys
sys.path.append('..')

import logging

from mongolog import MongoHandler

if __name__ == '__main__':

    log = logging.getLogger('example')
    log.setLevel(logging.DEBUG)

    log.addHandler(MongoHandler.to('mongolog', 'log'))

    log.debug("1 - debug message")
    log.info("2 - info message")
    log.warn("3 - warn message")
    log.error("4 - error message")
    log.critical("5 - critical message")
Example #4
0
 def config_mongolog(self, db_uri, db_name, log_col_name, log_level):
     c_sync = pymongo.MongoClient(db_uri, w=0)
     col = c_sync[db_name][log_col_name]
     logging.getLogger().addHandler(MongoHandler.to(collection=col))
     logging.getLogger().setLevel(log_level)