log: import fcntl only on linux

Otherwise, ogClient do not work on Windows because fcntl module do not
exists on Windows.
more_events
Javier Sánchez Parra 2022-09-27 17:35:22 +02:00
parent 3703fd6063
commit f1fff0b0b6
1 changed files with 76 additions and 70 deletions

View File

@ -2,9 +2,10 @@ import logging
import logging.config
import os
from src.utils.net import getifaddr
DEFAULT_LOGGING_LINUX = {
def _default_logging_linux():
from src.utils.net import getifaddr
logconfig = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
@ -49,8 +50,11 @@ DEFAULT_LOGGING_LINUX = {
},
}
}
return logconfig
DEFAULT_LOGGING_WIN = {
def _default_logging_win():
logconfig = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
@ -75,6 +79,8 @@ DEFAULT_LOGGING_WIN = {
},
}
}
return logconfig
def configure_logging(mode, level):
"""
@ -86,9 +92,9 @@ def configure_logging(mode, level):
logging to the expected samba shared log file ({ip}.txt.log).
"""
if mode == 'windows':
logconfig = DEFAULT_LOGGING_WIN
logconfig = _default_logging_win()
else:
logconfig = DEFAULT_LOGGING_LINUX
logconfig = _default_logging_linux()
if mode == 'live':
logconfig['loggers']['']['handlers'].append('samba')