logging configuration
This commit is contained in:
parent
786df6b552
commit
ca1de7f82d
|
@ -80,6 +80,8 @@ def create_app():
|
||||||
)
|
)
|
||||||
app.config.from_envvar('APPLICATION_SETTINGS')
|
app.config.from_envvar('APPLICATION_SETTINGS')
|
||||||
|
|
||||||
|
logging.basicConfig(filename=app.config['LOG_FILE'], level=logging.INFO)
|
||||||
|
|
||||||
token_file = Path(app.config.get('TOKEN_FILE'))
|
token_file = Path(app.config.get('TOKEN_FILE'))
|
||||||
if not token_file.exists():
|
if not token_file.exists():
|
||||||
app.logger.warning(
|
app.logger.warning(
|
||||||
|
|
|
@ -30,7 +30,7 @@ class DoorHandle:
|
||||||
self.nfc_sock.connect(nfc_socket)
|
self.nfc_sock.connect(nfc_socket)
|
||||||
self.logger.info(f"Connected to NFC socket at {nfc_socket}.")
|
self.logger.info(f"Connected to NFC socket at {nfc_socket}.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Could not connect to NFC socket at {nfc_socket}. "
|
self.logger.error(f"Could not connect to NFC socket at {nfc_socket}. "
|
||||||
f"Exception: {e}")
|
f"Exception: {e}")
|
||||||
self.nfc_sock = None
|
self.nfc_sock = None
|
||||||
#raise
|
#raise
|
||||||
|
@ -77,11 +77,13 @@ class DoorHandle:
|
||||||
email = data[3].strip() if len(data) > 3 else None
|
email = data[3].strip() if len(data) > 3 else None
|
||||||
valid_thru = data[4].strip() if len(data) > 4 else None
|
valid_thru = data[4].strip() if len(data) > 4 else None
|
||||||
|
|
||||||
tokens[token] = {'name': name,
|
tokens[token] = {
|
||||||
'organization': organization,
|
'name': name,
|
||||||
'email': email,
|
'organization': organization,
|
||||||
'valid_thru': valid_thru,
|
'email': email,
|
||||||
'inactive': inactive}
|
'valid_thru': valid_thru,
|
||||||
|
'inactive': inactive
|
||||||
|
}
|
||||||
return tokens
|
return tokens
|
||||||
|
|
||||||
def store_tokens(self, tokens):
|
def store_tokens(self, tokens):
|
||||||
|
@ -105,12 +107,14 @@ class DoorHandle:
|
||||||
if self.nfc_sock is not None:
|
if self.nfc_sock is not None:
|
||||||
self.nfc_sock.send(b'open ' + user.encode() + b'\n')
|
self.nfc_sock.send(b'open ' + user.encode() + b'\n')
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("No connection to NFC socket. Cannot close door!")
|
self.logger.error("No connection to NFC socket. Cannot open door!")
|
||||||
|
raise RuntimeError("No connection to NFC socket. Cannot open door!")
|
||||||
|
|
||||||
def close_door(self, user=''):
|
def close_door(self, user=''):
|
||||||
if self.nfc_sock is not None:
|
if self.nfc_sock is not None:
|
||||||
self.nfc_sock.send(b'close ' + user.encode() + b'\n')
|
self.nfc_sock.send(b'close ' + user.encode() + b'\n')
|
||||||
else:
|
else:
|
||||||
|
self.logger.error("No connection to NFC socket. Cannot close door!")
|
||||||
raise RuntimeError("No connection to NFC socket. Cannot close door!")
|
raise RuntimeError("No connection to NFC socket. Cannot close door!")
|
||||||
|
|
||||||
def get_most_recent_token(self):
|
def get_most_recent_token(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user