@@ -36,7 +36,7 @@ Setup in 3 easy steps:
3636
3737
3838 if(BuildConfig.DEBUG) {
39- Snippet.install(new Snippet.MeasuredExecutionPath());
39+ Snippet.install(new Snippet.MeasuredExecutionPath());
4040 Snippet.newFilter("SampleFilter");
4141 Snippet.addFlag(Snippet.FLAG_METADATA_LINE | Snippet.FLAG_METADATA_THREAD_INFO);
4242 }
@@ -217,60 +217,63 @@ Snippet.addFlag(Snippet.FLAG_METADATA_LINE | Snippet.FLAG_METADATA_THREAD_INFO);
217217 }
218218
219219 @NonNull
220- @Override public ExecutionContext capture(String message, Snippet.Closure closure) {
221- ExecutionContext context = super.capture(message, closure);
222- Log.d("Snippet", "Class: " + context.getClassName() + "Duration: " + context.getExecutionDuration());
223- // Context has all the information that measured path has captured. Use that to write to files.
224- return writeToFile(context);
225- }
220+ @Override
221+ public ExecutionContext capture(String message, Snippet.Closure closure) {
222+ ExecutionContext context = super.capture(message, closure);
223+ Log.d("Snippet", "Class: " + context.getClassName() + "Duration: " + context.getExecutionDuration());
224+ // Context has all the information that measured path has captured. Use that to write to files.
225+ return writeToFile(context);
226+ }
226227
227- private ExecutionContext writeToFile(ExecutionContext context) {
228- // Code to write to a file goes here, create a thread and write.
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;
232- }
228+ private ExecutionContext writeToFile(ExecutionContext context) {
229+ // Code to write to a file goes here, create a thread and write.
230+ // Finally return a the execution context(could be the same or a new implementation) with some // of the details that you captured.
231+ // NOTE: always put the relevant information on the context before you start doing IO // so that the execution path could return successfully.
232+ return context;
233+ }
233234
234235 @NonNull
235236 @Override public ExecutionContext capture(Snippet.Closure closure) {
236237 return super.capture(closure);
237- }
238+ }
238239
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
241- public ILogToken startCapture() {
242- return new ExtendableLogToken(super.startCapture());
243- }
240+ // We need to return a log token implementation that writes to a file when we call endCapture()
241+ // APIs.
242+ // USE ExtendableLogToken for the above purpose @Override
243+ public ILogToken startCapture() {
244+ return new ExtendableLogToken(super.startCapture());
245+ }
244246
245- @Override
246- public ILogToken find(String tag) {
247- return super.find(tag);
248- }
247+ @Override
248+ public ILogToken find(String tag) {
249+ return super.find(tag);
250+ }
249251
250- public class FileWritingLogToken extends ExtendableLogToken {
252+ public class FileWritingLogToken extends ExtendableLogToken {
251253
252- public FileWritingLogToken(ILogToken logToken) {
253- super(logToken);
254- }
254+ public FileWritingLogToken(ILogToken logToken) {
255+ super(logToken);
256+ }
255257
256- @Override
257- public ExecutionContext endCapture(String message) {
258- ExecutionContext context = super.endCapture(message);
259- writeToFile(context);
260- return context;
261- }
258+ @Override
259+ public ExecutionContext endCapture(String message) {
260+ ExecutionContext context = super.endCapture(message);
261+ writeToFile(context);
262+ return context;
263+ }
262264
263- @Override
264- public ExecutionContext endCapture() {
265- ExecutionContext context = super.endCapture();
266- writeToFile(context);
267- return context;
268- }
269- }
265+ @Override
266+ public ExecutionContext endCapture() {
267+ ExecutionContext context = super.endCapture();
268+ writeToFile(context);
269+ return context;
270+ }
271+ }
270272}
271- Finally, install it at the application create,
272-
273273
274+
275+ Finally, install it at the application create,
276+
274277 if(Build.DEBUG) {
275278 Snippet.install(new FileExecutionContext());
276279 }
0 commit comments