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

Change location of log file in REDCap #19

Closed
frdougal opened this issue Dec 6, 2018 · 2 comments
Closed

Change location of log file in REDCap #19

frdougal opened this issue Dec 6, 2018 · 2 comments
Assignees

Comments

@frdougal
Copy link
Contributor

frdougal commented Dec 6, 2018

Hi Chuck!

I’m not sure if anyone else has this problem, but I do not have access to the directory where my Python interpreter lives (error below). Since I would also prefer to log adjacent to the code I’m executing, I patched up the redcapToCdm.py with the code fragment at the bottom, with my stuff in bold.

I’m not sure if you would want to merge something like this into the file. I’m not going to put in a pull request, since I have other JHU-specific code in our file you wouldn’t be interested in.

Thanks!
Karl

Traceback (most recent call last):
File "U:\PCORI\Dev\PRO\path-redcap-to-cdm-1.1-JHUMerge\path-redcap-to-cdm-master\redcapToCdm.py", line 717, in
logging.basicConfig(filename='redcap.log.' + str(os.getpid()),level=logging.DEBUG, format='%(asctime)s: %(levelname)s - %(message)s')
File "e:\python27\lib\logging_init_.py", line 1540, in basicConfig
hdlr = FileHandler(filename, mode)
File "e:\python27\lib\logging_init_.py", line 911, in init
StreamHandler.init(self, self.open())
File "e:\python27\lib\logging_init
.py", line 936, in _open
stream = open(self.baseFilename, self.mode)
IOError: [Errno 13] Permission denied: 'C:\Windows\system32\redcap.log.3952'

if name == "main":
# use this command to disable the InsecurePlatformWarning (see http://stackoverflow.com/questions/29099404/ssl-insecureplatform-error-when-using-requests-package)
requests.packages.urllib3.disable_warnings()

logDir = os.path.join(os.path.dirname(os.path.dirname(__file__)),'logs')
if not os.path.isdir(logDir):
    print 'The logging directory does not exist: ' + logDir
    exit(1)
logFile = os.path.join(logDir,'redcap.log.' + str(os.getpid()))

logging.basicConfig(filename = os.path.normpath(logFile), level=logging.DEBUG, format='%(asctime)s: %(levelname)s - %(message)s')
@frdougal frdougal self-assigned this Dec 6, 2018
frdougal added a commit that referenced this issue Dec 10, 2018
@frdougal
Copy link
Contributor Author

Karl will review

@frdougal
Copy link
Contributor Author

Feedback from Karl:

Hi Chuck!

After getting my PIP updates done, I don’t have much other feedback than what I typed in the lists below. I’ve attached my redcapToCdm.py, just in case you want to diff it (like I said, though, I’m sticking with some of the directory navigation stuff rather than direct entry in config.ini, mostly because of the too-high-level error message when I fail to update config.ini for a migration to my Prod directory).

The only thing I will add is that using the logger outside of the loadConfigFile() method isn’t working for me e.g. the “Finished REDCap ETL…” statement at the end does not get logged for me. I suspect maybe the logger is only attached within that method scope. I meant to try moving the basicConfig() call to global scope, but haven’t gotten to it.

But you can make the patch as review by me.

Thanks!
Karl

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