mirror of
https://github.com/fastogt/fastocloud_admin.git
synced 2025-03-09 23:38:52 +00:00
Logging
This commit is contained in:
parent
c1c5967d7c
commit
08a6a27eb1
2 changed files with 12 additions and 3 deletions
|
@ -10,6 +10,8 @@ from pyfastocloud.client_handler import IClientHandler, Request, Response, Clien
|
|||
from gevent import socket
|
||||
from gevent import select
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
def check_is_auth_client(client) -> bool:
|
||||
if not client:
|
||||
|
@ -215,11 +217,15 @@ class SubscribersServiceManager(ServiceManager, IClientHandler):
|
|||
|
||||
def __add_maybe_subscriber(self, subs: SubscriberConnection):
|
||||
self._subscribers.append(subs)
|
||||
print('New connection address: {0}, connections: {1}'.format(subs.address(), len(self._subscribers)))
|
||||
logging.info('New connection address: {0}, connections: {1}'.format(subs.address(), len(self._subscribers)))
|
||||
|
||||
def __activate_subscriber(self, subs: SubscriberConnection):
|
||||
print('Welcome registered user: {0}, connections: {1}'.format(subs.info.email, len(self._subscribers)))
|
||||
logging.info('Welcome registered user: {0}, connections: {1}'.format(subs.info.email, len(self._subscribers)))
|
||||
|
||||
def __remove_subscriber(self, subs: SubscriberConnection):
|
||||
self._subscribers.remove(subs)
|
||||
print('Bye registered user: {0}, connections: {1}'.format(subs.info.email, len(self._subscribers)))
|
||||
if subs.info:
|
||||
logging.info('Bye registered user: {0}, connections: {1}'.format(subs.info.email, len(self._subscribers)))
|
||||
else:
|
||||
logging.info(
|
||||
'Closed connection address: {0}, connections: {1}'.format(subs.address(), len(self._subscribers)))
|
||||
|
|
|
@ -20,6 +20,9 @@ if __name__ == '__main__':
|
|||
parser.add_argument('--host', help='host (default: {0})'.format(HOST), default=HOST)
|
||||
argv = parser.parse_args()
|
||||
|
||||
import logging
|
||||
logging.basicConfig(filename='admin.log', filemode='w', level=logging.DEBUG, format='%(asctime)s.%(msecs)03d [%(levelname)s] %(message)s', datefmt='%H:%M:%S')
|
||||
|
||||
http_server = WSGIServer((argv.host, argv.port), app)
|
||||
srv_greenlet = gevent.spawn(http_server.serve_forever)
|
||||
alarm_greenlet = gevent.spawn(servers_refresh)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue