diff --git a/src/logging.js b/src/logging.js index d1e07aee993ad9267e16aa894e04d0a7ee7cd121..25b45eb61f83f4f965337a44180f68cf28151fa1 100644 --- a/src/logging.js +++ b/src/logging.js @@ -60,6 +60,21 @@ class LoggingClass { */ constructor(logging_dir) { + // First validate passed logging value. Start by checking if string. + if (typeof logging_dir === 'string' || logging_dir instanceof String) { + // Is string. Validate. + logging_dir = logging_dir.trim(); + + // Check last character. + if (logging_dir.slice(-1) != '/') { + logging_dir += '/'; + } + + } else { + // Is not string. Raise error. + throw new Error('Logging class must be initialized with directory location.'); + } + // Attempt to create logging folder. fs.mkdir(logging_dir, err => { // Ignore "dir already exists" errors. Raise all others.