comparison m-toolbox/classes/+utils/@helper/msg.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % MSG writes a message to the MATLAB terminal
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % DESCRIPTION: Writes a message to the MATLAB terminal if its priority is
4 % equal or higher than the verbosity level in the LTPDA user preferences. The
5 % message can be a printf format string that describes how subsequent argument
6 % sare converted for output.
7 %
8 % CALL: utils.helper.msg(priority, message, ...)
9 %
10 % INPUTS:
11 % message - message string to print
12 % priority - priority of the message as defined in utils.const.msg
13 %
14 % EXAMPLE:
15 %
16 % >> import utils.const.*
17 % >> utils.helper.msg(msg.IMPORTANT, 'The Answer is %d.', 42);
18 %
19 % NOTE: The verbosity level can be set within the 'LTPDAprefs' dialog, or via
20 %
21 % >> p = getappdata(0, 'LTPDApreferences');
22 % >> p.display.verboseLevel
23 % >> p.display.verboseLevel = utils.const.msg.PROC1
24 %
25 % VERSION: $Id: msg.m,v 1.15 2010/08/16 14:04:58 hewitson Exp $
26 %
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28
29 function msg(varargin)
30 level = varargin{1};
31
32 % get prefereces
33 persistent prefs;
34 prefs = getappdata(0, 'LTPDApreferences');
35
36 % decide to print or not
37 if ~isempty(prefs) && level <= double(prefs.getDisplayPrefs.getDisplayVerboseLevel)
38
39 % format message
40 msg = sprintf(varargin{2}, varargin{3:end});
41 msg = ['M: ' repmat(char(32), 1, 2*level) msg];
42
43 fprintf('%s\n', msg)
44 wb = getappdata(0, 'LTPDAworkbench');
45 if isa(wb, 'LTPDAworkbench')
46 wb.addMessage(msg);
47 end
48 end
49 end
50