Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of edl_logerror
Home > sltoolbox > ExpDL > edl_logerror.m

edl_logerror

PURPOSE ^

EDL_LOGERROR Logs an error into logger

SYNOPSIS ^

function edl_logerror(caller, err, logger, varargin)

DESCRIPTION ^

EDL_LOGERROR Logs an error into logger

 $ Syntax $
   - edl_logerror(caller, err, logger, ...)

 $ Arguments $
   - caller:       the name of caller (the agent that catches the error)
   - err:          the error struct
   - logger:       the logger
 
 $ Description $
   - edl_logerror(caller, err, logger, ...) logs the error caught into
     a logger. The logged information may include error header, 
     message, and runtime stack, depending on following properties
       'header':   whether to log header info (default = true)
       'message':  whether to log error message (default = true)
       'stack':    whether to log run-time stack (default = true)

 $ History $
   - Created by Dahua Lin, on Aug 13, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
  • incindent INCINDENT Increases the indent by a specified amount
  • write WRITE Writes message to a logger
  • writeblank WRITEBLANK Writes a blank line to log
  • writeinfo WRITEINFO Writes information to logger without time-stamp
  • slstrsplit SLSTRSPLIT splits a string into cell array of strings by delimiters
  • raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
  • slparseprops SLPARSEPROPS Parses input parameters
This function is called by:
  • edl_go EDL_GO The Top interface for doing experiments in EDL

SOURCE CODE ^

0001 function edl_logerror(caller, err, logger, varargin)
0002 %EDL_LOGERROR Logs an error into logger
0003 %
0004 % $ Syntax $
0005 %   - edl_logerror(caller, err, logger, ...)
0006 %
0007 % $ Arguments $
0008 %   - caller:       the name of caller (the agent that catches the error)
0009 %   - err:          the error struct
0010 %   - logger:       the logger
0011 %
0012 % $ Description $
0013 %   - edl_logerror(caller, err, logger, ...) logs the error caught into
0014 %     a logger. The logged information may include error header,
0015 %     message, and runtime stack, depending on following properties
0016 %       'header':   whether to log header info (default = true)
0017 %       'message':  whether to log error message (default = true)
0018 %       'stack':    whether to log run-time stack (default = true)
0019 %
0020 % $ History $
0021 %   - Created by Dahua Lin, on Aug 13, 2006
0022 %
0023 
0024 %% Parse and verify input arguments
0025 
0026 if nargin < 3
0027     raise_lackinput('edl_logerror', 3);
0028 end
0029 
0030 opts.header = true;
0031 opts.message = true;
0032 opts.stack = true;
0033 opts = slparseprops(opts, varargin{:});
0034 
0035 
0036 
0037 %% Logging
0038 
0039 % log header
0040 
0041 if opts.header
0042     if isempty(err.identifier)
0043         write(logger, '%s catch error:', caller);
0044     else
0045         write(logger, '%s catch error: %s:', caller, err.identifier);
0046     end
0047 end
0048 
0049 % log message
0050 
0051 if opts.message    
0052     msglines = slstrsplit(err.message, sprintf('\r\n'));
0053     nmlines = length(msglines);
0054     for i = 1 : nmlines
0055         writeinfo(logger, '%s', msglines{i});
0056     end
0057     writeblank(logger);
0058 end
0059 
0060 % log stack
0061 
0062 if opts.stack
0063     if ~isempty(err.stack)
0064         es = err.stack;
0065         writeinfo(logger, 'Runtime Stack:');
0066         ns = length(es);
0067         logger = incindent(logger, 1);
0068         for k = 1 : ns
0069             if ~isempty(es(k).file)
0070                 writeinfo(logger, '%s ==> (%d at %s)', es(k).name, es(k).line, es(k).file);
0071             else
0072                 writeinfo(logger, '%s ==> (%d)', es(k).name, es(k).line);
0073             end
0074         end
0075     end
0076     writeblank(logger);
0077 end
0078

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com