# Path: cloudify/logs.py
# EVENT_CLASS = _event.Event
# EVENT_VERBOSITY_LEVEL = _event.NO_VERBOSE
# def message_context_from_cloudify_context(ctx):
# def message_context_from_workflow_context(ctx):
# def message_context_from_sys_wide_wf_context(ctx):
# def message_context_from_workflow_node_instance_context(ctx):
#     def __init__(self, ctx, out_func, message_context_builder):
#     def flush(self):
#     def emit(self, record):
#     def __init__(self, ctx, out_func=None):
#     def __init__(self, ctx, out_func=None):
#     def __init__(self, ctx, out_func=None):
#     def __init__(self, ctx, out_func=None):
# def init_cloudify_logger(handler, logger_name,
#                          logging_level=logging.DEBUG):
# def send_workflow_event(ctx, event_type,
#                         message=None,
#                         args=None,
#                         additional_context=None,
#                         out_func=None):
# def send_sys_wide_wf_event(ctx, event_type, message=None, args=None,
#                            additional_context=None, out_func=None):
# def send_workflow_node_event(ctx, event_type,
#                              message=None,
#                              args=None,
#                              additional_context=None,
#                              out_func=None):
# def send_plugin_event(ctx,
#                       message=None,
#                       args=None,
#                       additional_context=None,
#                       out_func=None):
# def send_task_event(cloudify_context,
#                     event_type,
#                     message=None,
#                     args=None,
#                     additional_context=None,
#                     out_func=None):
# def _send_event(ctx, context_type, event_type,
#                 message, args, additional_context,
#                 out_func):
# def populate_base_item(item, message_type):
# def amqp_event_out(event):
# def amqp_log_out(log):
# def stdout_event_out(event):
# def stdout_log_out(log):
# def create_event_message_prefix(event):
# def with_amqp_client(func):
#     def wrapper(*args, **kwargs):
# def _publish_message(client, message, message_type, logger):
#     def __init__(self, context, socket, fallback_logger):
#     def emit(self, record):
# class CloudifyBaseLoggingHandler(logging.Handler):
# class CloudifyPluginLoggingHandler(CloudifyBaseLoggingHandler):
# class CloudifyWorkflowLoggingHandler(CloudifyBaseLoggingHandler):
# class SystemWideWorkflowLoggingHandler(CloudifyBaseLoggingHandler):
# class CloudifyWorkflowNodeLoggingHandler(CloudifyBaseLoggingHandler):
# class ZMQLoggingHandler(logging.Handler):
# 
# Path: cloudify/celery/logging_server.py
# LOGFILE_SIZE_BYTES = 5 * 1024 * 1024
# LOGFILE_BACKUP_COUNT = 5
# def configure_app(app):
#     def __init__(self, worker,
#                  with_logging_server=False,
#                  logging_server_logdir=None,
#                  logging_server_handler_cache_size=100,
#                  **kwargs):
#     def info(self, worker):
#     def start(self, worker):
#     def _stop_logging_server(self, worker):
#     def __init__(self, logdir, socket_url, cache_size):
#     def start(self):
#     def close(self):
#     def _process(self, entry):
#     def _get_handler(self, handler_context):
#     def __init__(self, message):
#     def format(record):
# class ZMQLoggingServerBootstep(bootsteps.StartStopStep):
# class ZMQLoggingServer(object):
# class Record(object):
# class Formatter(object):


import logging
import logging.handlers
import os
import shutil
import tempfile
import time
import mock
import testtools
        import zmq
from mock import patch
from cloudify import logs
from cloudify.celery import logging_server
        server, _ = self.test_basic()
        handler_cache = server.logging_server._get_handler._cache
        server_handler = handler_cache[(self.HANDLER_CONTEXT,)]
        # type(server_handler) doesn't do the right thing on 2.6
        self.assertEqual(server_handler.__class__, expected_type)

    def test_error_on_processing(self):
        server, logger = self.test_basic()
        for i in range(10):
            logger.handlers[0]._socket.send('Certainly not json')
        good_message = 'some new good message'
        logger.info(good_message)
        self._assert_in_log(good_message)

    def _start_server(self, enable=True, cache_size=10):
        server = logging_server.ZMQLoggingServerBootstep(
            self.worker,
            with_logging_server=enable,
            logging_server_logdir=self.workdir,
            logging_server_handler_cache_size=cache_size)
        self.addCleanup(lambda: server.stop(self.worker))
        server.start(self.worker)
        return server

    def _logger(self, server, handler_context=HANDLER_CONTEXT):
        context = server.logging_server.zmq_context
        socket = context.socket(zmq.PUSH)
        socket.connect(server.socket_url)
        logger = logging.getLogger(handler_context)
        logger.handlers = []

