Skip to content

Commit 218783a

Browse files
committed
added logging
1 parent 831422d commit 218783a

3 files changed

Lines changed: 58 additions & 2 deletions

File tree

castor.json

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
11
{
22
"ArchiveName": "zzz-ArluqTools",
3+
"RepoName": "ZtModArchive/ArluqTools",
4+
"Author": "Apodemus",
5+
"Version": "v2.2",
6+
"Type": "package",
7+
"License": "MIT License",
8+
"Description": "This is a lua library that is an abstraction layer around ZT2's libraries.",
39
"Z2f": true,
10+
"ZT2loc": "C:\\Program Files (x86)\\Microsoft Games\\Zoo Tycoon 2",
411
"IncludeFolders": [
12+
"ai",
13+
"awards",
14+
"biomes",
15+
"config",
16+
"effects",
17+
"entities",
18+
"lang",
19+
"locations",
20+
"maps",
21+
"materials",
22+
"photochall",
23+
"puzzles",
24+
"scenario",
525
"scripts",
6-
"ui"
26+
"shared",
27+
"tourdata",
28+
"ui",
29+
"world",
30+
"xpinfo"
731
],
832
"ExcludeFolders": [
933
"modules"
10-
]
34+
],
35+
"Dependencies": [],
36+
"DevDependencies": []
1137
}

scripts/lua/logging.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--- Logger class
2+
log = {}
3+
4+
--- Log debug to output
5+
--- @param message string
6+
function log.debug (message)
7+
print(os.date("[%Y-%m-%d %H:%M:%S] ") .. "[DEBUG] " .. message)
8+
end
9+
10+
--- Log error to output
11+
--- @param message string
12+
function log.error (message)
13+
print(os.date("[%Y-%m-%d %H:%M:%S] ") .. "[ERROR] " .. message)
14+
end
15+
16+
--- Log info to output
17+
--- @param message string
18+
function log.info (message)
19+
print(os.date("[%Y-%m-%d %H:%M:%S] ") .. "[INFO] " .. message)
20+
end
21+
22+
--- Log warning to output
23+
--- @param message string
24+
function log.warn (message)
25+
print(os.date("[%Y-%m-%d %H:%M:%S] ") .. "[WARN] " .. message)
26+
end

scripts/lua/try.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
include "scripts/lua/logging.lua"
2+
13
--- Function for try-catching
24
--- @param func function
35
function try(func)
@@ -11,6 +13,8 @@ function try(func)
1113
do
1214
displayZooMessageTextWithZoom(string.sub(exception, i, i+increment-1), 1, 30)
1315
end
16+
-- Show exception in log output
17+
log.error(exception)
1418
end
1519
end
1620

0 commit comments

Comments
 (0)