bugy / script-server

Web UI for your scripts with execution management
Other
1.52k stars 244 forks source link

Custom logging path for different scripts #695

Open zfpang opened 9 months ago

zfpang commented 9 months ago

Hi,

Is there anyway to define specific script and store the execution logging to another directory path instead of default directory?

Example: to store Script 1 at different path and script 2 , 3 , 4 remain the same.

bugy commented 9 months ago

Hi @zfpang, unfortunately this is not possible :(

MNeill73 commented 9 months ago

Holy hell I can't send emails right today...

If the purpose of this is to allow some users to see some logs for a given script, create a separate script that hunts and makes those logs accessible. I do something like this when I want to hunt for logs run against specific sets of instances in my labs. The following script takes a single argument passed, the lab instance (i.e., "03", which is what my instance names are labeled as), to return all of the scripts that ran against instances named as such:

for i in `grep se_lab_${1} /path/to/logs/* | cut -d: -f1|sort|uniq`; do
                runID=`egrep "^id" ${i}|cut -d: -f2`
                echo "${runID} --> ${i}<BR>"
                echo "&nbsp;&nbsp;&nbsp;&nbsp;"
                echo "<A HREF=\"/index.html#/history/${runID}\" TARGET=\"_blank\">Run ${runID}</A><BR><BR>"
done

That requires you to be logged in as a user that would normally have access to the log files, but it looks like a non-admin user can see the logs of the scripts that they run, so this would work, too.

If you made the logs directory accessible to a regular web server, you could generate external links to them so you could expose them outside of ScriptServer. Or, you could have ScriptServer parse the logs directory itself, return the list of logs that match the script name whose logs you want to expose, return that as a parameter values list, and let them choose which log specifically to show.

Note that ScriptServer by default logs runs as "SCRIPT_NAME_Spaces_asunderscores{logged-in-user}_{YYMMDD-datestamp}_{hhmmss timestamp}.log". So, run this command/script in your runner configuration to generate your list of files to pass to a list parameter:

(cd /path/to/logs && find . -name "Your_Script_Name_*")

You could even filter on the logged-in user's username by adding ${auth.username} to the find pattern, such as:

find "Your_Script_Name_${auth.username}_*"

(Note, double quotes so that the environment variable expands)

Then just have a script that cats the file you chose as the parameter:

cat /path/to/logs/${1}