-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsgEx.m
More file actions
36 lines (30 loc) · 1.16 KB
/
msgEx.m
File metadata and controls
36 lines (30 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function msgEx(Style,fmt,varargin)
% MSGEX prints formatted message
%
% Output includes date/time and caller name.
% If caller from MatLAb worker (see matlabpool) the message also includes worker ID
%
% Syntax:
% msgEx( format, data )
% msgEx('msg', format, data )
% msgEx('warn', format, data )
% msgEx('err', format, data )
%
WorkerString = '';
try
t = getCurrentTask();
if ~isempty(t)
WorkerString = sprintf('W%02d@',t.ID);
end
catch
WorkerString = '';
end
switch lower(Style)
case {'warn','warning'}, Style = mat2str([1.0,0.5,0.0]/2); Prefix = 'WARNING';
case {'msg','message'}, Style = mat2str([0.0,0.5,1.0]/2); Prefix = 'MESSAGE';
case {'err','error'}, Style = mat2str([1.0,0.0,0.0]/2); Prefix = '!ERROR!';
otherwise, Style = mat2str([0.5,0.5,0.5]/2); Prefix = '';
end
[CallerFile,CallerName,CallerLine] = GetCallerFileFunctionLine;
fprintf(' %s %s%s <a href="matlab: opentoline(''%s'',%d)">%s@%04d</a>: %s\n',Prefix,WorkerString,datestr(now,'HH:MM:SS.FFF'), CallerFile,CallerLine, CallerName,CallerLine, sprintf(fmt,varargin{:}));
end