-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhlog.lua
46 lines (33 loc) · 991 Bytes
/
hlog.lua
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
local hfile = require 'hfile'
local htime = require 'htime'
local hconstants = require 'hconstants'
local hlog = {
__VERSION = '1.0',
__DESCRIPTION = 'File-related functions for lua',
}
function hlog.test()
print("hlog merge")
end
function hlog.log(text)
print(text)
end
function hlog.logToFile(text)
-- print(hconstants.LOGS_DIRECTORY);
local dateValues = htime.getDateValues()
local filePath = htime.getLogFilePath();
-- print(filePath)
-- local filePath = 'hlogs/' .. tostring(dateValues.year) .. '-' .. tostring(dateValues.month) .. '-' .. tostring(dateValues.day) .. '.txt'
-- print(filePath)
print(text)
local hms = dateValues.hour .. ':' .. dateValues.min .. ':' .. dateValues.sec .. ':'
hfile.appendToFile(filePath, hms .. text)
end
function hlog.deletePreviousXDays(x)
if(x == nil) then
x = 1
end
local fileName = htime.getPreviousDaysDate(x)
hfile.deleteFile(fileName)
end
-- print(type("Hello world"))
return hlog