Logs
Log
- class BBLog(mod_identity, log_name, logging_file_path=None)
Bases:
objectA class used to log messages.
- Parameters:
mod_identity (BBModIdentity) – The identity of the mod that owns the log.
log_name (str) – The name of the log, used when enabling/disabling logs via commands
logging_file_path (str, optional) – A custom file path relative to The Sims 4 folder. Example: Value is ‘fake_path/to/directory’, the final path would be ‘The Sims 4/fake_path/to_directory’. Default is None.
- debug(message, ignore_enabled=False, **kwargs)
Log a message.
- disable()
Disable the log.
- enable()
Enable the log.
- error(message, exception=None, stack_trace=None, **kwargs)
Log an error.
- Parameters:
message (str) – The message to log.
exception (Exception, None) – The exception that occurred. Default is None.
stack_trace (List[str], optional) – The stack trace leading to the exception, if not supplied, a stack trace will be gathered for you. Default is None.
kwargs (Any) – Keyword Arguments to format into the error message.
- is_enabled()
Determine if the log is enabled.
- Returns:
True, if the log is enabled. False, if not.
- Return type:
- log_stack()
Log the current stack trace and the calling frames
- property mod_name
The name of the mod that owns the log.
- Returns:
The name of the mod that owns the log
- Return type:
Log Registry
- class BBLogRegistry
Bases:
objectUsed to create and register logs.
- Example Usage:
# Register the log, Logs will appear in a file titled "MOD_NAME_version_Debug.txt" and messages logged using this log will be prefixed with "bbl_log_name" log = BBLogRegistry().register_log(ModIdentity(), 'bbl_log_name') # Enable the log, if not enabled, messages will not be logged. log.enable() # Log a message log.debug('This is dummy text.') # Disable the log log.disable() # The BluuberryLibrary_v1.0_Debug.txt file will contain the "This is dummy text." message.
Note
Available Commands:
bbl.enable_log or bbl.enablelog
bbl.disable_log or bbl.disablelog
bbl.disable_all_logs or bbl.disablealllogs
bbl.logs
- disable_logs(log_name, mod_identity=None)
Disable all logs with the specified name. If a mod identity is specified, only logs registered to that mod will be disabled. Otherwise, all logs with the same name will be disabled.
- Parameters:
log_name (str) – The name of the logs to disable.
mod_identity (BBModIdentity, optional) – The identity of the mod the log belongs to. Default is None.
- Returns:
True, if successful. False, if not.
- Return type:
- enable_logs(log_name, mod_identity=None)
Enable all logs with the specified name. If a mod identity is specified, only logs registered to that mod will be enabled. Otherwise, all logs with the same name will be enabled.
- Parameters:
log_name (str) – The name of the logs to enable.
mod_identity (BBModIdentity, optional) – The identity of the mod the log belongs to. Default is None.
- Returns:
True, if successful. False, if not.
- Return type:
- register_log(mod_identity, log_name, override_logging_path=None)
Create and register a log with the specified name.
Note
If log_name matches the name of a Log already registered, that log will be returned rather than creating a new Log.
- Parameters:
mod_identity (BBModIdentity) – The identity of the mod registering a log.
log_name (str) – The name of the log.
override_logging_path (str, optional) – A custom file path relative to The Sims 4 folder. Example: Value is ‘fake_path/to/directory’, the final path would be ‘The Sims 4/fake_path/to_directory’. Default is None.
- Returns:
A log.
- Return type:
Stacktrace Utils
Log Mixin
- class BBLogMixin
Bases:
objectA mixin that provides functions for creating and maintaining a log.
- classmethod get_log()
Get an instance of the class owned log.
- classmethod get_log_name()
The name of the log used within the class.
- classmethod get_mod_identity()
The identity of the mod that owns this class.