Developer Journal: 30 April 2020

Posted on Thu 30 April 2020 in dev-journal

Today is going to be a short coding session. My only plan is to write a test for an issue that is not allowing the rotation of site logs to work correctly. The problem is just a permission issue as the user does not have permission to write to the folder. While I'm in there I'm also going to clean a few things up because seeing a log directory on a busy server would look obnoxious, imagine the output below if you had 10 sites running on a server..:

$ ls /var/log/uwsgi    

First I am going to put each site in a subdirectory so the /var/log/uwsgi/ folder looks cleaner. There is already a test file to check the generated output against so I just need to update that file and this test that already exists will do the rest.

def test_format_site_ini_file(self):
    end_file = Provisioner.format_ini_file(site)
    with open(os.path.join(CURRENT_DIR, 'test_site_ini_file.txt'), 'r') as f:
        contents =
    self.assertEqual(contents, end_file)

To get the test to pass I just need to update a line in the template file to use the new subfolder structure, specifically this meant modifying the logto parameter to be /var/log/uwsgi/%n/%n.log