# Path: cloudify/logs.py
# EVENT_CLASS = _event.Event
# EVENT_VERBOSITY_LEVEL = _event.NO_VERBOSE
# def message_context_from_cloudify_context(ctx):
# def message_context_from_workflow_context(ctx):
# def message_context_from_sys_wide_wf_context(ctx):
# def message_context_from_workflow_node_instance_context(ctx):
#     def __init__(self, ctx, out_func, message_context_builder):
#     def flush(self):
#     def emit(self, record):
#     def __init__(self, ctx, out_func=None):
#     def __init__(self, ctx, out_func=None):
#     def __init__(self, ctx, out_func=None):
#     def __init__(self, ctx, out_func=None):
# def init_cloudify_logger(handler, logger_name,
#                          logging_level=logging.DEBUG):
# def send_workflow_event(ctx, event_type,
#                         message=None,
#                         args=None,
#                         additional_context=None,
#                         out_func=None):
# def send_sys_wide_wf_event(ctx, event_type, message=None, args=None,
#                            additional_context=None, out_func=None):
# def send_workflow_node_event(ctx, event_type,
#                              message=None,
#                              args=None,
#                              additional_context=None,
#                              out_func=None):
# def send_plugin_event(ctx,
#                       message=None,
#                       args=None,
#                       additional_context=None,
#                       out_func=None):
# def send_task_event(cloudify_context,
#                     event_type,
#                     message=None,
#                     args=None,
#                     additional_context=None,
#                     out_func=None):
# def _send_event(ctx, context_type, event_type,
#                 message, args, additional_context,
#                 out_func):
# def populate_base_item(item, message_type):
# def amqp_event_out(event):
# def amqp_log_out(log):
# def stdout_event_out(event):
# def stdout_log_out(log):
# def create_event_message_prefix(event):
# def with_amqp_client(func):
#     def wrapper(*args, **kwargs):
# def _publish_message(client, message, message_type, logger):
#     def __init__(self, context, socket, fallback_logger):
#     def emit(self, record):
# class CloudifyBaseLoggingHandler(logging.Handler):
# class CloudifyPluginLoggingHandler(CloudifyBaseLoggingHandler):
# class CloudifyWorkflowLoggingHandler(CloudifyBaseLoggingHandler):
# class SystemWideWorkflowLoggingHandler(CloudifyBaseLoggingHandler):
# class CloudifyWorkflowNodeLoggingHandler(CloudifyBaseLoggingHandler):
# class ZMQLoggingHandler(logging.Handler):
# 
# Path: cloudify/celery/logging_server.py
# LOGFILE_SIZE_BYTES = 5 * 1024 * 1024
# LOGFILE_BACKUP_COUNT = 5
# def configure_app(app):
#     def __init__(self, worker,
#                  with_logging_server=False,
#                  logging_server_logdir=None,
#                  logging_server_handler_cache_size=100,
#                  **kwargs):
#     def info(self, worker):
#     def start(self, worker):
#     def _stop_logging_server(self, worker):
#     def __init__(self, logdir, socket_url, cache_size):
#     def start(self):
#     def close(self):
#     def _process(self, entry):
#     def _get_handler(self, handler_context):
#     def __init__(self, message):
#     def format(record):
# class ZMQLoggingServerBootstep(bootsteps.StartStopStep):
# class ZMQLoggingServer(object):
# class Record(object):
# class Formatter(object):


# Path: cloudify/tests/test_logging_server.py
import logging
import logging.handlers
import os
import shutil
import tempfile
import time
import mock
import testtools
        import zmq
from mock import patch
from cloudify import logs
from cloudify.celery import logging_server

        server, _ = self.test_basic()
        handler_cache = server.logging_server._get_handler._cache
        server_handler = handler_cache[(self.HANDLER_CONTEXT,)]
        # type(server_handler) doesn't do the right thing on 2.6
        self.assertEqual(server_handler.__class__, expected_type)

    def test_error_on_processing(self):
        server, logger = self.test_basic()
        for i in range(10):
            logger.handlers[0]._socket.send('Certainly not json')
        good_message = 'some new good message'
        logger.info(good_message)
        self._assert_in_log(good_message)

    def _start_server(self, enable=True, cache_size=10):
        server = logging_server.ZMQLoggingServerBootstep(
            self.worker,
            with_logging_server=enable,
            logging_server_logdir=self.workdir,
            logging_server_handler_cache_size=cache_size)
        self.addCleanup(lambda: server.stop(self.worker))
        server.start(self.worker)
        return server

    def _logger(self, server, handler_context=HANDLER_CONTEXT):
        context = server.logging_server.zmq_context
        socket = context.socket(zmq.PUSH)
        socket.connect(server.socket_url)
        logger = logging.getLogger(handler_context)
        logger.handlers = []

        handler = logs.ZMQLoggingHandler(handler_context, socket,