osbrain.logging — osBrain logging logic¶
Implementation of logging-related features.
-
class
osbrain.logging.Logger(name='', 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. before_loop()This user-defined method is to be executed right before the main loop. 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. 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. is_running()Returns a boolean indicating whether the agent is running or not. kill()Force shutdown of the agent. 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. on_init()Initialize attributes. 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()Start the main loop. 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. shutdown()Cleanly stop and shut down the agent. stop()Stop the agent. stop_all_timers()Stop all currently running timers. stop_timer(alias)Stop a currently running timer. subscribe(alias, handler, str], Any])Subscribe a SUB/SYNC_SUB socket given by its alias to the given topics, and leave the handlers prepared internally. unsubscribe(alias, topic, str])Unsubscribe a SUB/SYNC_SUB socket given by its alias from a given specific topic, and delete its entry from the handlers dictionary. -
log_handler(message, topic)¶ Handle incoming log messages.
-
on_init()¶ Initialize attributes.
-
-
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.