Logs

cloudify.logs.message_context_from_cloudify_context(ctx)[source]

Build a message context from a CloudifyContext instance

cloudify.logs.message_context_from_workflow_context(ctx)[source]

Build a message context from a CloudifyWorkflowContext instance

cloudify.logs.message_context_from_workflow_node_instance_context(ctx)[source]

Build a message context from a CloudifyWorkflowNode instance

class cloudify.logs.CloudifyBaseLoggingHandler(ctx, out_func, message_context_builder)[source]

Bases: Handler

A base handler class for writing log messages to RabbitMQ

flush()[source]

Ensure all logging output has been flushed.

This version does nothing and is intended to be implemented by subclasses.

emit(record)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

class cloudify.logs.CloudifyPluginLoggingHandler(ctx, out_func=None)[source]

Bases: CloudifyBaseLoggingHandler

A handler class for writing plugin log messages to RabbitMQ

class cloudify.logs.CloudifyWorkflowLoggingHandler(ctx, out_func=None)[source]

Bases: CloudifyBaseLoggingHandler

A Handler class for writing workflow log messages to RabbitMQ

class cloudify.logs.CloudifyWorkflowNodeLoggingHandler(ctx, out_func=None)[source]

Bases: CloudifyBaseLoggingHandler

A Handler class for writing workflow nodes log messages to RabbitMQ

class cloudify.logs.CloudifyCtxLoggingHandler(ctx)[source]

Bases: Handler

A logging handler for Cloudify’s context logger. A logger attached to this handler will result in logging being passed through to the Cloudify logger. This is useful for plugins that would like to have underlying APIs’ loggers flow through to the Cloudify context logger.

emit(record)[source]

Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.

cloudify.logs.init_cloudify_logger(handler, logger_name, logging_level=10)[source]

Instantiate an amqp backed logger based on the provided handler for sending log messages

Parameters:
  • handler – A logger handler based on the context

  • logger_name – The logger name

  • logging_level – The logging level

Returns:

An amqp backed logger

cloudify.logs.send_workflow_event(ctx, event_type, message=None, args=None, additional_context=None, out_func=None)[source]

Send a workflow event

Parameters:
  • ctx – A CloudifyWorkflowContext instance

  • event_type – The event type

  • message – The message

  • args – additional arguments that may be added to the message

  • additional_context – additional context to be added to the context

cloudify.logs.send_workflow_node_event(ctx, event_type, message=None, args=None, additional_context=None, out_func=None, skip_send=False)[source]

Send a workflow node event

Parameters:
  • ctx – A CloudifyWorkflowNode instance

  • event_type – The event type

  • message – The message

  • args – additional arguments that may be added to the message

  • additional_context – additional context to be added to the context

  • skip_send – Only for internal use - do not send the event to the manager, but log it to the logfile

cloudify.logs.send_plugin_event(ctx, message=None, args=None, additional_context=None, out_func=None)[source]

Send a plugin event to RabbitMQ

Parameters:
  • ctx – A CloudifyContext instance

  • message – The message

  • args – additional arguments that may be added to the message

  • additional_context – additional context to be added to the context

cloudify.logs.send_task_event(cloudify_context, event_type, message=None, args=None, additional_context=None, out_func=None)[source]

Send a task event

Parameters:
  • cloudify_context – a __cloudify_context struct as passed to operations

  • event_type – The event type

  • message – The message

  • args – additional arguments that may be added to the message

  • additional_context – additional context to be added to the context

cloudify.logs.populate_base_item(item, message_type)[source]
cloudify.logs.manager_event_out(event, **kwargs)[source]
cloudify.logs.manager_log_out(log, **kwargs)[source]
cloudify.logs.stdout_event_out(event, **kwargs)[source]
cloudify.logs.stdout_log_out(log, **kwargs)[source]
cloudify.logs.create_event_message_prefix(event, with_worker_names=False)[source]
cloudify.logs.setup_logger_base(log_level, log_dir=None)[source]
cloudify.logs.setup_subprocess_logger()[source]
cloudify.logs.setup_agent_logger(log_name, log_level=None, log_dir=None, max_bytes=None, max_history=None)[source]
class cloudify.logs.ExecutorNameFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]

Bases: Formatter

default_fmt = <logging.Formatter object>
user_fmt = <logging.Formatter object>
format(record)[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.