fix loggly setup
This commit is contained in:
parent
142d30bbcf
commit
4c7c94e190
2 changed files with 20 additions and 18 deletions
|
@ -139,18 +139,27 @@ def get_loggly_url(token=None, version=None):
|
|||
return LOGGLY_URL.format(token=token, tag='lbrynet-' + version)
|
||||
|
||||
|
||||
def configure_loggly_handler(*args, **kwargs):
|
||||
def configure_loggly_handler():
|
||||
if build_type.BUILD == 'dev':
|
||||
return
|
||||
level = kwargs.pop('level', logging.WARNING)
|
||||
_configure_loggly_handler(*args, level=level, **kwargs)
|
||||
level = logging.WARNING
|
||||
handler = get_loggly_handler(level=level, installation_id=conf.settings.installation_id,
|
||||
session_id=conf.settings.get_session_id())
|
||||
log = logging.getLogger("lbrynet")
|
||||
if handler.name:
|
||||
remove_handlers(log, handler.name)
|
||||
handler.setLevel(level)
|
||||
log.addHandler(handler)
|
||||
# need to reduce the logger's level down to the
|
||||
# handler's level or else the handler won't
|
||||
# get those messages
|
||||
if log.level > level:
|
||||
log.setLevel(level)
|
||||
|
||||
|
||||
@_log_decorator
|
||||
def _configure_loggly_handler(url=None, **kwargs):
|
||||
url = url or get_loggly_url()
|
||||
formatter = JsonFormatter(**kwargs)
|
||||
handler = HTTPSHandler(url)
|
||||
def get_loggly_handler(level, installation_id, session_id):
|
||||
formatter = JsonFormatter(level=level, installation_id=installation_id, session_id=session_id)
|
||||
handler = HTTPSHandler(get_loggly_url())
|
||||
handler.setFormatter(formatter)
|
||||
handler.name = 'loggly'
|
||||
return handler
|
||||
|
@ -255,7 +264,6 @@ def configure_logging(file_name, console, verbose=None):
|
|||
verbose = convert_verbose(verbose)
|
||||
configure_twisted()
|
||||
configure_file_handler(file_name)
|
||||
configure_loggly_handler()
|
||||
disable_third_party_loggers()
|
||||
if console:
|
||||
# if there are some loggers at the debug level, we need
|
||||
|
|
|
@ -24,7 +24,7 @@ from lbrynet import conf, analytics
|
|||
from lbrynet.conf import LBRYCRD_WALLET, LBRYUM_WALLET, PTC_WALLET
|
||||
from lbrynet.reflector import reupload
|
||||
from lbrynet.reflector import ServerFactory as reflector_server_factory
|
||||
|
||||
from lbrynet.core.log_support import configure_loggly_handler
|
||||
from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileSaverFactory
|
||||
from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileOpenerFactory
|
||||
from lbrynet.lbry_file.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier
|
||||
|
@ -36,7 +36,7 @@ from lbrynet.daemon.Publisher import Publisher
|
|||
from lbrynet.daemon.ExchangeRateManager import ExchangeRateManager
|
||||
from lbrynet.daemon.auth.server import AuthJSONRPCServer
|
||||
from lbrynet.core.PaymentRateManager import OnlyFreePaymentsManager
|
||||
from lbrynet.core import log_support, utils, system_info
|
||||
from lbrynet.core import utils, system_info
|
||||
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier, download_sd_blob
|
||||
from lbrynet.core.Session import Session
|
||||
from lbrynet.core.Wallet import LBRYumWallet, SqliteStorage, ClaimOutpoint
|
||||
|
@ -225,7 +225,7 @@ class Daemon(AuthJSONRPCServer):
|
|||
def setup(self):
|
||||
reactor.addSystemEventTrigger('before', 'shutdown', self._shutdown)
|
||||
|
||||
self._modify_loggly_formatter()
|
||||
configure_loggly_handler()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _announce_startup():
|
||||
|
@ -505,12 +505,6 @@ class Daemon(AuthJSONRPCServer):
|
|||
return d
|
||||
return defer.succeed(True)
|
||||
|
||||
def _modify_loggly_formatter(self):
|
||||
log_support.configure_loggly_handler(
|
||||
installation_id=conf.settings.installation_id,
|
||||
session_id=self._session_id
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _setup_lbry_file_manager(self):
|
||||
log.info('Starting to setup up file manager')
|
||||
|
|
Loading…
Reference in a new issue