You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: aas_log.m
    path of file: ./repos/automaticanalysis/aa_engine
    
    the code of the file until where you have to start completion: % automatic analysis - log tool
% used to display messages
% if iserr is true, an error is generated
% function aas_log(aap,iserr,msg,style)

function aas_log(aap,iserr,msg,style
    
function logitem(msg,style)
global aaparallel;

if nargin < 2
    style='text';
end;

% output to screen
if ~isempty(strfind(msg,'parallel-manage-workers'))
    pmw_log.msg=msg;
    pmw_log.when=clock;
    if ~isfield(aaparallel,'manage_workers_log')
        aaparallel.manage_workers_log=pmw_log;
    else
        aaparallel.manage_workers_log(end+1)=pmw_log;
    end;
else
    % no colours when deployed... (or when on command line)
    if isdeployed || ~usejava('desktop') || ~exist('cprintf','file')
        fprintf(msg);
    else
        cprintf(style,msg);
    end;
end;
% and to worker file?
global aaworker
if isfield(aaworker,'logname')
    fid=fopen(aaworker.logname,'a');
    fprintf(fid,'[%d.%02d.%02d %02d:%02d:%02d]  ',round(clock));
    fprintf(fid,msg);
    fclose(fid);
    if isfield(aaworker,'master'), aas_propagateto(aaworker.master.hostname,aaworker.logname); end