1
1
--[[
2
2
This file is part of darktable,
3
- copyright (c) 2014 Jérémy Rosen
3
+ Copyright (c) 2014 Jérémy Rosen
4
+ Copyright (c) 2016 Bill Ferguson
4
5
5
6
darktable is free software: you can redistribute it and/or modify
6
7
it under the terms of the GNU General Public License as published by
@@ -21,7 +22,7 @@ A collection of helper functions to help debugging lua scripts.
21
22
22
23
require it as
23
24
24
- dhelpers = require "official/ debug-helpers "
25
+ dhelpers = require "lib/dtutils. debug"
25
26
26
27
Each function is documented in its own header
27
28
@@ -33,177 +34,118 @@ local dt = require "darktable"
33
34
local io = require " io"
34
35
local table = require " table"
35
36
require " darktable.debug"
36
- local log = require " lib/libLog "
37
+ local log = require " lib/dtutils.log "
37
38
local M = {} -- The actual content of the module
38
39
39
40
M .libdoc = {
40
- Sections = { " Name " , " Synopsis " , " Description " , " License " } ,
41
- Name = [[ dtutils.debug - debugging helpers used in developing darktable lua scripts]] ,
42
- Synopsis = [[ local dd = require "lib/dtutils.debug"]] ,
41
+ Name = [[ dtutils.debug ]] ,
42
+ Synopsis = [[ debugging helpers used in developing darktable lua scripts]] ,
43
+ Usage = [[ local dd = require "lib/dtutils.debug"]] ,
43
44
Description = [[ dtutils.debug provides an interface to the darktable debugging routines.]] ,
44
- License = [[ This program is free software: you can redistribute it and/or modify
45
- it under the terms of the GNU General Public License as published by
46
- the Free Software Foundation; either version 3 of the License, or
47
- (at your option) any later version.
48
-
49
- This program is distributed in the hope that it will be useful,
50
- but WITHOUT ANY WARRANTY; without even the implied warranty of
51
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52
- GNU General Public License for more details.
53
-
54
- You should have received a copy of the GNU General Public License
55
- along with this program. If not, see <http://www.gnu.org/licenses/>.]] ,
45
+ Return_Value = [[ dd - library - the darktable lua debugging helpers]] ,
46
+ Limitations = [[ ]] ,
47
+ Example = [[ ]] ,
48
+ See_Also = [[ ]] ,
49
+ Reference = [[ ]] ,
50
+ License = log .libdoc .License ,
51
+ Copyright = [[ Copyright (c) 2014 Jérémy Rosen
52
+ Copyright (c) 2016 Bill Ferguson
53
+ ]] ,
56
54
functions = {}
57
55
}
58
56
59
- --[[
60
- NAME
61
- tracepoint - print out a tracepoint and dump the arguments
62
-
63
- SYNOPSIS
64
- local dd = require "lib/dtutils.debug"
65
-
66
- local result = tracepoint(name, ...)
67
- name - string - the name of the tracepoint to print out
68
- ... - arguments - variables to dump the contents of
69
-
70
- DESCRIPTION
71
- tracepoint prints its name and dumps its parameters using
72
- dt.debug
73
-
74
- RETURN VALUE
75
- result - ... - the supplied argument list
76
-
77
- ]]
78
-
79
- M .libdoc .functions [# M .libdoc .functions + 1 ] = {
80
- Sections = {" Name" , " Synopsis" , " Description" , " Return_Value" },
81
- Name = [[ tracepoint - print out a tracepoint and dump the arguments]] ,
82
- Synopsis = [[ local dd = require "lib/dtutils.debug"
57
+ M .libdoc .functions [" tracepoint" ] = {
58
+ Name = [[ tracepoint]] ,
59
+ Synopsis = [[ print out a tracepoint and dump the arguments]] ,
60
+ Usage = [[ local dd = require "lib/dtutils.debug"
83
61
84
62
local result = tracepoint(name, ...)
85
63
name - string - the name of the tracepoint to print out
86
64
... - arguments - variables to dump the contents of]] ,
87
65
Description = [[ tracepoint prints its name and dumps its parameters using
88
66
dt.debug]] ,
89
67
Return_Value = [[ result - ... - the supplied argument list]] ,
68
+ Limitations = [[ ]] ,
69
+ Example = [[ ]] ,
70
+ See_Also = [[ ]] ,
71
+ Reference = [[ ]] ,
72
+ License = [[ ]] ,
73
+ Copyright = [[ ]] ,
90
74
}
91
75
92
76
function M .tracepoint (name ,...)
93
- log .always ( 4 , " ***** " .. name .. " ****" )
77
+ log .msg ( log . always , 4 , " ***** " .. name .. " ****" )
94
78
params = {... }
95
- print ( dt .debug .dump (params ," parameters" ))
79
+ log . msg ( log . always , 0 , dt .debug .dump (params ," parameters" ))
96
80
return ... ;
97
81
end
98
82
99
-
100
-
101
- --[[
102
- NAME
103
- new_tracepoint - create a function returning a tracepoint
104
-
105
- SYNOPSIS
106
- local dd = require "lib/dtutils.debug"
107
-
108
- local result = new_tracepoint(name, ...)
109
- name - string - the name of the tracepoint to print out
110
- ... - arguments - variables to dump the contents of
111
-
112
-
113
- DESCRIPTION
114
- A function that returns a tracepoint function with the given name
115
- This is mainly used to debug callbacks.
116
-
117
- RETURN VALUE
118
- result - function - a function that returns the result of a tracepoint
119
-
120
- EXAMPLE
121
- register_event(event, dd.new_tracepoint("hit callback"))
122
-
123
- will print the following each time the callback is called
124
-
125
- **** hit callback ****
126
- <all the callback's parameters dumped>
127
-
128
- ]]
129
-
130
- M .libdoc .functions [# M .libdoc .functions + 1 ] = {
131
- Sections = {" Name" , " Synopsis" , " Description" , " Return_Value" , " Example" },
132
- Name = [[ new_tracepoint - create a function returning a tracepoint]] ,
133
- Synopsis = [[ local dd = require "lib/dtutils.debug"
83
+ M .libdoc .functions [" new_tracepoint" ] = {
84
+ Name = [[ new_tracepoint]] ,
85
+ Synopsis = [[ create a function returning a tracepoint]] ,
86
+ Usage = [[ local dd = require "lib/dtutils.debug"
134
87
135
88
local result = new_tracepoint(name, ...)
136
89
name - string - the name of the tracepoint to print out
137
90
... - arguments - variables to dump the contents of]] ,
138
91
Description = [[ A function that returns a tracepoint function with the given name
139
92
This is mainly used to debug callbacks.]] ,
140
93
Return_Value = [[ result - function - a function that returns the result of a tracepoint]] ,
94
+ Limitations = [[ ]] ,
141
95
Example = [[ register_event(event, dd.new_tracepoint("hit callback"))
142
96
143
97
will print the following each time the callback is called
144
98
145
99
**** hit callback ****
146
100
<all the callback's parameters dumped>]] ,
101
+ See_Also = [[ ]] ,
102
+ Reference = [[ ]] ,
103
+ License = [[ ]] ,
104
+ Copyright = [[ ]] ,
147
105
}
148
106
149
107
function M .new_tracepoint (name )
150
108
return function (...) return M .tracepoint (name ,... ) end
151
109
end
152
110
153
111
154
- --[[
155
- NAME
156
- dprint - pass a variable to dt.debug.dump and print the results to stdout
157
-
158
- SYNOPSIS
159
- local dd = require "lib/dtutils.debug"
160
-
161
- dd.dprint(var)
162
- var - variable - any variable that you want to see the contents of
163
-
164
- DESCRIPTION
165
- Wrapper around debug.dump, will directly print to stdout,
166
- same calling convention
167
-
168
- ]]
169
-
170
- M .libdoc .functions [# M .libdoc .functions + 1 ] = {
171
- Sections = {" Name" , " Synopsis" , " Description" },
172
- Name = [[ dprint - pass a variable to dt.debug.dump and print the results to stdout]] ,
173
- Synopsis = [[ local dd = require "lib/dtutils.debug"
112
+ M .libdoc .functions [" dprint" ] = {
113
+ Name = [[ dprint]] ,
114
+ Synopsis = [[ pass a variable to dt.debug.dump and print the results to stdout]] ,
115
+ Usage = [[ local dd = require "lib/dtutils.debug"
174
116
175
117
dd.dprint(var)
176
118
var - variable - any variable that you want to see the contents of]] ,
177
119
Description = [[ Wrapper around debug.dump, will directly print to stdout,
178
120
same calling convention]] ,
121
+ Return_Value = [[ ]] ,
122
+ Limitations = [[ ]] ,
123
+ Example = [[ ]] ,
124
+ See_Also = [[ ]] ,
125
+ Reference = [[ ]] ,
126
+ License = [[ ]] ,
127
+ Copyright = [[ ]] ,
179
128
}
180
129
181
130
function M .dprint (...)
182
131
log .always (4 , dt .debug .dump (... ))
183
132
end
184
133
185
- --[[
186
- NAME
187
- terse_dump - set dt.debug.known to shorten all image dumps to a single line
188
-
189
- SYNOPSIS
190
- local dd = require "lib/dtutils.debug"
191
-
192
- dd.terse_dump()
193
-
194
- DESCRIPTION
195
- terse_dump sets dt.debug.known to shorten all images to a single line.
196
- If you don't need to debug the content of images, this will avoid them flooding your logs
197
- ]]
198
-
199
- M .libdoc .functions [# M .libdoc .functions + 1 ] = {
200
- Sections = {" Name" , " Synopsis" , " Description" },
201
- Name = [[ terse_dump - set dt.debug.known to shorten all image dumps to a single line]] ,
202
- Synopsis = [[ local dd = require "lib/dtutils.debug"
134
+ M .libdoc .functions [" terse_dump" ] = {
135
+ Name = [[ terse_dump]] ,
136
+ Synopsis = [[ set dt.debug.known to shorten all image dumps to a single line]] ,
137
+ Usage = [[ local dd = require "lib/dtutils.debug"
203
138
204
139
dd.terse_dump()]] ,
205
140
Description = [[ terse_dump sets dt.debug.known to shorten all images to a single line.
206
141
If you don't need to debug the content of images, this will avoid them flooding your logs]] ,
142
+ Return_Value = [[ ]] ,
143
+ Limitations = [[ ]] ,
144
+ Example = [[ ]] ,
145
+ See_Also = [[ ]] ,
146
+ Reference = [[ ]] ,
147
+ License = [[ ]] ,
148
+ Copyright = [[ ]] ,
207
149
}
208
150
209
151
function M .terse_dump ()
0 commit comments