Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:A9T9 RPA LogService

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, Logging
Last Updated 2026-10-22 00:00 GMT

Overview

Concrete tool for persisting macro execution logs to the filesystem and surfacing them in the UI, provided by the Ui.Vision log service.

Description

The LogService class (`src/services/log/index.ts`) persists macro execution log entries to the native filesystem (via the XFile native messaging host) and is the single source of truth for log persistence across macro runs. It manages a logs directory and date-stamped log files (`log-YYYYMMDD-HHMMSS.txt`). The `getLogService` function is a singleton getter. `ensureLineBreak` is a small helper that guarantees trailing newlines on log strings.

During macro execution, each command's `RunCommandResult` is dispatched as a Redux `addLog` action, which renders in the side panel log list. The `LogService` persists those entries to disk when the XFile mode is active. The UI rendering happens in `src/containers/sidepanel/components/logs/`.

Usage

Import `getLogService` when you need to persist log text to the filesystem. The in-memory log entries for UI display are managed via Redux actions (`addLog`) rather than direct LogService calls.

Code Reference

Source Location

  • Repository: A9T9/RPA
  • File: src/services/log/index.ts
  • Lines: L12-L138 (LogService class, getLogService, ensureLineBreak)

Signature

export class LogService {
  constructor(params?: LogServiceParams)

  check(): Promise<boolean>              // Ensure logs directory exists
  log(str: string): Promise<boolean>      // Append a line to the current log file
  logWithTime(str: string): Promise<boolean> // Append a timestamped line
  logTo(filePath: string, str: string): Promise<boolean> // Append to a specific file
  updateLogFileName(): void              // Rotate to a fresh date-stamped filename
}

export const getLogService: () => LogService  // Singleton getter

export function ensureLineBreak(str: string): string

Import

import { getLogService, LogService, ensureLineBreak } from '@/services/log'

I/O Contract

Inputs

Name Type Required Description
str string Yes Log text to persist
filePath string No (logTo) Specific file path to append to

Outputs

Name Type Description
success Promise<boolean> Whether the log was written successfully

Usage Examples

Persist a Log Line

import { getLogService } from '@/services/log'

const logService = getLogService()
await logService.check()         // ensure directory exists
await logService.logWithTime('Macro started: Login test')
await logService.log('Command click succeeded')

Add a Log Entry to Redux for UI Display

import { act } from '@/actions'

// During the player's handleResult callback:
store.dispatch(act.addLog('info', 'click on xpath=//button[@id="login"] — ok'))
store.dispatch(act.addLog('error', 'Element not found: timeout'))

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment