function aHandler = javaWorkerMessageHandler( )
; %#ok Undocumented
% Create a message handler.
%
% The message handler accepts a level number and a message, and routes them
% to the worker logger.

% Copyright 2006-2015 The MathWorks, Inc.

import java.util.logging.Level;
aHandler = @nMessageHandler;
workerLogger = com.mathworks.toolbox.distcomp.mjs.worker.PackageInfo.LOGGER;
% Defend against other code resetting the global LogManager
% see g1095813.
workerLogger.setLevel(Level.ALL);
    function nMessageHandler(msg, levelNum)
        % Do nothing if log level is invalid
        if nargin ~= 2
            return
        end
        lvl = com.mathworks.toolbox.parallel.pctutil.logging.DistcompLevel.getLevelFromValue(levelNum);
        workerLogger.log(lvl, msg);
    end

end
