mirror of
https://github.com/mathew-kurian/Scribe.js
synced 2025-09-12 03:31:11 +00:00
Add getUser() function
Useful to add active user name in log path
This commit is contained in:
parent
cc7479eb9c
commit
4c17b1badf
1 changed files with 31 additions and 0 deletions
|
@ -90,6 +90,37 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LogWriter.prototype.getUser
|
||||||
|
*
|
||||||
|
* Tool, return active user
|
||||||
|
*
|
||||||
|
* @return {String}
|
||||||
|
*/
|
||||||
|
LogWriter.prototype.getUser = function () {
|
||||||
|
|
||||||
|
var user = '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
var platformKey = process.platform === 'win32' ? 'USERPROFILE' : 'HOME',
|
||||||
|
platformDivider = process.platform === 'win32' ? '\\' : '/';
|
||||||
|
|
||||||
|
|
||||||
|
var userDir = process.env[platformKey].toLowerCase();
|
||||||
|
user = userDir.slice(userDir.lastIndexOf(platformDivider) + 1);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
user = 'user'; //default
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LogWriter.prototype.getPath
|
* LogWriter.prototype.getPath
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue