Home > vbmeg > functions > common > utility > vb_disp_nonl.m

vb_disp_nonl

PURPOSE ^

Display message WITH new line.

SYNOPSIS ^

function vb_disp_nonl(message, verbose_level_min)

DESCRIPTION ^

 Display message WITH new line.

 This function shows a message on the MATLAB console. The message is
 automatically suppressed according to vbmeg_inst.verbose_level. 

 [syntax]
 vb_disp(message,verbose_level_min)

 [input]
 message          : <<string>> Message be shown. 
 verbose_level_min: <optional> <<int or string>> Verbose level of this
                    message. 
 --- verbose level string (verbose_level_min)
   'NONE' (=0)      Suppressing all messages 
   'EMERGENCY' (=1)
   'WARNING' (=2)
   'NOTICE' (=3)    VBMEG default value
   'INFO' (=5)
   'DEBUG' (=10)    Displaying all messages
 ---

 [example]
 >> vb_disp_nonl(sprintf('message\n'));          % default=NOTICE
 >> vb_disp_nonl(sprintf('message\n','NOTICE');  % default=NOTICE
 >> vb_disp_nonl(sprintf('message\n'),3);        % 3 is NOTICE

 exmaple of message suppression
 >> vb_set_verbose('WARNING');     % making verbose level low
 >> vb_disp(sprintf('message\n')); % same with the 1st line but none is shown

 [history]
 2011-06-28 rhayashi Initial version

 [see also]
    vb_set_verbose, vb_get_verbose, vb_disp

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function vb_disp_nonl(message, verbose_level_min)
0002 % Display message WITH new line.
0003 %
0004 % This function shows a message on the MATLAB console. The message is
0005 % automatically suppressed according to vbmeg_inst.verbose_level.
0006 %
0007 % [syntax]
0008 % vb_disp(message,verbose_level_min)
0009 %
0010 % [input]
0011 % message          : <<string>> Message be shown.
0012 % verbose_level_min: <optional> <<int or string>> Verbose level of this
0013 %                    message.
0014 % --- verbose level string (verbose_level_min)
0015 %   'NONE' (=0)      Suppressing all messages
0016 %   'EMERGENCY' (=1)
0017 %   'WARNING' (=2)
0018 %   'NOTICE' (=3)    VBMEG default value
0019 %   'INFO' (=5)
0020 %   'DEBUG' (=10)    Displaying all messages
0021 % ---
0022 %
0023 % [example]
0024 % >> vb_disp_nonl(sprintf('message\n'));          % default=NOTICE
0025 % >> vb_disp_nonl(sprintf('message\n','NOTICE');  % default=NOTICE
0026 % >> vb_disp_nonl(sprintf('message\n'),3);        % 3 is NOTICE
0027 %
0028 % exmaple of message suppression
0029 % >> vb_set_verbose('WARNING');     % making verbose level low
0030 % >> vb_disp(sprintf('message\n')); % same with the 1st line but none is shown
0031 %
0032 % [history]
0033 % 2011-06-28 rhayashi Initial version
0034 %
0035 % [see also]
0036 %    vb_set_verbose, vb_get_verbose, vb_disp
0037 %
0038 % Copyright (C) 2011, ATR All Rights Reserved.
0039 % License : New BSD License(see VBMEG_LICENSE.txt)
0040 
0041 global vbmeg_inst;
0042 const = vb_define_verbose;
0043 
0044 if nargin<2 || isempty(verbose_level_min)
0045   verbose_level_min = const.VERBOSE_LEVEL_NOTICE;
0046 end
0047 
0048 if ischar(verbose_level_min)
0049   switch verbose_level_min
0050    case 'NONE'
0051     verbose_level_min = 0;
0052    case 'EMERGENCY'
0053     verbose_level_min = 1;
0054    case 'WARNING'
0055     verbose_level_min = 2;
0056    case 'NOTICE'
0057     verbose_level_min = 3;
0058    case 'INFO'
0059     verbose_level_min = 5;
0060    case 'DEBUG'
0061     verbose_level_min = 10;
0062    otherwise
0063     error('Invalid verbose string: %s\n',verbose_level_min);
0064   end
0065 end
0066 
0067 if isempty(vbmeg_inst) || ~isfield(vbmeg_inst,'verbose_level')
0068   verbose_level = const.VERBOSE_LEVEL_NOTICE;
0069 else
0070   verbose_level = vbmeg_inst.verbose_level;
0071 end
0072 
0073 if verbose_level>=verbose_level_min
0074   fprintf('%s', [const.verbose_level_str{verbose_level_min+1} message]);
0075 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005