osbrain.logging — osBrain logging logic

Implementation of logging-related features.

class osbrain.logging.Logger(name=None, host=None)

Bases: osbrain.core.Agent

Specialized Agent for logging. Binds a SUB socket and starts logging incoming messages.

Methods

addr(alias)
Parameters:
bind(kind[, alias, handler, host, port]) Bind to an agent address.
connect(server_address[, alias, handler]) Connect to a server agent address.
each(period, method, *args, **kwargs) Execute a repeated action with a defined period.
handle_loopback(message) Handle incoming messages in the loopback socket.
iddle() This function is to be executed when the agent is iddle.
iterate() Agent’s main iteration.
log_debug(message[, logger]) Log a debug message.
log_error(message[, logger]) Log an error message.
log_handler(message, topic) Handle incoming log messages.
log_info(message[, logger]) Log an info message.
log_warning(message[, logger]) Log a warning message.
loop() Agent’s main loop.
loopback(header[, data]) Send a message to the loopback socket.
on_init() This user-defined method is to be executed after initialization.
ping() A simple ping method testing purposes.
raise_exception() Raise an exception (for testing purposes).
run() Run the agent.
safe(method, *args, **kwargs) A safe call to a method.
safe_ping() A simple loopback ping for testing purposes.
set_attr(**kwargs) Set object attributes.
set_logger(logger[, alias]) Connect the agent to a logger and start logging messages to it.
set_loop(loop)
set_method(*args, **kwargs) Set object methods.
stop() Stop the agent.
subscribe(alias, handlers) Subscribe the agent to another agent.
test() A test method to check the readiness of the agent.
close_sockets  
execute  
get_attr  
kill  
recv  
register  
registered  
self_execute  
send  
send_recv  
set_handler  
shutdown  
str2bytes  
log_handler(message, topic)

Handle incoming log messages.

on_init()

This user-defined method is to be executed after initialization.

osbrain.logging.pyro_log()

Set environment variables to activate Pyro logging. The log level is set to “DEBUG”.

osbrain.logging.run_logger(name, nsaddr=None, addr=None, base=<class 'osbrain.logging.Logger'>)

Ease the logger creation process.

This function will create a new logger, start the process and then run its main loop through a proxy.

Parameters:
name : str

Logger name or alias.

nsaddr : SocketAddress, default is None

Name server address.

addr : SocketAddress, default is None

New logger address, if it is to be fixed.

Returns:
proxy

A proxy to the new logger.