Server crashes are now dumped to log file.
This commit is contained in:
parent
cb5f1dbf9b
commit
08d2bf8bc9
101 changed files with 220 additions and 1807 deletions
|
|
@ -42,6 +42,9 @@ GNU Affero General Public License for more details.
|
|||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//Node Imports
|
||||
const fs = require('node:fs/promises')
|
||||
|
||||
//Config
|
||||
const config = require('../../config.json');
|
||||
|
||||
|
|
@ -92,7 +95,7 @@ module.exports.localExceptionHandler = function(err){
|
|||
//If we're being verbose
|
||||
if(config.verbose){
|
||||
//Log the error
|
||||
console.log(err)
|
||||
module.exports.dumpError(err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -191,6 +194,17 @@ module.exports.errorMiddleware = function(err, req, res, next){
|
|||
}
|
||||
|
||||
module.exports.errorHandler(res, err.message, reason, err.status);
|
||||
}
|
||||
|
||||
module.exports.dumpError = function(err, date = new Date()){
|
||||
try{
|
||||
console.log(err);
|
||||
console.log(JSON.stringify(err, null, 2));
|
||||
fs.writeFile(`log/crash/${date.getTime()}.log`, JSON.stringify(err, null, 2));
|
||||
}catch(err){
|
||||
module.exports.consoleWarn("Hey Dawg, I Heard you liked errors, so I got you an error while dumping your error to the error logs:");
|
||||
module.exports.consoleWarn(err);
|
||||
}
|
||||
}</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
|
@ -207,7 +221,7 @@ module.exports.errorMiddleware = function(err, req, res, next){
|
|||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a> on Sat Sep 06 2025 00:47:13 GMT-0400 (Eastern Daylight Time)
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a> on Sat Sep 06 2025 01:23:36 GMT-0400 (Eastern Daylight Time)
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue