-
Notifications
You must be signed in to change notification settings - Fork 1
/
Logging.ls
71 lines (63 loc) · 1.69 KB
/
Logging.ls
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
global CRLF, consoleMode, cxObj
on initConsole
set CRLF = RETURN & numToChar(10)
set consoleMode = False
set cxObj = new xtra("console")
if cxObj.consoleExists() then
if cxObj.consoleAttach() then
cxObj.stdOut(CRLF)
if the count of getCommandLineArgs() > 0 then set consoleMode = True
end if
end if
end
on createLogFile
global exportFolder, logFile
set fPath = getUniqueFile(exportFolder, "Export", "log")
set result = writeLog(EMPTY, fPath)
if result.code = 0 then set logFile = fPath
else errorMsg(result.message)
return result.code
end
on resetLog
global logFile, numWarnings
if stringP(logFile) and not numWarnings then deleteEmptyFile(logFile)
set logFile = VOID
set numWarnings = 0
end
on logMsg msg
global logFile
put msg
put CRLF after msg
if stringP(logFile) then
set result = writeLog(msg, logFile)
if result.code <> 0 then
set logFile = False
errorMsg(result.message)
end if
end if
end
on infoMsg msg
cxObj.stdOut(msg & CRLF)
logMsg(msg)
end
on warnMsg msg
global numWarnings
set numWarnings = numWarnings + 1
cxObj.stdErr(msg & CRLF)
logMsg(msg)
end
on errorMsg msg
warnMsg(msg)
if consoleMode then quit()
else errorDialog(msg)
end
on logOptions
global movieFiles, castFiles, exportFolder, memberTypes, exportFormats, exportOptions, toolPaths
infoMsg("Movies:" && movieFiles)
infoMsg("Casts:" && castFiles)
infoMsg("Export folder:" && exportFolder)
infoMsg("Member types:" && memberTypes)
infoMsg("Export formats:" && exportFormats)
infoMsg("Export options:" && exportOptions)
infoMsg("Tool paths:" && toolPaths)
end