Skip to content

Logs

The Execution Log is a very powerful way to record outputs, track execution and collect metrics from your automation. In this section you will find how to manipulate Logs via SDK.

BotCity Orchestrator

You can also make use of the Execution Log functionality directly on the BotCity Orchestrator platform.

See more at:

Create a log

You can create a custom Log to collect task execution data.

To create a new Log, you need the following information:

  • Label: unique identifier of the Log to be created.
  • Columns: List of columns that make up the Log, defined with the Column class:
    • name: Friendly name displayed in the BotCity Orchestrator.
    • label: Unique identifier for this column in the Log.
    • width: (optional) Suggested width in pixels.

Attention!

The SDK provides the Column class that helps create the list of Log columns.

See an example of Log creation:

# Create a list of columns
columns = [
    Column(name="# Records", label="records"),
    Column(name="Status", label="status"),
]

# Create a new log
maestro.new_log(
    activity_label="logLabel",
    columns=columns
)
// Create a list of columns
List<Column> columns = Arrays.asList(
    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("# 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("# Records", "records", 300),
    new Column("Status", "status", 300),
]

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

// Create a list of columns
List<Column> columns = new List<Column>
{
    new Column("# Records", "records", 200),
    new Column("Status", "status", 100)
};

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

Create Log entries

With the Log created, each Log entry records a new row with data collected by the automation.

To create a Log entry, you need the following information:

  • Label: unique identifier of the already created Log.
  • Values: key (column label) and value based on the created columns.

See an example of a Log entry:

maestro.new_log_entry(
    activity_label="logLabel",
    values = {
        "records": "10",
        "status": "SUCCESS"
    }
)
Map<String,Object> values = new HashMap<String,Object>();
values.put("records","10");
values.put("status","SUCCESS");

maestro.newLogEntry("logLabel", columns);
await maestro.logEntry(
    "logLabel",
    {
        records: "10",
        status: "SUCCESS"
    }
)
await maestro.logEntry(
    "logLabel",
    {
        records: "10",
        status: "SUCCESS"
    }
)
var newEntry = new Dictionary<string, object>
{
    { "records", "10"},
    { "status", "SUCCESS" },
};

await maestro.NewLogEntryAsync("logLabel", newEntry);

What types of values are accepted?

Logs record output information for execution monitoring. Therefore, the values passed to each column must be JSON serializable objects.

For sending more complex data, see the option: Result files.

Fetch Log data

You can return log records filtered by date.

To fetch a Log, you need the following information:

  • Label: unique identifier of the already created Log.
  • Date: start date to filter the records search.

Date Filter

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

See the implementation example:

# 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 start date as 30 days ago
Instant instant = Instant.now().minus(30, ChronoUnit.DAYS);
Date date = Date.from(instant);

// Retrieve the log data
List<Row> data = maestro.getLog("logLabel", date);
const data = await maestro.fetchDataLog("logLabel", 30)
const data: DataLog[] = await maestro.fetchDataLog("logLabel", 30)
DateTime now = DateTime.Now;
DateTime pastDate = now.AddDays(-30);
string formattedDate = pastDate.ToString("dd/MM/yyyy");

// Get the log data
List<Entry> entries = await maestro.GetLogAsync("logLabel", DateTime.Now);

Download as CSV

You can return Log records and save them as a .CSV file.

See the example:

# Not yet implemented
// Define filter days to search
int days = 30;

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

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

// Save 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)
// Not yet implemented

Delete an entire Log

You can delete an entire Log along with all its records irreversibly.

Attention!

This operation will delete the ENTIRE Log record history and cannot be undone.

See an example of how to delete the Log:

maestro.delete_log(activity_label="logLabel")

Roadmap

Not yet available.

await maestro.deleteLog("logLabel")
await maestro.deleteLog("logLabel")
await maestro.DeleteLogAsync("logLabel");