Beispiel #1
0
import os
import logging
import argparse

from memsql_loader.util import paths

_debug = False
_disable_stdout = False
_log_path = os.path.join(paths.get_data_dir(), 'memsql_loader.log')

_file_handler = None
_stream_handler = None


def setup(log_path=None, stdout_enabled=True):
    global _stream_handler, _file_handler

    if stdout_enabled:
        _stream_handler = logging.StreamHandler()
        format_str = "(%(levelname)s) %(message)s"
        _stream_handler.setFormatter(logging.Formatter(format_str))
    else:
        _stream_handler = False

    if log_path is not None:
        # mark that we are joining the file log
        try:
            with open(log_path, 'a') as logfile:
                logfile.write('Log file opened by %s\n' % os.getpid())

            _file_handler = logging.FileHandler(filename=log_path)
Beispiel #2
0
def get_pid_file_path():
    return os.path.join(paths.get_data_dir(), "memsql-loader.pid")
Beispiel #3
0
def get_loader_db_path():
    return os.path.join(paths.get_data_dir(), MEMSQL_LOADER_DB)
Beispiel #4
0
import os
import logging
import argparse

from memsql_loader.util import paths

_debug = False
_disable_stdout = False
_log_path = os.path.join(paths.get_data_dir(), 'memsql_loader.log')

_file_handler = None
_stream_handler = None

def setup(log_path=None, stdout_enabled=True):
    global _stream_handler, _file_handler

    if stdout_enabled:
        _stream_handler = logging.StreamHandler()
        format_str = "(%(levelname)s) %(message)s"
        _stream_handler.setFormatter(logging.Formatter(format_str))
    else:
        _stream_handler = False

    if log_path is not None:
        # mark that we are joining the file log
        try:
            with open(log_path, 'a') as logfile:
                logfile.write('Log file opened by %s\n' % os.getpid())

            _file_handler = logging.FileHandler(filename=log_path)
            format_str = "%(asctime)s %(levelname)s | %(process)d:%(name)s | %(message)s"