# 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
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
#    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    * See the License for the specific language governing permissions and
#    * limitations under the License.





class TestLoggingServer(testtools.TestCase):

    HANDLER_CONTEXT = 'logger'

    def setUp(self):
        self.worker = mock.Mock()
        super(TestLoggingServer, self).setUp()
        self.workdir = tempfile.mkdtemp(prefix='cloudify-logging-server-')
        self.addCleanup(lambda: shutil.rmtree(self.workdir,
                                              ignore_errors=True))

    def test_basic(self):
        message = 'MESSAGE TEXT'
        server = self._start_server()

# 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

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
#    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    * See the License for the specific language governing permissions and
#    * limitations under the License.





class TestLoggingServer(testtools.TestCase):

    HANDLER_CONTEXT = 'logger'

    def setUp(self):
        self.worker = mock.Mock()
        super(TestLoggingServer, self).setUp()
        self.workdir = tempfile.mkdtemp(prefix='cloudify-logging-server-')
        self.addCleanup(lambda: shutil.rmtree(self.workdir,
                                              ignore_errors=True))

    def test_basic(self):
        message = 'MESSAGE TEXT'
        server = self._start_server()

        self.assertEqual(server, self.worker.logging_server)