ILogger Interface

Summary

The Logger interface used by LEADVIEW.

Syntax
TypeScript
interface lt.LEADVIEW.ILogger() 
Remarks

A custom Logger can be provided to the Viewer.run method. To do so, create your own object that implements the ILogger interface and pass it to RunSettings.

Example
RunSettings.ts
RunSettings.html
export class RunSettingsExample { 
    public constructor() { 
        if(lt.RasterSupport.kernelExpired) 
            lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/js/LEADTOOLSEVAL.txt", "EVAL", null); 
    } 
 
    public run = (divID: string): void => { 
        const lv = new lt.LEADVIEW.Viewer(); 
        const runSettings: lt.LEADVIEW.RunSettings = { 
            logger: this.createLogger(), 
            author: "Demo Author" 
        } 
 
        // A quick test to make sure the logger was injected successfully is to change the 'rootDivId' to an invalid ID 
        // This will throw a LEADVIEW creation error, which will be bubbled up to the logApplicationError Logger method. 
        lv.run(runSettings, { 
            'rootDivId': divID 
        }); 
    } 
 
    private createLogger = ():lt.LEADVIEW.ILogger => { 
        const logger: lt.LEADVIEW.ILogger = { 
            logApplicationError: (errorType: lt.LEADVIEW.ErrorType, message:string) =>{ 
                alert(`Application Error:\nType:${errorType}\nMessage:${message}`); 
            }, 
            logServiceError: (serviceError: lt.Document.ServiceError, defaultMessage?: string) => { 
                alert(`Service Error:\nType:${serviceError.code}\nMessage:${serviceError.message}`); 
                return serviceError.message; 
            } 
        }; 
 
        return logger; 
    } 
} 
<!doctype html> 
<html lang="en"> 
    <title>LV Examples | RunSettings</title> 
    <head> 
        <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script> 
 
        <script src="../LT/Leadtools.js"></script> 
        <script src="../LT/Leadtools.Controls.js"></script> 
        <script src="../LT/Leadtools.Annotations.Engine.js"></script> 
        <script src="../LT/Leadtools.Annotations.Designers.js"></script> 
        <script src="../LT/Leadtools.Annotations.Rendering.Javascript.js"></script> 
        <script src="../LT/Leadtools.Annotations.Automation.js"></script> 
        <script src="../LT/Leadtools.ImageProcessing.Main.js"></script> 
        <script src="../LT/Leadtools.ImageProcessing.Color.js"></script> 
        <script src="../LT/Leadtools.ImageProcessing.Core.js"></script> 
        <script src="../LT/Leadtools.ImageProcessing.Effects.js"></script> 
        <script src="../LT/Leadtools.Document.js"></script> 
        <script src="../LT/Leadtools.Document.Viewer.js"></script> 
        <script src="../LT/Leadtools.LEADVIEW.js" defer></script> 
        <link href="../css/Leadtools.LEADVIEW.css" type="text/css" rel="stylesheet"> 
 
        <!-- All of the LEADVIEW TypeScript examples are served as a bundle --> 
        <script src="../bundle.js" type="text/javascript"></script> 
    </head> 
    <body> 
        <div id="runDemo" style="width: 100%; height: 100vh;"></div> 
    </body> 
 
    <script> 
       window.onload = () => { 
         const example = new window.examples.RunSettingsExample(); 
         example.run("runDemo"); 
      }; 
    </script> 
</html> 
Requirements

Target Platforms

See Also

Reference

lt.LEADVIEW Namespace

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.LEADVIEW Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.