Skip to main content

OperationLogOperations

Operations

Reads the recorded history of what happened in the application. It lists actions a page at a time, reports what the history can and cannot say about itself, and writes it to a file. It is read only: there is no way through this service to delete, clear, edit or rewrite anything the application recorded. Calls made through this service are not themselves recorded. Reading the history is not one of the things the history is about, and a call that recorded itself would change the answer to the next one. A listing is a snapshot taken when it is opened, so its pages agree with one another. Actions recorded afterwards are not in it and hasNewerActions() reports that. A listing is closed by close_listing(), by opening another one, or when the open project is replaced, and a call against a listing that is no longer valid raises rather than returning a wrong page.

Import​

import ScriptingApi as api

# Access via Application
app = api.Application()
ops = app.get_operation_log_operations()

Methods​

Properties​

get_status​

Reports what the recorded history can and cannot say about itself.

Signature:

get_status() -> LogStatus

Returns: LogStatus — The status as api.LogStatus. Raises an error if there is no history in this process.


open_listing​

Opens a listing over one recorded history, narrowed by one filter. The history is read and narrowed once here, so paging the result afterwards is cheap. Opening a listing closes any listing that was already open, including when this call raises, so a caller that retries with a narrower filter opens a new listing rather than returning to the previous token.

Signature:

open_listing(source: LogSource = api.LogSource.ProjectHistory, filter: LogFilter = LogFilter()) -> LogListing

Parameters:

ParameterTypeDescription
sourceLogSourceWhich recorded history to list. Use api.LogSource values.
filterLogFilterHow to narrow it. Create using api.LogFilter(); its defaults narrow to the same view the Operation Log panel opens with.

Returns: LogListing — The listing as api.LogListing. Raises an error if the filter matches more actions than one listing holds, in which case the message says how many it matched.


list_actions​

Reads one page of an open listing.

Signature:

list_actions(token: str, offset: int = 0, count: int = 100) -> list

Parameters:

ParameterTypeDescription
tokenstrThe token of the open listing, from api.LogListing.token.
offsetintThe first action of the page, counted from zero.
countintHow many actions to read. A larger request is served at the supported maximum and the caller continues from the next offset.

Returns: list — The page as a list of api.LogEntry, empty past the end of the listing. Raises an error if the listing is no longer valid.


has_newer_actions​

Reports whether actions were recorded after the listing was opened.

Signature:

has_newer_actions(token: str) -> bool

Parameters:

ParameterTypeDescription
tokenstrThe token of the open listing.

Returns: bool — True when the history has moved on, so reopening the listing would show more. Raises an error if the listing is no longer valid.


close_listing​

Closes a listing and releases what it was holding.

Signature:

close_listing(token: str) -> None

Parameters:

ParameterTypeDescription
tokenstrThe token of the listing. An unknown token closes nothing.

File System​

export_to_disk​

Writes a whole recorded history to a file. The file states which history it holds and whether anything is missing from it.

Signature:

export_to_disk(source: LogSource, format: LogExportFormat, filePath: str) -> bool

Parameters:

ParameterTypeDescription
sourceLogSourceWhich recorded history to write. Use api.LogSource values.
formatLogExportFormatWhich file to write. Use api.LogExportFormat values.
filePathstrThe full path of the file to write.

Returns: bool — True when the file was written. Raises an error with the reason when it was not.


export_listing_to_disk​

Writes the actions of an open listing to a file.

Signature:

export_listing_to_disk(token: str, format: LogExportFormat, filePath: str) -> bool

Parameters:

ParameterTypeDescription
tokenstrThe token of the open listing.
formatLogExportFormatWhich file to write. Use api.LogExportFormat values.
filePathstrThe full path of the file to write.

Returns: bool — True when the file was written. Raises an error with the reason when it was not, including the case where a listed action is no longer held by the history it came from, which refuses the whole export rather than writing a file that is quietly missing it.


See Also​