/** * Sample to illustrate the use of the logging system. */ import { InfiniteApiControllerInterface, InfiniteFactory, InfiniteLogger, LogLevel, LogBehavior } from'generated_files/documentation/appinfiniteapi';
// a custom logger classMyLoggerimplementsInfiniteLogger { // just output a fancy message, but you may use your own GUI addLog(pContent : string, pDate : Date, pLevel : LogLevel) : void { console.log('got log ' + pContent + ' at time ' + pDate + ' at level ' + pLevel); } }
// the api controller interface (no need to create it, it is available !) constlControllerInterface : InfiniteApiControllerInterface = InfiniteFactory.GetInfiniteApiController(); // create our custom logger constlLogger : MyLogger = newMyLogger(); // no message less than information lControllerInterface.setLogLevel(LogLevel.LL_Information); // and we use our custom logger for the Information level lControllerInterface.setLogLevelBehavior(LogLevel.LL_Information, LogBehavior.LB_LogToObject, lLogger);
// add some logs lControllerInterface.addLog('this log should be discarded', LogLevel.LL_Debug);
lControllerInterface.addLog('this log should be displayed with my fancy logger', LogLevel.LL_Information);
The InfiniteLogger interface is used to customize the way logging is handled.
This interface is used with InfiniteApiControllerInterface.setLogLevelBehavior. You may create your own class that implements the InfiniteLogger in order to customize the behavior of the logging.
Please refer to the InfiniteApiControllerInterface for more information.
See
InfiniteApiControllerInterface.setLogLevelBehavior