Change log¶
Whenever an entity (e.g. a data series, a feature class a models setup,...) are added or updated the system will make an entry in the change_log with information about the user, the machine, the time and the activity, thus making timeline of changes to an entity.
This is done by default and for all entities. However, because of this the information is quite general.
Tools modifying entities apply more information about the operation, describing the actions taken by each tool in a sequence.
With scripting it is possible to create and modify entities and unless programed otherwise only the default logging will be supplied. However, the ChangeLog module has an API (see the API documentation) which allows custom log-records to be added instead of the default logs, see below scripting example.
Display of ChangeLog¶
Whenever an entity is selected in the UI the meta data manager is able to display the set of changes to this entity, in a separate tab in the property grid.
The above shows an example og the changelog of a time series which was
created by running the resample tool on a time series called
ANGASMAYO-60CXT33EN2QB01 - 1 - ANGASMAYO (Caudal) (Extract)
and the
above tool settings. The first log record shows the input time series
detail, the second the tool settings.
By default the application will show the last 100 logs (this is a configurable setting in the Dhi.solutions.Shell.exe.Config file).
View all logs¶
A separate query tool is available to access the entire changlog for an entity (or set of entities).
Selecting the above new time series the query result can look like this.
Make a script with ChangeLog¶
The below sample script will rename a time series and add custom change log record instead of the default update record
def ChangeLogExample():
def ChangeLogExample():
"""
<Script>
<Author>Anders Klinting</Author>
<Description>How to ad a change log record</Description>
</Script>
"""
# Get the changelog module and time series manager.
cmgr = app.Modules.Get('ChangeLog Manager')
tsmgr = app.Modules.Get('Time series Manager')
oldName = 'ANGASMAYO-60CXT33EN2QB01 - 1 - ANGASMAYO (Caudal) (Extract) (Resampled)'
newName = 'New name';
# Get the Time Series
ts = tsmgr.TimeSeriesList.Fetch("/Misc/%s" %(oldName))
# Rename the series
ts.Name = newName;
# Make a changelog record with AddChangeLogEntry.
cmgr.AddChangeLogEntry(ts, 'ChangeLogExample script', "Changing the name from %s to %s" %(oldName, newName), None)
# Update the series - the changelog will follow automatically.
tsmgr.TimeSeriesList.Update(ts);
After running the script the changelog of the sata series will look like: