Skip to content

Commit 2708d91

Browse files
Update README.md
1 parent 5c4ca04 commit 2708d91

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

README.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -205,41 +205,44 @@ Snippet.addFlag(Snippet.FLAG_METADATA_LINE | Snippet.FLAG_METADATA_THREAD_INFO);
205205

206206
207207
/**
208-
* Demo for showing custom implementation of Execution Path. This path, takes the data that is * captured from the MeasuredExecutionPath and passes it to FileExecutionPath and then the data * is written to the file. * <p>
209-
* We need to override LogToken also, as for the code that is non contiguous all the measurements * are inside the log token that is handed over to the user by Snippet.startCapture() API * So if we want that our new execution to work for both kinds of APIs that ie. * The one passed through a lambda in Snippet.capture(lambda) and Snippet.startCapture()/LogToken.endCapture() * We need to override both the classes. */
208+
* Demo for showing custom implementation of Execution Path. This path, takes the data that is * captured from the MeasuredExecutionPath and passes it to FileExecutionPath and then the data * is written to the file. * <p>
209+
* We need to override LogToken also, as for the code that is non contiguous all the measurements * are inside the log token that is handed over to the user by Snippet.startCapture() API * So if we want that our new execution to work for both kinds of APIs that ie. * The one passed through a lambda in Snippet.capture(lambda) and Snippet.startCapture()/LogToken.endCapture()
210+
* We need to override both the classes. */
211+
210212
public class FileExecutionPath extends Snippet.MeasuredExecutionPath {
211213
212-
@Override
214+
@Override
213215
public ILogToken startCapture(String tag) {
214216
return super.startCapture(tag);
215217
}
216218
217-
@NonNull
219+
@NonNull
218220
@Override public ExecutionContext capture(String message, Snippet.Closure closure) {
219221
ExecutionContext context = super.capture(message, closure);
220222
Log.d("Snippet", "Class: " + context.getClassName() + "Duration: " + context.getExecutionDuration());
221223
// Context has all the information that measured path has captured. Use that to write to files.
222-
return writeToFile(context);
224+
return writeToFile(context);
223225
}
224226
225227
private ExecutionContext writeToFile(ExecutionContext context) {
226228
// Code to write to a file goes here, create a thread and write.
227-
// Finally return a the execution context(could be the same or a new implementation) with some // of the details that you captured.
228-
// NOTE: always put the relevant information on the context before you start doing IO // so that the execution path could return successfully. return context;
229+
// Finally return a the execution context(could be the same or a new implementation) with some // of the details that you captured.
230+
// NOTE: always put the relevant information on the context before you start doing IO // so that the execution path could return successfully.
231+
return context;
229232
}
230233
231-
@NonNull
234+
@NonNull
232235
@Override public ExecutionContext capture(Snippet.Closure closure) {
233236
return super.capture(closure);
234237
}
235238
236-
// We need to return a log token implementation that writes to a file when we call endCapture()
237-
// APIs. // USE ExtendableLogToken for the above purpose @Override
239+
// We need to return a log token implementation that writes to a file when we call endCapture()
240+
// APIs. // USE ExtendableLogToken for the above purpose @Override
238241
public ILogToken startCapture() {
239242
return new ExtendableLogToken(super.startCapture());
240243
}
241244
242-
@Override
245+
@Override
243246
public ILogToken find(String tag) {
244247
return super.find(tag);
245248
}
@@ -251,21 +254,21 @@ Snippet.addFlag(Snippet.FLAG_METADATA_LINE | Snippet.FLAG_METADATA_THREAD_INFO);
251254
}
252255
253256
@Override
254-
public ExecutionContext endCapture(String message) {
257+
public ExecutionContext endCapture(String message) {
255258
ExecutionContext context = super.endCapture(message);
256259
writeToFile(context);
257260
return context;
258261
}
259262
260263
@Override
261-
public ExecutionContext endCapture() {
264+
public ExecutionContext endCapture() {
262265
ExecutionContext context = super.endCapture();
263266
writeToFile(context);
264267
return context;
265268
}
266269
}
267270
}
268-
Finally, install it at the application create,
271+
Finally, install it at the application create,
269272

270273

271274
if(Build.DEBUG) {

0 commit comments

Comments
 (0)