From c75deefbf34e06d04a429b85a63b70c52679a255 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 16 Dec 2017 14:37:45 +0200 Subject: [PATCH] Update and rename current method name.txt to log-method-name.md --- snippets/current method name.txt | 3 --- snippets/log-method-name.md | 8 ++++++++ 2 files changed, 8 insertions(+), 3 deletions(-) delete mode 100644 snippets/current method name.txt create mode 100644 snippets/log-method-name.md diff --git a/snippets/current method name.txt b/snippets/current method name.txt deleted file mode 100644 index 7f76c176d..000000000 --- a/snippets/current method name.txt +++ /dev/null @@ -1,3 +0,0 @@ -###code to view name of current method - -String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); diff --git a/snippets/log-method-name.md b/snippets/log-method-name.md new file mode 100644 index 000000000..d8922ee62 --- /dev/null +++ b/snippets/log-method-name.md @@ -0,0 +1,8 @@ +### Log method name + +Use `console.debug()` and the `name` property of the passed method to log the method's name to the `debug` channel of the console. + +```js +const methodName = fn => (console.debug(fn.name), fn); +// methodName(methodName) -> methodName (logged in debug channel of console) +```