robot.output package

Package for internal logging and other output.

Not part of the public API, and also subject to change in the future when test execution is refactored.

Submodules

robot.output.debugfile module

robot.output.debugfile.DebugFile(path)[source]

robot.output.filelogger module

class robot.output.filelogger.FileLogger(path, level)[source]

Bases: robot.output.loggerhelper.AbstractLogger

message(msg)[source]
start_suite(suite)[source]
end_suite(suite)[source]
start_test(test)[source]
end_test(test)[source]
start_keyword(kw)[source]
end_keyword(kw)[source]
output_file(name, path)[source]
close()[source]
debug(msg)
error(msg)
fail(msg)
info(msg)
set_level(level)
skip(msg)
trace(msg)
warn(msg)
write(message, level, html=False)

robot.output.librarylogger module

Implementation of the public logging API for libraries.

This is exposed via robot.api.logger. Implementation must reside here to avoid cyclic imports.

robot.output.librarylogger.write(msg, level, html=False)[source]
robot.output.librarylogger.trace(msg, html=False)[source]
robot.output.librarylogger.debug(msg, html=False)[source]
robot.output.librarylogger.info(msg, html=False, also_console=False)[source]
robot.output.librarylogger.warn(msg, html=False)[source]
robot.output.librarylogger.error(msg, html=False)[source]
robot.output.librarylogger.console(msg, newline=True, stream='stdout')[source]

robot.output.listenerarguments module

class robot.output.listenerarguments.ListenerArguments(arguments)[source]

Bases: object

get_arguments(version)[source]
classmethod by_method_name(name, arguments)[source]
class robot.output.listenerarguments.MessageArguments(arguments)[source]

Bases: robot.output.listenerarguments.ListenerArguments

classmethod by_method_name(name, arguments)
get_arguments(version)
class robot.output.listenerarguments.StartSuiteArguments(arguments)[source]

Bases: robot.output.listenerarguments._ListenerArgumentsFromItem

classmethod by_method_name(name, arguments)
get_arguments(version)
class robot.output.listenerarguments.EndSuiteArguments(arguments)[source]

Bases: robot.output.listenerarguments.StartSuiteArguments

classmethod by_method_name(name, arguments)
get_arguments(version)
class robot.output.listenerarguments.StartTestArguments(arguments)[source]

Bases: robot.output.listenerarguments._ListenerArgumentsFromItem

classmethod by_method_name(name, arguments)
get_arguments(version)
class robot.output.listenerarguments.EndTestArguments(arguments)[source]

Bases: robot.output.listenerarguments.StartTestArguments

classmethod by_method_name(name, arguments)
get_arguments(version)
class robot.output.listenerarguments.StartKeywordArguments(arguments)[source]

Bases: robot.output.listenerarguments._ListenerArgumentsFromItem

classmethod by_method_name(name, arguments)
get_arguments(version)
class robot.output.listenerarguments.EndKeywordArguments(arguments)[source]

Bases: robot.output.listenerarguments.StartKeywordArguments

classmethod by_method_name(name, arguments)
get_arguments(version)

robot.output.listenermethods module

class robot.output.listenermethods.ListenerMethods(method_name, listeners)[source]

Bases: object

class robot.output.listenermethods.LibraryListenerMethods(method_name)[source]

Bases: object

new_suite_scope()[source]
discard_suite_scope()[source]
register(listeners, library)[source]
unregister(library)[source]
class robot.output.listenermethods.ListenerMethod(method, listener, library=None)[source]

Bases: object

called = False

robot.output.listeners module

class robot.output.listeners.Listeners(listeners, log_level='INFO')[source]

Bases: object

set_log_level(level)[source]
start_keyword(kw)[source]
end_keyword(kw)[source]
log_message(msg)[source]
imported(import_type, name, attrs)[source]
output_file(file_type, path)[source]
class robot.output.listeners.LibraryListeners(log_level='INFO')[source]

Bases: object

register(listeners, library)[source]
unregister(library, close=False)[source]
new_suite_scope()[source]
discard_suite_scope()[source]
set_log_level(level)[source]
log_message(msg)[source]
imported(import_type, name, attrs)[source]
output_file(file_type, path)[source]
class robot.output.listeners.ListenerProxy(listener, method_names, prefix=None)[source]

Bases: robot.output.loggerhelper.AbstractLoggerProxy

classmethod import_listeners(listeners, method_names, prefix=None, raise_on_error=False)[source]

robot.output.logger module

class robot.output.logger.Logger(register_console_logger=True)[source]

Bases: robot.output.loggerhelper.AbstractLogger

A global logger proxy to delegating messages to registered loggers.

Whenever something is written to LOGGER in code, all registered loggers are notified. Messages are also cached and cached messages written to new loggers when they are registered.

NOTE: This API is likely to change in future versions.

start_loggers
end_loggers
register_console_logger(type='verbose', width=78, colors='AUTO', markers='AUTO', stdout=None, stderr=None)[source]
unregister_console_logger()[source]
register_syslog(path=None, level='INFO')[source]
register_xml_logger(logger)[source]
unregister_xml_logger()[source]
register_listeners(listeners, library_listeners)[source]
register_logger(*loggers)[source]
unregister_logger(*loggers)[source]
disable_message_cache()[source]
register_error_listener(listener)[source]
message(msg)[source]

Messages about what the framework is doing, warnings, errors, …

cache_only
delayed_logging
log_message(msg)

Messages about what the framework is doing, warnings, errors, …

log_output(output)[source]
enable_library_import_logging()[source]
disable_library_import_logging()[source]
start_suite(suite)[source]
end_suite(suite)[source]
start_test(test)[source]
end_test(test)[source]
start_keyword(keyword)[source]
end_keyword(keyword)[source]
imported(import_type, name, **attrs)[source]
output_file(file_type, path)[source]

Finished output, report, log, debug, or xunit file

close()[source]
debug(msg)
error(msg)
fail(msg)
info(msg)
set_level(level)
skip(msg)
trace(msg)
warn(msg)
write(message, level, html=False)
class robot.output.logger.LoggerProxy(logger, method_names=None, prefix=None)[source]

Bases: robot.output.loggerhelper.AbstractLoggerProxy

start_keyword(kw)[source]
end_keyword(kw)[source]

robot.output.loggerhelper module

class robot.output.loggerhelper.AbstractLogger(level='TRACE')[source]

Bases: object

set_level(level)[source]
trace(msg)[source]
debug(msg)[source]
info(msg)[source]
warn(msg)[source]
fail(msg)[source]
skip(msg)[source]
error(msg)[source]
write(message, level, html=False)[source]
message(msg)[source]
class robot.output.loggerhelper.Message(message, level='INFO', html=False, timestamp=None)[source]

Bases: robot.model.message.Message

message
resolve_delayed_message()[source]
BREAK = 'BREAK'
CONTINUE = 'CONTINUE'
ELSE = 'ELSE'
ELSE_IF = 'ELSE IF'
EXCEPT = 'EXCEPT'
FINALLY = 'FINALLY'
FOR = 'FOR'
IF = 'IF'
IF_ELSE_ROOT = 'IF/ELSE ROOT'
ITERATION = 'ITERATION'
KEYWORD = 'KEYWORD'
MESSAGE = 'MESSAGE'
RETURN = 'RETURN'
SETUP = 'SETUP'
TEARDOWN = 'TEARDOWN'
TRY = 'TRY'
TRY_EXCEPT_ROOT = 'TRY/EXCEPT ROOT'
WHILE = 'WHILE'
config(**attributes)

Configure model object with given attributes.

obj.config(name='Example', doc='Something') is equivalent to setting obj.name = 'Example' and obj.doc = 'Something'.

New in Robot Framework 4.0.

copy(**attributes)

Return shallow copy of this object.

Parameters:attributes – Attributes to be set for the returned copy automatically. For example, test.copy(name='New name').

See also deepcopy(). The difference between these two is the same as with the standard copy.copy and copy.deepcopy functions that these methods also use internally.

deepcopy(**attributes)

Return deep copy of this object.

Parameters:attributes – Attributes to be set for the returned copy automatically. For example, test.deepcopy(name='New name').

See also copy(). The difference between these two is the same as with the standard copy.copy and copy.deepcopy functions that these methods also use internally.

has_setup
has_teardown
html
html_message

Returns the message content as HTML.

id

Item id in format like s1-t3-k1.

See TestSuite.id for more information.

level
parent
repr_args = ('message', 'level')
timestamp
type = 'MESSAGE'
visit(visitor)[source]

Visitor interface entry-point.

class robot.output.loggerhelper.IsLogged(level)[source]

Bases: object

set_level(level)[source]
class robot.output.loggerhelper.AbstractLoggerProxy(logger, method_names=None, prefix=None)[source]

Bases: object

robot.output.output module

class robot.output.output.Output(settings)[source]

Bases: robot.output.loggerhelper.AbstractLogger

register_error_listener(listener)[source]
close(result)[source]
start_suite(suite)[source]
end_suite(suite)[source]
start_test(test)[source]
end_test(test)[source]
start_keyword(kw)[source]
end_keyword(kw)[source]
message(msg)[source]
set_log_level(level)[source]
debug(msg)
error(msg)
fail(msg)
info(msg)
set_level(level)
skip(msg)
trace(msg)
warn(msg)
write(message, level, html=False)

robot.output.pyloggingconf module

robot.output.pyloggingconf.robot_handler_enabled(level)[source]
robot.output.pyloggingconf.set_level(level)[source]
class robot.output.pyloggingconf.RobotHandler(level=0, library_logger=<module 'robot.output.librarylogger' from '/home/docs/checkouts/readthedocs.org/user_builds/robot-framework/checkouts/v5.0.1/src/robot/output/librarylogger.py'>)[source]

Bases: logging.Handler

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.

acquire()

Acquire the I/O thread lock.

addFilter(filter)

Add the specified filter to this handler.

close()

Tidy up any resources used by the handler.

This version removes the handler from an internal map of handlers, _handlers, which is used for handler lookup by name. Subclasses should ensure that this gets called from overridden close() methods.

createLock()

Acquire a thread lock for serializing access to the underlying I/O.

filter(record)

Determine if a record is loggable by consulting all the filters.

The default is to allow the record to be logged; any filter can veto this and the record is then dropped. Returns a zero value if a record is to be dropped, else non-zero.

Changed in version 3.2: Allow filters to be just callables.

flush()

Ensure all logging output has been flushed.

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

format(record)

Format the specified record.

If a formatter is set, use it. Otherwise, use the default formatter for the module.

get_name()
handle(record)

Conditionally emit the specified logging record.

Emission depends on filters which may have been added to the handler. Wrap the actual emission of the record with acquisition/release of the I/O thread lock. Returns whether the filter passed the record for emission.

handleError(record)

Handle errors which occur during an emit() call.

This method should be called from handlers when an exception is encountered during an emit() call. If raiseExceptions is false, exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom handler if you wish. The record which was being processed is passed in to this method.

name
release()

Release the I/O thread lock.

removeFilter(filter)

Remove the specified filter from this handler.

setFormatter(fmt)

Set the formatter for this handler.

setLevel(level)

Set the logging level of this handler. level must be an int or a str.

set_name(name)

robot.output.stdoutlogsplitter module

class robot.output.stdoutlogsplitter.StdoutLogSplitter(output)[source]

Bases: object

Splits messages logged through stdout (or stderr) into Message objects

robot.output.xmllogger module

class robot.output.xmllogger.XmlLogger(path, log_level='TRACE', rpa=False, generator='Robot')[source]

Bases: robot.result.visitor.ResultVisitor

close()[source]
set_log_level(level)[source]
message(msg)[source]
log_message(msg)[source]
start_keyword(kw)[source]

Called when a keyword starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_keyword(kw)[source]

Called when a keyword ends.

By default, calls end_body_item() which, by default, does nothing.

start_if(if_)[source]

Called when an IF/ELSE structure starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_if(if_)[source]

Called when an IF/ELSE structure ends.

By default, calls end_body_item() which, by default, does nothing.

start_if_branch(branch)[source]

Called when an IF/ELSE branch starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_if_branch(branch)[source]

Called when an IF/ELSE branch ends.

By default, calls end_body_item() which, by default, does nothing.

start_for(for_)[source]

Called when a FOR loop starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_for(for_)[source]

Called when a FOR loop ends.

By default, calls end_body_item() which, by default, does nothing.

start_for_iteration(iteration)[source]

Called when a FOR loop iteration starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_for_iteration(iteration)[source]

Called when a FOR loop iteration ends.

By default, calls end_body_item() which, by default, does nothing.

start_try(root)[source]

Called when a TRY/EXCEPT structure starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_try(root)[source]

Called when a TRY/EXCEPT structure ends.

By default, calls end_body_item() which, by default, does nothing.

start_try_branch(branch)[source]

Called when TRY, EXCEPT, ELSE or FINALLY branches start.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_try_branch(branch)[source]

Called when TRY, EXCEPT, ELSE and FINALLY branches end.

By default, calls end_body_item() which, by default, does nothing.

start_while(while_)[source]

Called when a WHILE loop starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_while(while_)[source]

Called when a WHILE loop ends.

By default, calls end_body_item() which, by default, does nothing.

start_while_iteration(iteration)[source]

Called when a WHILE loop iteration starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_while_iteration(iteration)[source]

Called when a WHILE loop iteration ends.

By default, calls end_body_item() which, by default, does nothing.

start_return(return_)[source]

Called when a RETURN element starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_return(return_)[source]

Called when a RETURN element ends.

By default, calls end_body_item() which, by default, does nothing.

start_continue(continue_)[source]

Called when a CONTINUE element starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_continue(continue_)[source]

Called when a CONTINUE element ends.

By default, calls end_body_item() which, by default, does nothing.

start_break(break_)[source]

Called when a BREAK element starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

end_break(break_)[source]

Called when a BREAK element ends.

By default, calls end_body_item() which, by default, does nothing.

start_test(test)[source]

Called when a test starts. Default implementation does nothing.

Can return explicit False to stop visiting.

end_test(test)[source]

Called when a test ends. Default implementation does nothing.

start_suite(suite)[source]

Called when a suite starts. Default implementation does nothing.

Can return explicit False to stop visiting.

end_suite(suite)[source]

Called when a suite ends. Default implementation does nothing.

start_statistics(stats)[source]
end_statistics(stats)[source]
start_total_statistics(total_stats)[source]
end_total_statistics(total_stats)[source]
start_tag_statistics(tag_stats)[source]
end_tag_statistics(tag_stats)[source]
start_suite_statistics(tag_stats)[source]
end_suite_statistics(tag_stats)[source]
visit_stat(stat)[source]
start_errors(errors=None)[source]
end_errors(errors=None)[source]
end_body_item(item)

Called, by default, when keywords, messages or control structures end.

More specific end_keyword(), end_message(), :meth:`end_for, etc. can be implemented to visit only keywords, messages or specific control structures.

Default implementation does nothing.

end_message(msg)

Called when a message ends.

By default, calls end_body_item() which, by default, does nothing.

end_result(result)
end_stat(stat)
start_body_item(item)

Called, by default, when keywords, messages or control structures start.

More specific start_keyword(), start_message(), :meth:`start_for, etc. can be implemented to visit only keywords, messages or specific control structures.

Can return explicit False to stop visiting. Default implementation does nothing.

start_message(msg)

Called when a message starts.

By default, calls start_body_item() which, by default, does nothing.

Can return explicit False to stop visiting.

start_result(result)
start_stat(stat)
visit_break(break_)

Visits BREAK elements.

visit_continue(continue_)

Visits CONTINUE elements.

visit_errors(errors)
visit_for(for_)

Implements traversing through FOR loops.

Can be overridden to allow modifying the passed in for_ without calling start_for() or end_for() nor visiting body.

visit_for_iteration(iteration)

Implements traversing through single FOR loop iteration.

This is only used with the result side model because on the running side there are no iterations.

Can be overridden to allow modifying the passed in iteration without calling start_for_iteration() or end_for_iteration() nor visiting body.

visit_if(if_)

Implements traversing through IF/ELSE structures.

Notice that if_ does not have any data directly. Actual IF/ELSE branches are in its body and visited using visit_if_branch().

Can be overridden to allow modifying the passed in if_ without calling start_if() or end_if() nor visiting branches.

visit_if_branch(branch)

Implements traversing through single IF/ELSE branch.

Can be overridden to allow modifying the passed in branch without calling start_if_branch() or end_if_branch() nor visiting body.

visit_keyword(kw)

Implements traversing through keywords.

Can be overridden to allow modifying the passed in kw without calling start_keyword() or end_keyword() nor visiting the body of the keyword

visit_message(msg)

Implements visiting messages.

Can be overridden to allow modifying the passed in msg without calling start_message() or end_message().

visit_result(result)
visit_return(return_)

Visits a RETURN elements.

visit_statistics(stats)
visit_suite(suite)

Implements traversing through suites.

Can be overridden to allow modifying the passed in suite without calling start_suite() or end_suite() nor visiting child suites, tests or setup and teardown at all.

visit_suite_statistics(stats)
visit_tag_statistics(stats)
visit_test(test)

Implements traversing through tests.

Can be overridden to allow modifying the passed in test without calling start_test() or end_test() nor visiting the body of the test.

visit_total_statistics(stats)
visit_try(try_)

Implements traversing through TRY/EXCEPT structures.

This method is used with the TRY/EXCEPT root element. Actual TRY, EXCEPT, ELSE and FINALLY branches are visited separately using visit_try_branch().

visit_try_branch(branch)

Visits individual TRY, EXCEPT, ELSE and FINALLY branches.

visit_while(while_)

Implements traversing through WHILE loops.

Can be overridden to allow modifying the passed in while_ without calling start_while() or end_while() nor visiting body.

visit_while_iteration(iteration)

Implements traversing through single WHILE loop iteration.

This is only used with the result side model because on the running side there are no iterations.

Can be overridden to allow modifying the passed in iteration without calling start_while_iteration() or end_while_iteration() nor visiting body.