logpath

0.3.4 • Public • Published

logpath

NPM version NPM downloads Dependencies MIT License

A simple module to get a custom node.js app log dir path across platforms

Install

$ npm install --save logpath

Use

const logpath = require('logpath');

const logDirPath = logpath.createAndGetLogDirPath();

logpath creates directory if not found and tries to return log directory paths in the following order:

On Linux

  1. /var/log/${APP_NAME}
  2. ${XDG_CONFIG_HOME}/${APP_NAME}
  3. ${HOME}/.config/${APP_NAME}
  4. ${XDG_DATA_HOME}/${APP_NAME}
  5. ${HOME}/.local/share/${APP_NAME}

On MacOS

  1. ${HOME}/Library/Logs/${APP_NAME}
  2. ${HOME}/Library/Application Support/${APP_NAME}

On Windows

  1. ${APPDATA}/${APP_NAME}
  2. ${HOME}/AppData/Roaming/${APP_NAME}

Where ${APP_NAME} is the name of the application using logpath, retrieved from package.json

Default

On any other platform, or if the directory path could not be returned (e.g. due to lack of read/write privileges), logpath will try and create a logs dir under the application's root folder.

Package Sidebar

Install

npm i logpath

Weekly Downloads

5

Version

0.3.4

License

MIT

Last publish

Collaborators

  • akb89