AgentOps logger
The AgentOps logger is quick and simple way of integrating your existing agent codebase with AgentOps. It allows you to use your current logs as events by extending the built-in Python logging system to emit events to AgentOps. There are main ways of using it:- Initializing a new Logger with AgentOps functionality
- Adding a log handler to your existing Logger
python
Initializing a new Logger
If you don’t already have a logger or want to simply initialize your logger via AgentOps, do the following: We can initilize a new logger with the following:python
get_agentops_logger
also takes the optional parameter of level
to limit
the amount of logs that get sent to AgentOps.
Adding a log handler
If you already have complex set ups for your logging and you find it more convinient, you can get a log handler from Agent Ops and attach it to your existing logger Then we can initilize a new logger with the clientpython
Details
The AgentOpsLogger class is a utility class for creating loggers and handlers configured to work with the AgentOps service.python
- client (Client): The AgentOps client to which the logs will be sent.
- name (str): The name for the logger and handler.
- level (int, optional): The minimum severity level to log. Defaults to logging.DEBUG.
- A logger (logging.Logger) configured with an AgentOpsHandler.
python
- client (Client): The AgentOps client to which the logs will be sent.
- name (str): The name for the handler.
- A new AgentOpsHandler with the given client and name.
- client (Client): The AgentOps client to which the logs will be sent.
- name (str): The name for this handler.
python
- s (str): The string from which color codes will be removed.
python
- record (logging.LogRecord): The log record to process.