-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsample.prg
More file actions
56 lines (44 loc) · 1.7 KB
/
sample.prg
File metadata and controls
56 lines (44 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local lcConfigFile, ;
lcLogFile, ;
lcUser, ;
loLogger, ;
loException as Exception
* Define some things.
lcConfigFile = fullpath('compact.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 database
lcLogFile = lower(fullpath('applog.txt'))
&& the name of the log file to write to
lcUser = 'DHENNIG'
&& 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
&& specified
loLogger.cUser = lcUser
&& optional: uses Windows user name if not specified
loLogger.Open(lcLogFile)
* Log the application start.
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 = y
catch 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')
* Shut down the logger and display the log.
release loLogger
modify file (lcLogFile) nowait