mik icon indicating copy to clipboard operation
mik copied to clipboard

Use relative file locations?

Open whikloj opened this issue 7 years ago • 1 comments

Just wondering how you felt about relative file locations? Especially for logs and the like? I see you specify your log location directly from the settings file in several locations so you'd need to centralize that a bit.

But otherwise I was thinking something like changing this https://github.com/MarcusBarnes/mik/blob/master/mik#L102-L106

to

// Set up logger ErrorException stream for main mik script.
$pathToLog = $settings['LOGGING']['path_to_log'];
if (!empty($pathToLog)) {
    $pathToLog = realpath($pathToLog);
    $logDir = dirname($pathToLog);
    if (!file_exists($logDir)) {
        if (! mkdir($logDir)) {
            throw new Exception(
              "Log directory (${logDir}) does not exist, unable to create"
            );
        }
    }
}
$log = new Logger('ErrorException');
$logStreamHandler= new StreamHandler($pathToLog, Logger::ERROR);
$log->pushHandler($logStreamHandler);

whikloj avatar Jun 26 '17 20:06 whikloj

@whikloj can you give an example value for ['LOGGING']['path_to_log']? Would it be something like "/path_to/my/logs"?

The main mik script already does define a relative path to problem_records.log:

https://github.com/MarcusBarnes/mik/blob/master/mik#L192-L199

Is that the kind of thing you're proposing? If so, we probably should clean up the code there and create a utility function to get the path in the interests of DRY. A reusable function would also let post-write hook scripts, etc. use it.

mjordan avatar Jun 26 '17 21:06 mjordan