Always log scm stderr and makes the log file path configurable.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11209 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-01-20 12:04:23 +00:00
parent 9f9802bf46
commit 30801ca968
2 changed files with 15 additions and 4 deletions

View File

@ -133,6 +133,12 @@ default:
scm_bazaar_command: scm_bazaar_command:
scm_darcs_command: scm_darcs_command:
# Absolute path to the scm commands errors (stderr) log file.
# The default is to log in the 'log' directory of your Redmine instance.
# Example:
# scm_stderr_log_file: /var/log/redmine_scm_stderr.log
scm_stderr_log_file:
# Key used to encrypt sensitive data in the database (SCM and LDAP passwords). # Key used to encrypt sensitive data in the database (SCM and LDAP passwords).
# If you don't want to enable data encryption, just leave it blank. # If you don't want to enable data encryption, just leave it blank.
# WARNING: losing/changing this key will make encrypted data unreadable. # WARNING: losing/changing this key will make encrypted data unreadable.

View File

@ -218,14 +218,19 @@ module Redmine
Rails.logger Rails.logger
end end
# Path to the file where scm stderr output is logged
def self.stderr_log_file
@stderr_log_path ||=
Redmine::Configuration['scm_stderr_log_file'].presence ||
Rails.root.join("log/#{Rails.env}.scm.stderr.log").to_s
end
def self.shellout(cmd, options = {}, &block) def self.shellout(cmd, options = {}, &block)
if logger && logger.debug? if logger && logger.debug?
logger.debug "Shelling out: #{strip_credential(cmd)}" logger.debug "Shelling out: #{strip_credential(cmd)}"
end end
if Rails.env == 'development' # Capture stderr in a log file
# Capture stderr when running in dev environment cmd = "#{cmd} 2>>#{shell_quote(stderr_log_file)}"
cmd = "#{cmd} 2>>#{shell_quote(Rails.root.join('log/scm.stderr.log').to_s)}"
end
begin begin
mode = "r+" mode = "r+"
IO.popen(cmd, mode) do |io| IO.popen(cmd, mode) do |io|