Session

The Session package in openSTREAM provides tools for managing session environments, logging, and file structure during simulations. It helps ensure organized workflows and consistent runtime behavior. This includes:


class Session.Session(opt)

Bases: handle

SESSION Class for managing simulation session metadata and logging

This class handles session naming, directory creation, and logging setup. It ensures that session directories are valid and manages file overwriting behavior. It also integrates with the Log class to control output and warnings.

Constructor Summary
Session(opt)

SESSION Constructor for Session class

Initializes session metadata including name, directory, and overwrite behavior.

Inputs:

  • opt.name — Session name

  • opt.dirName — Directory name

  • opt.parentDir — Parent directory path

  • opt.overwriteFiles — Flag to allow overwriting existing session files

Property Summary
dirName = ""

Name of the session directory

directory

Full path to the session directory

log

Log object for managing output and warnings

name = ""

Name of the session (used for log file naming)

overwriteFiles = false

Flag to allow overwriting existing session files

parentDir = ""

Parent directory where session folder will be created

showWarnings = true

Flag to control display of warnings

Method Summary
makeSessionDirectory()

MAKESESSIONDIRECTORY Creates the session directory

Validates path legality, handles existing directories, closes open files and diaries if necessary, and creates the directory.

setupLog(session, LOGMODE, opts)

SETUPLOG Initializes the Log object for the session

Inputs:

  • LOGMODE — Logging mode (console, file, both, none)

  • opts.LOGFID — Optional file ID for logging

class Session.Log(LOGMODE, opts)

Bases: handle

LOG Console and file-based logging manager

This class manages logging of messages and warnings to console and/or file. It supports multiple logging modes, integrates with session management, and provides diary functionality for persistent logs.

Constructor Summary
Log(LOGMODE, opts)

LOG Constructor for Log class

Initializes logging mode, session context, and warning settings. Creates log file and session directory if needed.

Inputs:

  • LOGMODE — Determines where logs go (console, file, both, or none), using Session.LogMode.

  • opt.session — Session object for directory and naming context

  • opt.LOGFID — File ID for the open log file.

  • opt.showWarnings — Whether to display warnings in the console.

Property Summary
LOGFID = -1

File ID for log file

LOGMODE

Logging mode (console only, file only, both, or none)

diaryFilePath

Full path to the diary file

diaryIsOn = false

Flag indicating whether MATLAB diary is active

logFileName

Name of the log file (without extension)

logFilePath

Full path to the log file

showWarnings = true

Flag to control display of warnings

Method Summary
closeLog()

CLOSELOG Closes log file and resets file ID

delete()

DELETE Destructor for log class

Ensures log file and diary are properly closed

diaryOff()

DIARYOFF Turn off diary logging

diaryOn()

DIARYON Turn on diary logging if applicable

log(varargin)

LOG Logs messages to console and/or file depending on LOGMODE

openLog(opts)

OPENLOG Opens log file for writing

Optionally keeps it open between writes

warning(varargin)

WARNING Logs warnings using MATLAB’s built-in warning mechanism

Optionally writes to file if warnings are suppressed

Session.isLegalPath(pathname)

ISLEGALPATH Checks if the given pathname is valid on the current operating system

This function attempts to convert the input pathname to a Java Path object. If the conversion succeeds, the path is considered legal and the function returns true. If an exception is thrown during conversion, the path is considered illegal and the function returns false.

Input:

  • pathname — String representing the file or folder path to validate

Output:

  • bool — Logical true if the path is valid, false otherwise

class Session.LogMode

Bases: uint16

LOGMODE Enumeration of supported logging modes

This enumeration defines the available logging configurations for the simulation framework. It is used to control whether messages and warnings are printed to the console, written to a file, both, or suppressed entirely.