Better debug management

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
Change default datadir to use the path of the file instead of the
last path the system was

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
Create the log directory if it doesn't exist yet

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
Use os.path.join to format file paths

Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>