"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "doc/example/log-module-commands/siteconfig.tcl" between
modules-5.1.1.tar.bz2 and modules-5.2.0.tar.bz2

About: The Environment Modules package provides for the dynamic modification of a user’s environment via modulefiles.

siteconfig.tcl  (modules-5.1.1.tar.bz2):siteconfig.tcl  (modules-5.2.0.tar.bz2)
skipping to change at line 13 skipping to change at line 13
# evaluations to generate a log entry each time a module is loaded or # evaluations to generate a log entry each time a module is loaded or
# unloaded with an information to know if module is auto-loaded or not. # unloaded with an information to know if module is auto-loaded or not.
# #
# Author: Xavier Delaruelle <xavier.delaruelle@cea.fr> # Author: Xavier Delaruelle <xavier.delaruelle@cea.fr>
# Compatibility: Modules v4.2+ # Compatibility: Modules v4.2+
# #
# Installation: put this file in the 'etc' directory of your Modules # Installation: put this file in the 'etc' directory of your Modules
# installation. Refer to the "Modulecmd startup" section in the # installation. Refer to the "Modulecmd startup" section in the
# module(1) man page to get this location. # module(1) man page to get this location.
proc execLogger {msg} {
# ensure logger command is executed with system libs
if {[info exists ::env(LD_LIBRARY_PATH)]} {
set ORIG_LD_LIBRARY_PATH $::env(LD_LIBRARY_PATH)
unset ::env(LD_LIBRARY_PATH)
}
exec logger -t module $msg
# restore current user lib setup
if {[info exists ORIG_LD_LIBRARY_PATH]} {
set ::env(LD_LIBRARY_PATH) $ORIG_LD_LIBRARY_PATH
}
}
proc logModfileInterp {cmdstring code result op} { proc logModfileInterp {cmdstring code result op} {
# parse context # parse context
lassign $cmdstring cmdname modfile modname lassign $cmdstring cmdname modfile modname
set mode [currentState mode] set mode [currentState mode]
if {[info level] > 1} { if {[info level] > 1} {
set caller [lindex [info level -1] 0] set caller [lindex [info level -1] 0]
} else { } else {
set caller {} set caller {}
} }
skipping to change at line 35 skipping to change at line 48
# add info on load mode to know if module is auto-loaded or not # add info on load mode to know if module is auto-loaded or not
if {$mode eq {load} && $caller eq {cmdModuleLoad}} { if {$mode eq {load} && $caller eq {cmdModuleLoad}} {
upvar 1 uasked uasked upvar 1 uasked uasked
set extra ", \"auto\": [expr {$uasked ? {false} : {true}}]" set extra ", \"auto\": [expr {$uasked ? {false} : {true}}]"
} else { } else {
set extra {} set extra {}
} }
# produced log entry (formatted as a JSON record) # produced log entry (formatted as a JSON record)
exec logger -t module "{ \"user\": \"[get-env USER]\", \"mode\":\ execLogger "{ \"user\": \"[get-env USER]\", \"mode\": \"$mode\",\
\"$mode\", \"module\": \"$modname\"${extra} }" \"module\": \"$modname\"${extra} }"
} }
} }
# run log procedure after each modulefile interpretation call # run log procedure after each modulefile interpretation call
trace add execution execute-modulefile leave logModfileInterp trace add execution execute-modulefile leave logModfileInterp
proc logModuleCmd {cmdstring code result op} { proc logModuleCmd {cmdstring code result op} {
# parse context # parse context
set args [lassign $cmdstring cmdname] set args [lassign $cmdstring cmdname]
if {[info level] > 1} { if {[info level] > 1} {
set caller [lindex [info level -1] 0] set caller [lindex [info level -1] 0]
} else { } else {
set caller {} set caller {}
} }
# skip duplicate log entry when ml command calls module # skip duplicate log entry when ml command calls module
if {$cmdname ne {module} || $caller ne {ml}} { if {$cmdname ne {module} || $caller ne {ml}} {
# produced log entry (formatted as a JSON record) # produced log entry (formatted as a JSON record)
exec logger -t module "{ \"user\": \"[get-env USER]\", \"cmd\":\ execLogger "{ \"user\": \"[get-env USER]\", \"cmd\": \"$cmdname\",\
\"$cmdname\", \"args\": \"$args\" }" \"args\": \"$args\" }"
} }
} }
# run log procedure after each module or ml command # run log procedure after each module or ml command
trace add execution module leave logModuleCmd trace add execution module leave logModuleCmd
trace add execution ml leave logModuleCmd trace add execution ml leave logModuleCmd
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: # vim:set tabstop=3 shiftwidth=3 expandtab autoindent:
 End of changes. 3 change blocks. 
4 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)