Skip to content
Permalink
cc7dc82605
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
28 lines (26 sloc) 640 Bytes
function [obj, deleteLogger] = getLogger(name, varargin)
persistent loggers;
logger_found = false;
if ~isempty(loggers)
for logger = loggers
if strcmp(logger.name, name)
obj = logger;
logger_found = true;
break;
end
end
end
if ~logger_found
obj = logging.logging(name, varargin{:});
loggers = [loggers, obj];
end
deleteLogger = @() deleteLogInstance();
function deleteLogInstance()
if ~logger_found
error(['logger for file [ ' name ' ] not found'])
end
loggers = loggers(loggers ~= obj);
delete(obj);
clear('obj');
end
end