osbrain.logging — osBrain logging logic¶
Implementation of logging-related features.
-
class
osbrain.logging.Logger(name=None, host=None, serializer=None, transport=None, attributes=None)¶ Bases:
osbrain.agent.AgentSpecialized Agent for logging. Binds a
SUBsocket and starts logging incoming messages.Methods
addr(alias)Return the address of a socket given by its alias. after(delay, method, *args[, alias])Execute an action after a delay. bind(kind[, alias, handler, addr, …])Bind to an agent address. close(alias)Close a socket given its alias and clear its entry from the Agent.socketdictionary.close_all()Close all non-internal zmq sockets. connect(server[, alias, handler])Connect to a server agent address. each(period, method, *args[, alias])Execute a repeated action with a defined period. execute_as_function(function, *args, **kwargs)Execute a function passed as parameter. execute_as_method(function, *args, **kwargs)Execute a function as a method, without adding it to the set of agent methods. get_attr(name)Return the specified attribute of the agent. get_unique_external_zmq_sockets()Return an iterable containing all the zmq.Socket objects from self.socketwhich are not internal, without repetition.has_socket(alias)Return whether the agent has the passed socket internally stored. idle()This function is to be executed when the agent is idle. iterate()Agent’s main iteration. list_timers()Return a list with all timer aliases currently running. 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. on_init()This user-defined method is to be executed after initialization. ping()A test method to check the readiness of the agent. raise_exception()Raise an exception (for testing purposes). recv(address)Receive a message from the specified address. run()Run the agent. safe_call(method, *args, **kwargs)A safe call to a method. send(address, message[, topic, handler, …])Send a message through the specified address. send_recv(address, message)This method is only used in REQREP communication patterns. set_attr(**kwargs)Set object attributes. set_logger(logger[, alias])Connect the agent to a logger and start logging messages to it. set_method(*args, **kwargs)Set object methods. stop()Stop the agent. stop_all_timers()Stop all currently running timers. stop_timer(alias)Stop a currently running timer. kill register registered shutdown -
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.