forked from e0404/matRad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatRad_dispToConsole.m
74 lines (54 loc) · 1.78 KB
/
matRad_dispToConsole.m
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function matRad_dispToConsole(string,param,typeOfMessage,formatSpec)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% matRad_dispToConsole function to display information on the console
% depending on the current param.logLevel
% call
% matRad_dispToConsole(string,param,typeOfMessage)
%
% input
% string: message that should be displayed on the console
% param: structure containt a subfield logLevel
% typeOfMessage: possible options are 'info','warning','error'
% formatSpec: optional
% output
%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2017 the matRad development team.
%
% This file is part of the matRad project. It is subject to the license
% terms in the LICENSE file found in the top-level directory of this
% distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
% of the matRad project, including this file, may be copied, modified,
% propagated, or distributed except according to the terms contained in the
% LICENSE file.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if exist('param','var')
if ~isfield(param,'logLevel')
param.logLevel = 1;
end
else
param.logLevel = 1;
end
switch typeOfMessage
case {'error'}
fprintf(string);
case{'warning'}
if param.logLevel < 4
fprintf(['[\bWarning:]\b ' string]);
end
case{'info'}
if param.logLevel < 3
if exist('formatSpec','var')
fprintf(formatSpec,string);
else
fprintf(string);
end
end
otherwise
error('type of message not defined');
end
end