Skip to content

Logs

Logs are an excellent way to keep track of a bot execution and provide insightiful information for operation and monitoring.

BotMaestro offers a very flexible log implementation that is very easy to use and create the log which best fit your use case.

You can create as many custom logs as you desire to better organize your data and manage your automations.

Over the following sections we will show you how to create a log, insert log entries and delete a log.

Important

In the methods below, the automation label parameter will refer to the log label that was created.

You can find more details in the Logs section.

Creating a Log

To create a new Log we need to provide the following information:

  • Automation Label (Log Label)
  • List of Columns

The SDK provides the Columns class which helps to create new entries.

A Column instance holds the following information:

  • name: Text to be displayed on the BotMaestro Web Portal
  • label: Unique Identifier for this column on this log
  • width: Suggested width in pixels.

Here is how we can create a new Log:

# Create a list of columns
columns = [
    Column(name="Date/Time", label="timestamp", width=300),
    Column(name="# Records", label="records", width=200),
    Column(name="Status", label="status", width=100),
]

# Create a new log
maestro.new_log(
    "logLabel",
    columns
)
// Create a list of columns
List<Column> columns = Arrays.asList(
    new Column("Date/Time", "timestamp", 300),
    new Column("# Records", "records", 200),
    new Column("Status", "status", 100)
);

// Create a new log
maestro.newLog("logLabel", columns);
// Create a list of columns
const columns = [
    new Column("Date/Time", "timestamp", 300),
    new Column("# Records", "records", 300),
    new Column("Status", "status", 300),
]

// Create a new log
await maestro.createLog("logLabel", columns);
// Create a list of columns
const columns: Column[] = [
    new Column("Date/Time", "timestamp", 300),
    new Column("# Records", "records", 300),
    new Column("Status", "status", 300),
]

// Create a new log
const log: Log = await maestro.createLog("logLabel", columns);

Creating new Log Entries

With your shiny new log ready, it is time to create some log entries.

Here is how you can insert new log entries:

import datetime

maestro.new_log_entry(
    activity_label="logLabel",
    values = {
        "timestamp": datetime.datetime.now().strftime("%Y-%m-%d_%H-%M"),
        "records": "10",
        "status": "SUCCESS"
    }
)
String timestamp = new SimpleDateFormat("yyyy-MM-dd_HH-mm").format(new java.util.Date());

Map<String,Object> values = new HashMap<>();
values.put("timestamp", timestamp);
values.put("records", "10");
values.put("status", "SUCCESS");

maestro.newLogEntry("logLabel", values);
await maestro.logEntry(
    "logLabel",
    {
        timestamp: new Date().toISOString(),
        records: "10",
        status: "SUCCESS"
    }
)
await maestro.logEntry(
    "logLabel",
    {
        timestamp: new Date().toISOString(),
        records: "10",
        status: "SUCCESS"
    }
)

Fetch Log Data

Retrieving log data is as easy as creating log entries.

The date argument acts as a filter for the initial date for log to be retrieved.

Note

The date parameter must use the DD/MM/YYYY format. If date is not informed, all data from the log is retrieved.

# Get the start date as 30 days ago
instant = (datetime.datetime.now() - datetime.timedelta(days=30))
date = instant.strftime("%d/%m/%Y")

# Get the log data
data = maestro.get_log(activity_label="logLabel", date=date)
// Get the log data
List<Row> data = maestro.getLog("logLabel", 30);
const data = await maestro.fetchDataLog("logLabel", 30)
const data: DataLog[] = await maestro.fetchDataLog("logLabel", 30)

Downloading as CSV

Roadmap

Not yet available.

// Define filter days to search
int days = 30;

// Define the path to save the file
File logFile = new File("<path to save>/log.csv");

// Retrieve the log data
byte[] data = maestro.getLogFile("logLabel", days);

// Save it to disk
Files.write(data, logFile);
// Define the path to save the file
const filepath = "log.csv"

// Define filter days to search
const days = 30

const data = await maestro("logLabel", filepath, days)
// Define the path to save the file
const filepath: string = "log.csv"

// Define filter days to search
const days: number = 30

const data: Buffer = await maestro("logLabel", filepath, days)

Deleting an Entire Log

If by any reason you need to completely remove the log along with all its entries, you can do so using the command below.

Warning

This operation will erase ALL log history, and it cannot be reverted.

maestro.delete_log(activity_label="logLabel")
maestro.deleteLog("logLabel");
await maestro.deleteLog("logLabel")
await maestro.deleteLog("logLabel")