skipcheck

TM1 client · Docs · The server

LogService

from skipcheck_tm1.services import LogService

Used in the walkthrough Run a process and read its result.

The server's logs: the message log, the transaction log (cell changes), the audit log (changes to objects and security), and the error logs processes write.

What TM1 (11.8) does here that you might not expect:

  • An entry's ID numbers it within the response, not in the log: the same entry gets another ID in the next request, and TM1 refuses to fetch an entry by its ID (501, "Indexing of message log entries is not supported"). So there's no get by ID here.
  • A message log entry without a time, such as the log's first line, has the TimeStamp 0000-00-00T00:00Z; it's read as None.
  • The transaction and audit logs only fill when they're switched on (a cube's logging, and AuditLog in the configuration).

Read the newest message log entries:

# The 50 newest entries, newest first
return tm1.logs.message_log(True, ODataQuery.none().top(50))

Follow the message log for errors:

# Errors as they're written, until the caller stops iterating; a poll every 5 s
for entry in tm1.logs.tail_message_log(5):
    if entry.level is LogLevel.ERROR:
        yield f"{entry.logger}: {entry.message}"

Read a process's error logs:

# What each error log of one process says
files = [file.filename for file in tm1.logs.error_log_files() if file.filename and file.filename.endswith("_Load Sales.log")]
return [tm1.logs.error_log_content(filename) for filename in files]

Count the cell changes in the transaction log:

# How many cell changes the transaction log holds, leaving out its status lines
return len(tm1.logs.transaction_log(False, True))

The asyncio flavor, skipcheck_tm1.aio, has the same methods to await, on AsyncLogService.

Members

message_log_entriesGET MessageLogEntries, oldest first unless ordered otherwise; filter on Level or TimeStamp.
message_logThe message log, newest first if reverse.
transaction_log_entriesGET TransactionLogEntries.
transaction_logThe transaction log, newest first if reverse, without status lines if ignore_status_messages.
audit_log_entriesGET AuditLogEntries; empty unless the audit log is on.
tail_message_logFollows the message log.
tail_transaction_logFollows the transaction log, as tail_message_log does the message log.
tail_audit_logFollows the audit log, as tail_message_log does the message log.
error_log_filesThe error logs processes have written, such as tm1processerror_<time>_<process>.log.
error_log_fileGET ErrorLogFiles('name'); a Tm1NotFoundError if there's none.
error_log_contentWhat the file says, as text, read whole.

message_log_entries

message_log_entries(query: ODataQuery | None = None, **options: Any) -> list[MessageLogEntry]

GET MessageLogEntries, oldest first unless ordered otherwise; filter on Level or TimeStamp.

TM1 REST EntitySet MessageLogEntries

message_log

message_log(reverse: bool, query: ODataQuery | None = None, **options: Any) -> list[MessageLogEntry]

MessageLog(Reverse=…): the message log, newest first if reverse.

TM1 REST FunctionImport MessageLog

transaction_log_entries

transaction_log_entries(query: ODataQuery | None = None, **options: Any) -> list[TransactionLogEntry]

GET TransactionLogEntries. Besides cell changes, the log holds status lines (such as CubeSerialized: …) with only StatusMessage set.

TM1 REST EntitySet TransactionLogEntries

transaction_log

transaction_log(reverse: bool, ignore_status_messages: bool, query: ODataQuery | None = None, **options: Any) -> list[TransactionLogEntry]

TransactionLog(Reverse=…,IgnoreStatusMessages=…): the transaction log, newest first if reverse, without status lines if ignore_status_messages.

TM1 REST FunctionImport TransactionLog

audit_log_entries

audit_log_entries(query: ODataQuery | None = None, **options: Any) -> list[AuditLogEntry]

GET AuditLogEntries; empty unless the audit log is on. Expand AuditDetails for each entry's details.

TM1 REST EntitySet AuditLogEntries Navigation AuditLogEntry/AuditDetails

tail_message_log

tail_message_log(every: float | timedelta) -> Iterator[MessageLogEntry]

Follows the message log: the entries written from now on, polling every every (seconds) until the caller stops iterating. Built on TailMessageLog() (schema 11.3.0).

TailMessageLog() returns a delta link, but TM1 (11.8) answers it with every entry since the link was made, each time, and with no next link. So this keeps the one link and skips the entries it has already yielded, and each poll fetches more the longer it runs. For a long watch, start afresh now and then.

TM1 REST FunctionImport TailMessageLog

tail_transaction_log

tail_transaction_log(every: float | timedelta) -> Iterator[TransactionLogEntry]

Follows the transaction log, as tail_message_log does the message log. Built on TailTransactionLog() (schema 11.3.0).

TM1 REST FunctionImport TailTransactionLog

tail_audit_log

tail_audit_log(every: float | timedelta) -> Iterator[AuditLogEntry]

Follows the audit log, as tail_message_log does the message log. Built on TailAuditLog() (schema 11.6.0).

TM1 REST FunctionImport TailAuditLog

error_log_files

error_log_files(query: ODataQuery | None = None, **options: Any) -> list[ErrorLogFile]

GET ErrorLogFiles: the error logs processes have written, such as tm1processerror_<time>_<process>.log.

TM1 REST EntitySet ErrorLogFiles

error_log_file

error_log_file(filename: str, query: ODataQuery | None = None, **options: Any) -> ErrorLogFile

GET ErrorLogFiles('name'); a Tm1NotFoundError if there's none.

TM1 REST EntitySet ErrorLogFiles

error_log_content

error_log_content(filename: str) -> str

GET ErrorLogFiles('name')/Content: what the file says, as text, read whole. TM1 (11.8) starts it with a byte order mark, which is dropped.

TM1 REST EntitySet ErrorLogFiles