% $Id$
%
% Earth System Modeling Framework
% Copyright (c) 2002-2023, University Corporation for Atmospheric Research, 
% Massachusetts Institute of Technology, Geophysical Fluid Dynamics 
% Laboratory, University of Michigan, National Centers for Environmental 
% Prediction, Los Alamos National Laboratory, Argonne National Laboratory, 
% NASA Goddard Space Flight Center.
% Licensed under the University of Illinois-NCSA License.

%\subsection{C++ Use and Examples}

%<Detailed examples of F90 usage of the class.>
\subsubsection{Example Code}

In this example we set the default log file to log.txt and then call the 
various methods to write to the log.  The first step is to include 
ESMC\_LogErr.h and ESMF\_LogMacros.inc.  Next, we define ESMC\_Method to 
the corresponding method.

{\tt
\begin{verbatim}
#include "ESMCI_LogErr.h"
#define ESMC_METHOD "TestLog1Ex"

int main() {
int *rc;
    
    ESMC_LogSetFilename("log1.txt");
    ESMC_LogDefault.WriteLog("LogWrite",ESMC_LOGMSG_WARN);
    ESMC_LogDefault.FoundError(ESMF_TRUE,rc);
	ESMC_LogDefault.MsgFoundError(ESMF_TRUE,"Log Msg Found Error",rc);
    ESMC_LogDefault.AllocError(rc);
	ESMC_LogDefault.MsgAllocError("Log Msg Alloc Error",rc);
}
\end{verbatim}
\tt}

\subsubsection{Example 1. ESMC\_LogSetFilename}

The default log is already set by ESMF during initialization.  However, if a user
wants to write to a different log, then ESMC\_LogSetFilename is used.  A fully 
qualified path and filename are required.  If only the filename is given then
the log file will be created in the same directory as the method calling the
ESMC\_LogSetFilename.

\subsubsection{Example 2. ESMC\_LogWrite}

ESMC\_LogWrite is the basic method for writing to the log.  All it requires is a
message and log type.

\subsubsection{Example 3. ESMC\_LogFoundError}

ESMC\_LogFoundError allows the user to pass a return code to check and if the 
return code is associated with an error it will write the corresponding error
message to the log.  It will also pass back the return code in rc.

\subsubsection{Example 4. ESMC\_LogMsgFoundError}

ESMC\_LogMsgFoundError does the same as ESMC\_LogFoundError but allows the user
to add his/her own message as well.

\subsubsection{Example 5. ESMC\_LogAllocError}

ESMC\_LogAllocError writes an allocation error to the log and returns a return
code rc.

\subsubsection{Example 6. ESMC\_LogMsgAllocError}

ESMC\_LogMsgAllocError does the same as ESMC\_LogAllocError but allows the user
to add his/her own message as well.
