use same logging for apps
This commit is contained in:
parent
6f9ec2fa66
commit
80f548fdfd
2 changed files with 10 additions and 18 deletions
|
@ -4,32 +4,22 @@ install(runner=AppHelper.runEventLoop)
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
from appdirs import user_data_dir
|
|
||||||
|
|
||||||
|
from lbrynet import conf
|
||||||
|
from lbrynet.core import log_support
|
||||||
from LBRYApp import LBRYDaemonApp
|
from LBRYApp import LBRYDaemonApp
|
||||||
|
|
||||||
if sys.platform != "darwin":
|
|
||||||
log_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
|
|
||||||
else:
|
|
||||||
log_dir = user_data_dir("LBRY")
|
|
||||||
|
|
||||||
if not os.path.isdir(log_dir):
|
log = logging.getLogger()
|
||||||
os.mkdir(log_dir)
|
|
||||||
|
|
||||||
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=2097152, backupCount=5)
|
|
||||||
log.addHandler(handler)
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
log_file = conf.get_log_filename()
|
||||||
|
log_support.configure_logging(log_file, console=False)
|
||||||
app = LBRYDaemonApp.sharedApplication()
|
app = LBRYDaemonApp.sharedApplication()
|
||||||
reactor.addSystemEventTrigger("after", "shutdown", AppHelper.stopEventLoop)
|
reactor.addSystemEventTrigger("after", "shutdown", AppHelper.stopEventLoop)
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import socket
|
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
@ -11,13 +10,14 @@ import win32gui_struct
|
||||||
from jsonrpc.proxy import JSONRPCProxy
|
from jsonrpc.proxy import JSONRPCProxy
|
||||||
from twisted.internet import reactor, error
|
from twisted.internet import reactor, error
|
||||||
from twisted.web import server
|
from twisted.web import server
|
||||||
import twisted
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import winxpgui as win32gui
|
import winxpgui as win32gui
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import win32gui
|
import win32gui
|
||||||
|
|
||||||
|
from lbrynet import conf
|
||||||
|
from lbrynet.core import log_support
|
||||||
from lbrynet.core import utils
|
from lbrynet.core import utils
|
||||||
from lbrynet.lbrynet_daemon.DaemonServer import DaemonServer
|
from lbrynet.lbrynet_daemon.DaemonServer import DaemonServer
|
||||||
from lbrynet.lbrynet_daemon.DaemonRequest import DaemonRequest
|
from lbrynet.lbrynet_daemon.DaemonRequest import DaemonRequest
|
||||||
|
@ -284,6 +284,8 @@ def main(lbry_name=None):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
utils.setup_certs_for_windows()
|
utils.setup_certs_for_windows()
|
||||||
|
log_file = conf.get_log_filename()
|
||||||
|
log_support.configure_logging(log_file, console=False)
|
||||||
lbry_daemon = JSONRPCProxy.from_url(settings.API_CONNECTION_STRING)
|
lbry_daemon = JSONRPCProxy.from_url(settings.API_CONNECTION_STRING)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue