Esempio n. 1
0
def configure_logging(app):

    app.logger = logging.getLogger("python-logstash-logger")
    app.logger.setLevel(logging.DEBUG)

    logstash_host = os.environ.get('LOGSTASH_HOST')

    handler = logstash.TCPLogstashHandler(logstash_host, 5959, version=1)
    formatter = LogstashFormatter()
    handler.setFormatter(formatter)

    app.logger.addHandler(handler)
    app.logger.info('Logging setup complete')
Esempio n. 2
0
    def __init__(self):
        self.logger = logging.getLogger("logstash")
        self.logger.setLevel(logging.INFO)
        try:
            host = os.environ["LOGSTASH_HOST"]
        except:
            host = "localhost"
        try:
            port = int(os.environ["LOGSTASH_PORT"])
        except:
            port = 5044
        handler = AsynchronousLogstashHandler(host=host,
                                              port=port,
                                              ssl_enable=False,
                                              ssl_verify=False,
                                              database_path='')

        formatter = LogstashFormatter()
        handler.setFormatter(formatter)
        self.logger.addHandler(handler)
        self.info("Init logger")
Esempio n. 3
0
def initiate_log():
    # Create the logger and set it's logging level
    logger = logging.getLogger("logstash")
    logger.setLevel(logging.DEBUG)

    # Create the handler
    handler = AsynchronousLogstashHandler(
        host='ab5413e7-7e28-45a6-bdaa-d6c3e00cab46-ls.logit.io',
        port=27421,
        ssl_enable=True,
        ssl_verify=False,
        database_path='')

    # Here you can specify additional formatting on your log record/message
    formatter = LogstashFormatter()
    handler.setFormatter(formatter)

    # Assign handler to the logger
    logger.addHandler(handler)

    return logger
Esempio n. 4
0
config_path_template = os.path.join(APP_ROOT, "TEMPLATE_config_environment.py")

# Sending loggs to logit.io
# Create the logger and set it's logging level
logger_logit = logging.getLogger("logstash")
logger_logit.setLevel(logging.ERROR)
# Create the handler
handler = AsynchronousLogstashHandler(
    host='fc652908-5b50-4887-8af2-89286e6febe1-ls.logit.io',
    port=17326,
    ssl_enable=True,
    ssl_verify=False,
    database_path='')
# Here you can specify additional formatting on your log record/message
formatter = LogstashFormatter(message_type='python-logstash',
                              extra_prefix='extra',
                              extra=dict(mikrostoritev='imageUpload',
                                         okolje='production'))
handler.setFormatter(formatter)
# Assign handler to the logger
logger_logit.addHandler(handler)

try:
    # if config_path.exists():
    if os.path.exists(config_path):
        exec(open(config_path).read())
    else:
        # exec(open(config_path_template).read())
        pass
except Exception as e:
    print("No configuration files found: ", e)
Esempio n. 5
0
logger.setLevel(logging.INFO)        

log_endpoint_uri = str(environ["LOGS_URI"]).strip()
log_endpoint_port = int(environ["LOGS_PORT"].strip())


# Create the handler
handler = AsynchronousLogstashHandler(
    host=log_endpoint_uri,
    port=log_endpoint_port, 
    ssl_enable=True, 
    ssl_verify=False,
    database_path='')

# Here you can specify additional formatting on your log record/message
formatter = LogstashFormatter()
handler.setFormatter(formatter)

# Assign handler to the logger
logger.addHandler(handler)

# -------------------------------------------
# Models
# -------------------------------------------
class User(db.Model):
    __tablename__ = 'users'

    user_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    email = db.Column(db.String)
    password_hash = db.Column(db.String)
    n_followers = db.Column(db.Integer)
Esempio n. 6
0
config_path_template = os.path.join(APP_ROOT, "TEMPLATE_config_environment.py")

# Sending loggs to logit.io
# Create the logger and set it's logging level
logger_logit = logging.getLogger("logstash")
logger_logit.setLevel(logging.ERROR)
# Create the handler
handler = AsynchronousLogstashHandler(
    host='fc652908-5b50-4887-8af2-89286e6febe1-ls.logit.io',
    port=17326,
    ssl_enable=True,
    ssl_verify=False,
    database_path='')
# Here you can specify additional formatting on your log record/message
formatter = LogstashFormatter(message_type='python-logstash',
                              extra_prefix='extra',
                              extra=dict(mikrostoritev='UserManagement',
                                         okolje='production'))
handler.setFormatter(formatter)
# Assign handler to the logger
logger_logit.addHandler(handler)

try:
    # if config_path.exists():
    if os.path.exists(config_path):
        exec(open(config_path).read())
    else:
        # exec(open(config_path_template).read())
        pass
except Exception as e:
    print("No configuration files found: ", e)
Esempio n. 7
0
transport = HttpTransport(host=logstash_host,
                          port=logstash_port,
                          ssl_enable=True,
                          ssl_verify=True,
                          timeout=5.0,
                          username=logstash_username,
                          password=logstash_password)

handler = AsynchronousLogstashHandler(host=logstash_host,
                                      port=logstash_port,
                                      transport=transport,
                                      database_path='log-stash.db')

formatter = LogstashFormatter(
    extra={
        'application': "pengy",
        'component': "pulse.eco",
        'environment': logstash_environment
    })
handler.setFormatter(formatter)

log.addHandler(handler)

# ttn config
ttn_mqtt_broker = config['ttn_mqtt']['server']
ttn_mqtt_broker_port = config['ttn_mqtt']['port']
ttn_mqtt_username = config['ttn_mqtt']['username']
ttn_mqtt_password = config['ttn_mqtt']['password']
ttn_mqtt_client_id = 'pengy-pulse.eco'

# pulse.eco config
pulse_eco_software_version = config['pulse_eco']['software_version']
Esempio n. 8
0
# Sending loggs to logit.io
# Create the logger and set it's logging level
logger_logit = logging.getLogger("logstash")
logger_logit.setLevel(logging.ERROR)
# Create the handler
handler = AsynchronousLogstashHandler(
    host="fc652908-5b50-4887-8af2-89286e6febe1-ls.logit.io",
    port=17326,
    ssl_enable=True,
    ssl_verify=False,
    database_path="",
)
# Here you can specify additional formatting on your log record/message
formatter = LogstashFormatter(
    message_type="python-logstash",
    extra_prefix="extra",
    extra=dict(mikrostoritev="imageUpload", okolje="production"),
)
handler.setFormatter(formatter)
# Assign handler to the logger
logger_logit.addHandler(handler)

try:
    # if config_path.exists():
    if os.path.exists(config_path):
        exec(open(config_path).read())
    else:
        # exec(open(config_path_template).read())
        pass
except Exception as e:
    print("No configuration files found: ", e)
    port=logstash_port,
    ssl_enable=True,
    ssl_verify=True,
    timeout=5.0,
    username=logstash_username,
    password=logstash_password)

handler = AsynchronousLogstashHandler(
    host=logstash_host,
    port=logstash_port,
	transport=transport,
    database_path='log-stash.db')

formatter = LogstashFormatter(
	extra={
		'application': "pengy",
		'component': "sensor.community",
		'environment': logstash_environment})

handler.setFormatter(formatter)

log.addHandler(handler)

# ttn config
ttn_mqtt_broker = config['ttn_mqtt']['server']
ttn_mqtt_broker_port = config['ttn_mqtt']['port']
ttn_mqtt_username = config['ttn_mqtt']['username']
ttn_mqtt_password = config['ttn_mqtt']['password']
ttn_mqtt_client_id = 'pengy-sensor.community'

# sensor_community config