Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ $ gogo-set-log-level com.mycompany.mylogger DEBUG

```

If <log-level> is not set the current level of <logger-name> is returned.

Example:

```
$ gogo-set-log-level com.mycompany
Level for com.mycompany: ERROR
```

#### gogo-reindex-all-search-indexes

Reindex all search indexes.
Expand Down
19 changes: 16 additions & 3 deletions gogo-set-log-level
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
# Further documentation: https://github.com/slemarchand/liferay-gogo-scripts
#

if { $argc < 2 } {
if { $argc < 1 } {
set command [file tail $argv0]
send_user "usage: $command <logger-name> <log-level>\n"
send_user "If <log-level> is not set the current level of <logger-name> is returned.\n"
exit 1
}

Expand Down Expand Up @@ -69,7 +70,19 @@ set level [lindex $argv 1];

set groovy_script " \
import static com.liferay.util.log4j.Log4JUtil.setLevel; \
setLevel('$name','$level',true); \
import static com.liferay.util.log4j.Log4JUtil.getOriginalLevel; \
level = '$level'; \
name = '$name'; \
if(!level.isEmpty()) { \
setLevel(name, level, true); \
println('Level set'); \
} else { \
try { \
println('Level for ' + name + ': ' + getOriginalLevel(name)); \
} catch(java.lang.Exception ex) { \
ex.printStackTrace(); \
} \
} \
";

send -- " \
Expand Down Expand Up @@ -106,4 +119,4 @@ expect {
set output [string range $output [string first "\n" $output]+1 [string last "\n" $output]-1]
if { $return_code == 0 } { send_user "$output\n" } else { send_error "$output\n" }

exit $return_code
exit $return_code