Setup
Getting started
To use LOGS-Py, first import the module.
from LOGS import LOGS
You can easily create an instance of that object and connect it to a logs server. With this examples script you can check the status of the connection (you need to provide the necessary authentication information, see below).
from LOGS import LOGS
logs = LOGS()
logs.printServerStatus()
The output looks like this (depending on your server setup):
LOGSAPI> Server properties:
LOGSAPI> protocol: https
LOGSAPI> server: yours.logs.com
LOGSAPI> port: None
LOGSAPI> group: yourGroup
Authentication
In order to connect to a LOGS instance, initially you need to specify the URL of the specific LOGS group and an API key to authenticate yourself. You can generate the API via the LOGS UI. There are several ways to provide this information on the initialization of the LOGS instance.
1. Method: provide your credentials directly via the constructor parameters
from LOGS import LOGS
logs = LOGS(url="https://yours.logs.com/yourGroup", apiKey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
Note: replace the url and apiKey with those specific to your environment.
2. Method: Provide your credentials via a json file
If a file named logs.json resides within the execution directory. It will be automatically recognized and you can use an empty constructor.
from LOGS import LOGS
logs = LOGS()
You can also specify a server configuration in another directory.
from LOGS import LOGS
logs = LOGS(configFile="/path/to/config/config.json")
The content of the json file must look like this example
{
"apiKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"url": "https://yours.logs.com/yourGroup"
}