function configureLoggers(obj, modelHIncludingLoggers)%
%

%   Copyright 2009-2014 The MathWorks, Inc.
    if nargin<2
        modelHIncludingLoggers = [];
    end
    
    if ~isempty(modelHIncludingLoggers)
        restoreDirtyness = true;
        origDirty = get_param(modelHIncludingLoggers,'Dirty');
    else
        restoreDirtyness = false;
    end

    numPorts = length(obj.PortHsToLog);    
    for idx=1:numPorts
        set_param(obj.PortHsToLog(idx),'DataLogging','on');
    end
    
    if isa(obj,'Sldv.SubsystemLogger')
        numDSMs = length(obj.dsmHsToLog);
        for idx=1:numDSMs
            set_param(obj.dsmHsToLog(idx),'DataLogging','on');
        end
    end
    
    if restoreDirtyness
        set_param(modelHIncludingLoggers,'Dirty',origDirty);       
    end
end

