@echo off

rem LogDump tool - parses and prints log files.
rem -l[ocation]           print the source location of the message
rem -d[ate]               print the date of the message
rem -s[severity] <value>  MIN|DEBUG|PATH|INFO|WARNING|ERROR|FATAL"
rem                       display only records with severity >= value
rem -o[utfile] <filename> the filename where to write the output. Always writes
rem 	 	      the complete file and terminates automatic.
rem -c[omplete]           read complete file(s). Starts with the file header.
rem -p[ath] <dir or logfile>  path to the server log directory or single file. If dir, contents of all files under dir are dumped");
rem                       default path is : '/usr/sap/C11/JC00/j2ee/cluster/server0/log'
rem -h[elp]               print help
rem example: lv -c -s ERROR -p C:\usr\sap\C11\JC00\j2ee\cluster\server0\log\system -o errors.log 
rem          writes all the messages with severity 'error' and higher from all logs under the 
rem	     -p path.

@setlocal
@title Log Dump
set JAVA_CMD="/usr/sap/EPP/J00/exe/sapjvm_6\bin\java.exe"
if EXIST %JAVA_CMD% (
  echo launching Java from /usr/sap/EPP/J00/exe/sapjvm_6 
) else if DEFINED JAVA_HOME (
  echo launching Java from JAVA_HOME 
  set JAVA_CMD="%JAVA_HOME%\bin\java.exe"
) else (
  echo WARNING SAP JVM not found and environment variable JAVA_HOME not set, trying to launch java from current PATH
  set JAVA_CMD=java
)
%JAVA_CMD% -server -showversion -cp .\lib\sap.com~tc~logging~java~impl.jar com.sap.tc.logging.tools.lv.LV %*
@endlocal
@if %errorlevel% NEQ 0 (
  echo Program terminated abnormally
  pause
) else (
  rem Program successfully finished
)