forked from VFPX/Log4VFP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.prg
63 lines (53 loc) · 1.97 KB
/
sample.prg
1
local lcConfigFile, ; lcLogFile, ; lcUser, ; loLogger, ; loException as Exception* Define some things.lcConfigFile = fullpath('postgresql.config') && the name of the configuration file to use; use this for a compact log*lcConfigFile = fullpath('verbose.config') && the name of the configuration file to use; use this for a verbose log*lcConfigFile = fullpath('database.config') && the name of the configuration file to use; use this to log to a SQL && Server databaselcLogFile = lower(fullpath('applog.txt')) && the name of the log file to write tolcUser = 'nic' && the name of the current user* Initialize the logger.loLogger = newobject('Log4VFP', 'Log4VFP.prg')loLogger.cConfigurationFile = lcConfigFile && optional: uses a basic log4vfp.config (created if necessary) if not && specifiedloLogger.cUser = lcUser && optional: uses Windows user name if not specifiedloLogger.Open(lcLogFile, lcUser)* Log the application start.loLogger.LogInfo('Test')loLogger.LogInfo('=================> App started at {0}', datetime())loLogger.LogInfo('Application object created: version {0}', '1.0.1234')loLogger.LogInfo('Using {0} build {1} {2}', os(1), os(5), os(7))* Log that an error occurred.try x = ycatch to loException loLogger.LogError('Error {0} occurred: {1}', loException.ErrorNo, ; loException.Message)endtry* Log a process.wait window timeout 2 'Inserting a 2 second delay between logs (1)...'loLogger.StartMilestone('=================> Started process')wait window timeout 2 'Inserting a 2 second delay between logs (2)...'loLogger.LogInfo('Process done')* Do the same in a loop 1 000 000 times and time it* loLogger.StartMilestone('=================> Started process')*!* lnSec = SECONDS()*!* DO WHILE SECONDS() - lnSec < 10*!* loLogger.LogError('Application object created: version {0}', '1.0.1234')*!* ENDDO*!* loLogger.LogInfo('Process done')*!* Shut down the logger and display the log.release loLoggerCLEAR ALLmodify file (lcLogFile) nowait