Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log module command #283

Closed
cdorbell2 opened this issue Jul 23, 2019 · 3 comments
Closed

log module command #283

cdorbell2 opened this issue Jul 23, 2019 · 3 comments
Milestone

Comments

@cdorbell2
Copy link

Hello
do you known if it is possible to include a function of log each command used ?

the output can be send to a syslog or anything other system of log for permit to see the evolution of usage of each tool (tool and others)

it's a cad view :)

@xdelaruelle
Copy link
Member

With a siteconfig.tcl script file installed in Modules etc directory that overrides the module procedure to call the logger utility prior performing the module command.

Here is some code snippet as example:

# override 'module' procedure to log each call made by user                                              
rename ::module ::__module                                                                               
proc module {command args} {                                                                             
   if {[getEvalModuleStackDepth] == 0} {                                                                 
      exec logger -t module "[get-env USER]: $command [join $args]"                                      
   }                                                                                                     
   return [eval __module "{$command}" $args]                                                                 
}

I will let this issue open until I add an example recipe for this use case in the documentation cookbook.

@xdelaruelle xdelaruelle added this to the 4.3.1 milestone Jul 23, 2019
@cdorbell2
Copy link
Author

Thanks Xavier,
it's very simple to use but it's limited to the first module command.
module workspace : mywork/work1
into " mywork/work1" all information specific to the workspace "path", and all tools that i use .
module load gnu/gcc
module load gnu/nedit
when i start a module load mywork/work1 i seen only the module command not the others (nedit , gcc)

@xdelaruelle
Copy link
Member

Yes the example only log the module command that are typed by user, not those within modulefiles. If you want to see everything, just remove the if {[getEvalModuleStackDepth] == 0} { statement to let the exec logger call operate in any cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants