ENVI::LogMessage

The LogMessage method writes a custom message to the log file specified by the LOG_FILE property of the ENVI function. If a log file has not been specified, then no log message will be written.

Log messages are used primarily in batch programs to summarize processing results. You can use the LogMessage method multiple times in your code, for example, to indicate successful completion of a process so that you can review the log file later.

Example

This example displays two images in two different views, while logging successful completion of each step. Copy and paste the following code into the IDL command line:

; Start the application

e = ENVI()

 

; Create a log file

e.LOG_FILE = e.GetTemporaryFilename('.txt')

 

; Open a raster file

file = FILEPATH('qb_boulder_msi', ROOT_DIR=e.ROOT_DIR, $

SUBDIRECTORY = ['data'])

raster = e.OpenRaster(file)

 

; Update the log file

e.LogMessage, 'File opened sucessfully: ' + raster.URI

 

; Create a view and add a raster layer to it

view1 = e.GetView()

layer1 = view1.CreateLayer(raster)

 

; Create a second view and add a raster layer to it

view2 = e.CreateView()

layer2 = view2.CreateLayer(raster, /CIR)

 

; Update the log file again

e.LogMessage, 'Views created successfully'

Open the log file (*.txt) in your system's temporary directory, and verify the messages were correctly added to the log file.

Syntax

ENVI.LogMessage, Message [, ERROR=variable]

Arguments

Message

Specify a string with the custom message to add.

Keywords

Keywords are applied only during the initial creation of the object.

ERROR

Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.

Version History

ENVI 5

Introduced

API Version

4.2

See Also

ENVI function, ENVI::ReportError, LOG_FILE property of ENVI, Manage Errors