Repository navigation
Expand file tree
/
Copy pathd.lua
More file actions
106 lines (79 loc) · 2.68 KB
/
Copy pathd.lua
File metadata and controls
106 lines (79 loc) · 2.68 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
--[[#######################################################################
## d.lua ##
## BattUse - myDebug functions ##
## ##
## Author: BeGab ##
## URL : https://github.com/Be-Gab/ModelList ##
## ##
## Copyright (C) "BeGab" ##
## ##
###########################################################################
## License GNU General Public License v3.0 ##
#########################################################################]]
local appName = ...
local logF = nil
local LF = "\r\n"
local logDir = "/APPLOG/"
local d = {}
function d.log( s , v, hely )
local dt = getDateTime()
local ido = string.format( "%02d:%02d:%02d" , dt.hour, dt.min, dt.sec )
hely = hely or nil
v = v or nil
s = s .. " [" .. type( v ) .. "] "
if type( v ) == "boolean" then
if v then
v = "True"
else
v = "False"
end
end
if type( v ) == "nil" then
v = "nil"
end
if v then
s = s .. " => " .. v
end
if hely then
print( ido .. ":" .. appName .. " [" .. hely .. "]: " .. s )
else
print( ido .. ":" .. appName .. ": " .. s )
end
if logF ~= nil then
if hely then
io.write( logF, ido .. ":" .. " [" .. hely .. "]: " .. s .. LF )
else
io.write( logF, ido .. ":" .. s .. LF )
end
end
end
function d.printAssoc( msg , tbl, showFunctions, tab )
local sTab
showFunctions = showFunctions or false
tab = tab or 0
sTab = string.rep( " " , tab )
d.log( sTab .. "==================== >> " , msg )
for key, value in pairs( tbl) do
if type( value ) == "table" then
d.printAssoc( key , value, showFunctions, tab + 1 )
else
-- d.log( "Teszt:"..msg..":" , key )
if type( value ) == "function" then
if showFunctions then
d.log( sTab .. " " .. key .. "()" )
end
else
d.log( sTab .. " " .. key , value )
end
end
end
d.log( sTab .. "==================== << " , msg )
end
function d.setLogFile( logFile )
local dt = getDateTime()
-- local dts = string.format( "_%02d%02d%02d_" , dt.hour, dt.min , dt.sec )
local dts = string.format( "_%04d%02d%02d" , dt.year, dt.mon, dt.day )
logF = io.open( logDir .. logFile .. dts .. ".log" , "a" )
io.write( logF, " ======================================================================" .. LF )
end
return d