Exemple #1
0
def mustLogWithoutColorsAsWell():
    # Arrange
    noExceptionThrown = 'exception not thrown'
    someLogMessage = 'some log message'
    someExceptionMessage = 'some exception message'
    someInnerExceptionMessage = 'some inner exception message'
    exception = None
    someExceptionMessageWithStackTrace = f'{someExceptionMessage} with stacktrace'
    someExceptionMessageWithoutStackTrace = f'{someExceptionMessage} without stacktrace'

    def controlableException(logType, muteStackTrace=False):
        try:
            raise Exception(
                someExceptionMessageWithoutStackTrace
                if muteStackTrace else someExceptionMessageWithStackTrace)
        except Exception as exception:
            if logType in OPTIONAL_EXCEPTION_LOG_TYPES:
                logType(logType,
                        someLogMessage,
                        exception=exception,
                        muteStackTrace=muteStackTrace)
            else:
                logType(logType,
                        someLogMessage,
                        exception,
                        muteStackTrace=muteStackTrace)

    # Act
    # log.success(log.success, someLogMessage)
    # log.setting(log.setting, someLogMessage)
    # log.debug(log.debug, someLogMessage)
    # log.warning(log.warning, someLogMessage)
    #
    # log.success(log.success, someLogMessage)
    # log.setting(log.setting, someLogMessage)
    # log.debug(log.debug, someLogMessage)
    # log.warning(log.warning, someLogMessage)

    controlableException(log.log)
    controlableException(log.debug)
    controlableException(log.warning)
    controlableException(log.wraper)
    controlableException(log.failure)
    controlableException(log.error)
    controlableException(log.test)

    controlableException(log.log, muteStackTrace=True)
    controlableException(log.debug, muteStackTrace=True)
    controlableException(log.warning, muteStackTrace=True)
    controlableException(log.wraper, muteStackTrace=True)
    controlableException(log.failure, muteStackTrace=True)
    controlableException(log.error, muteStackTrace=True)
    controlableException(log.test, muteStackTrace=True)

    # log.log(log.log, someLogMessage, None)
    # log.debug(log.debug, someLogMessage, None)
    # log.warning(log.warning, someLogMessage, None)
    # log.wraper(log.wraper, noExceptionThrown, None)
    # log.failure(log.failure, noExceptionThrown, None)
    # log.error(log.error, noExceptionThrown, None)
    # log.test(log.test, someLogMessage, None)

    # Assert
    assert True == SettingHelper.activeEnvironmentIsDefault()
    assert SettingHelper.DEFAULT_ENVIRONMENT == EnvironmentHelper.get(
        SettingHelper.ACTIVE_ENVIRONMENT)
    assert SettingHelper.DEFAULT_ENVIRONMENT == SettingHelper.getActiveEnvironment(
    )
Exemple #2
0
from python_helper import EnvironmentHelper, log

from python_helper import SettingHelper

import globals
globalsInstance = globals.newGlobalsInstance(__file__
    , loadLocalConfig = SettingHelper.activeEnvironmentIsDefault()

    , settingStatus = True
    , successStatus = True
    , errorStatus = True

    , debugStatus = True
    , failureStatus = True
    , warningStatus = True
    , wrapperStatus = True
    , logStatus = True
    # , testStatus = True
)

from python_framework.api.src.service.flask import FlaskManager
import TestApi
app = TestApi.app
api = TestApi.api
jwt = TestApi.jwt

@FlaskManager.initialize(api, defaultUrl = '/swagger', openInBrowser=False)
def runFlaskApplication(app=None):
    FlaskManager.runApi(debug=False, use_reloader=False)
    # app.run(debug=False, use_reloader=False)
    # app.run(debug=True)