logorbit
v1.2.1
Published
Simple and lightweight logging library for Node.JS applications
Downloads
2
Maintainers
Readme
This project is still under heavy development
LogOrbit
LogOrbit is a simple and lightweight logging library for Node.JS applications. It provides an effortless way to log various types of information, from errors to debug messages, with minimal setup.
Table Of Contents
Changelog [1.2.1] - 2023-08-20
Added
- Introduced the
setDirName()
function to set a name for logging directory
Changed
- Restructured README.md
Installation
Install LogOrbit using npm or yarn:
npm install logorbit
or if you prefer yarn:
yarn add logorbit
Usage
Setting Logging Directory (Optional)
Use the setDirName
function to specity a directory name for storing all the generated logs
const logorbit = require("logorbit")
logorbit.setDirName("Logs") // Default dir name is "orbitlogs"
Setting Logging Method (Optional)
Use the setLog()
function to set the logging method to json or plain text.
const logorbit = require("logorbit")
logorbit.setDirName("Logs") // Default dir name is "orbitlogs"
logorbit.setLog("json")
This will set the logging method to json
or
const logorbit = require("logorbit")
logorbit.setDirName("Logs") // Default dir name is "orbitlogs"
logorbit.setLog("text")
This will set the logging method to plain text
Logging errors
Utilize the logError()
function to record various error messages in either JSON or text format, depending on the chosen method
const logorbit = require("logorbit")
logorbit.setDirName("Logs") // Default dir name is "orbitlogs"
logorbit.setLog("text")
var error = "some error"
logorbit.logError(error)
Text: error.txt
19-08-2023 20:08:45: Some error
JSON error.json
[
{
"timestamp": "19-08-2023 20:08:45",
"message": "Some error"
}
]
This action will generate a directory named orbitlogs
within your project's root folder if it doesn't already exist. Inside this directory, a file named errors.txt
will be created to store all error logs
Logging Debug Messages
Utilize the logDebug()
function to record debug messages in chosen file format
const logorbit = require("logorbit")
logorbit.setDirName("Logs") // Default dir name is "orbitlogs"
logorbit.setLog("text")
logorbit.logDebug("Server started on port 5000")
Text: debug.txt
19-08-2023 20:08:45: Port set to 5000
JSON debug.json
[
{
"timestamp": "19-08-2023 20:08:45",
"message": "Server started on port 5000"
}
]
This action will generate a directory named orbitlogs
within your project's root folder if it doesn't already exist. Inside this directory, a file named debug.txt
will be created to store all error logs
Contributing
Contributions are more than welcome! If you find issues or have improvements in mind, please don't hesitate to open an issue or submit a pull request on the GitHub respository
License
This project is licensed under the MIT License, For more information, see the LICENSE file.