Example #1
0
def log_outbound(result,
                 service_ip,
                 service_port,
                 service_method,
                 service_request_uri,
                 service_request_query,
                 service_request_body,
                 http_response_code,
                 description='-',
                 exception=False):
    #
    args = {
        'timestamp': _timestamp(),
        'service_id': get_cfg_serviceid(),
        'service_type': serviceType,
        'result': result,
        'service_ip': service_ip,
        'service_port': service_port,
        'service_method': service_method,
        'service_request_uri': service_request_uri,
        'service_request_query': service_request_query,
        'service_request_body': service_request_body,
        'http_response_code': http_response_code,
        'description': description
    }
    #
    log_msg = logOutbound.format(**args)
    #
    if exception:
        log_msg += ', exception={exception}'.format(exception=exception)
    #
    _add_log_entry(log_msg)
Example #2
0
def get_config(request):
    #
    args = get_request_log_args(request)
    #
    try:
        #
        data = {
            'service_id': get_cfg_serviceid(),
            'name_long': get_cfg_name_long(),
            'name_short': get_cfg_name_short(),
            'subservices': get_cfg_subservices(),
            'groups': get_cfg_groups(),
            'ui_links': []
        }
        #
        status = httpStatusSuccess
        #
        args['result'] = logPass
        args['http_response_code'] = status
        args['description'] = '-'
        log_inbound(**args)
        #
        return HTTPResponse(body=data, status=status)
        #
    except Exception as e:
        #
        status = httpStatusServererror
        #
        args['result'] = logException
        args['http_response_code'] = status
        args['description'] = '-'
        args['exception'] = e
        log_inbound(**args)
        #
        raise HTTPError(status)
Example #3
0
def logging_service():
    while True:
        #
        item = cache.logQ.get()
        #
        item['timestamp'] = item['timestamp'].strftime(logTimeFormat)
        item['service_id'] = get_cfg_serviceid()
        item['service_type'] = serviceType
        #
        save_log_item(item)
Example #4
0
def get_config(request):
    #
    args = get_request_log_args(request)
    args['timestamp'] = datetime.now()
    args['process'] = 'inbound'
    #
    try:
        #
        data = {
            'service_id':
            get_cfg_serviceid(),
            'name_long':
            get_cfg_name_long(),
            'name_short':
            get_cfg_name_short(),
            'subservices':
            get_cfg_subservices(),
            'groups':
            get_cfg_groups(),
            'ui_links': [{
                'label': 'Authentication (2FA)',
                'description':
                'Undertake two-factor authentication (2FA) to allow access to iCloud account.',
                'uri': '/icloud/authentication/2fa/2fa.html'
            }]
        }
        #
        status = httpStatusSuccess
        #
        args['result'] = logPass
        args['http_response_code'] = status
        args['description'] = '-'
        cache.logQ.put(args)
        #
        return HTTPResponse(body=data, status=status)
        #
    except Exception as e:
        #
        status = httpStatusServererror
        #
        args['result'] = logException
        args['http_response_code'] = status
        args['description'] = '-'
        args['exception'] = e
        cache.logQ.put(args)
        #
        raise HTTPError(status)
Example #5
0
def get_config(request):
    #
    args = get_request_log_args(request)
    args['timestamp'] = datetime.now()
    args['process'] = 'inbound'
    #
    try:
        #
        data = {
            'service_id':
            get_cfg_serviceid(),
            'name_long':
            get_cfg_name_long(),
            'name_short':
            get_cfg_name_short(),
            'subservices':
            get_cfg_subservices(),
            'groups':
            get_cfg_groups(),
            'ui_links': [{
                'label': 'Configuration',
                'description':
                'Update configuration for categories, countries, language and sources.',
                'uri': '/news/config.html'
            }]
        }
        #
        status = httpStatusSuccess
        #
        args['result'] = logPass
        args['http_response_code'] = status
        args['description'] = '-'
        cache.logQ.put(args)
        #
        return HTTPResponse(body=data, status=status)
        #
    except Exception as e:
        #
        status = httpStatusServererror
        #
        args['result'] = logException
        args['http_response_code'] = status
        args['description'] = '-'
        args['exception'] = e
        cache.logQ.put(args)
        #
        raise HTTPError(status)
Example #6
0
def log_internal(result, operation, description='-', exception=False):
    #
    args = {
        'timestamp': _timestamp(),
        'service_id': get_cfg_serviceid(),
        'service_type': serviceType,
        'result': result,
        'operation': operation,
        'description': description
    }
    #
    log_msg = logInternal.format(**args)
    #
    if exception:
        log_msg += ', exception={exception}'.format(exception=exception)
    #
    _add_log_entry(log_msg)
Example #7
0
from discovery.broadcast import broadcast_service
from log.log import log_internal
from portlistener import start_bottle

try:

    ################################

    log_internal(logPass, logDescStartingService, description='started')

    ################################
    # Initiate service broadcast

    process_broadcast = Process(target=broadcast_service,
                                args=(
                                    get_cfg_serviceid(),
                                    get_cfg_port(),
                                ))
    process_broadcast.start()

    ################################
    # Port_listener

    log_internal(logPass,
                 logDescPortListener.format(port=get_cfg_port()),
                 description='starting')

    start_bottle()

    process_broadcast.terminate()
Example #8
0
from resources.global_resources.log_vars import logPass, logException
from config.config import get_cfg_serviceid, get_cfg_port
from discovery.broadcast import broadcast_service
from log.log import log_internal
from portlistener import start_bottle

try:

    ################################

    log_internal(logPass, logDescStartingService, description='started')

    ################################
    # Initiate service broadcast

    process_broadcast = Process(target=broadcast_service, args=(get_cfg_serviceid(), get_cfg_port(), ))
    process_broadcast.start()

    ################################
    # Port_listener

    log_internal(logPass, logDescPortListener.format(port=get_cfg_port()), description='starting')

    start_bottle()

    process_broadcast.terminate()

    log_internal(logPass, logDescPortListener.format(port=get_cfg_port()), description='stopped')

except Exception as e:
    log_internal(logException, logDescStartingService, description='fail', exception=e)
Example #9
0
def _get_log_filename():
    return '{filename}.{date}.log'.format(
        filename=get_cfg_serviceid(),
        date=datetime.now().strftime(logFileNameDateFormat))