IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
irverbose.m
Go to the documentation of this file.
1 %>@ingroup usercomm
2 %>@file
3 %> @brief Verbose function. Currently just disp'ing the string
4 %
5 %> @param level
6 %> @arg @c 0 - debug
7 %> @arg @c 1 - "maybe important" info
8 %> @arg @c 2 - important info
9 %> @arg @c 3 - "must read" info
10 %> @sa @ref verbose_assert.m
11 function irverbose(s, level)
12 verbose_assert();
13 global VERBOSE;
14 if ~exist('level', 'var')
15  level = 1;
16 end;
17 
18 sp = '';
19 if ~isempty(VERBOSE.sid)
20  sp = [':', VERBOSE.sid];
21 end;
22 % if matlabpool('size') > 0
23 % sp = [':L', int2str(labindex)];
24 % end;
25 
26 s = [sp, ':VB', int2str(level), ':', s];
27 
28 if level >= VERBOSE.minlevel
29  disp(s);
30 end;
31 
32 if VERBOSE.flag_file
33  if isempty(VERBOSE.filename)
34  VERBOSE.filename = find_filename('irr_verbose', [], 'txt');
35  end;
36 
37  try
38  H = fopen(VERBOSE.filename, 'a+');
39  if H == -1
40  fprintf('Could not open file %s\n', VERBOSE.filename);
41  else
42  fwrite(H, [s, 10]);
43  end;
44  fclose(H);
45  catch ME
46  % Won't let program execution finish because of that! Sometimes I happen do delete the log file while cleaning directories, wouldn't want it
47  % to stop just because of that.
48  fprintf('___ IRVERBOSE FAILED WRITING TO FILE "%s": %s\n', VERBOSE.filename, ME.message);
49  end;
50 end;
51 
52 % if level == 3
53 % msgbox(s);
54 % end;