cocalc/src / smc-project / node_modules / broadway / node_modules / winston / lib / winston / exception.js
50663 views/*1* exception.js: Utility methods for gathing information about uncaughtExceptions.2*3* (C) 2010 Charlie Robbins4* MIT LICENCE5*6*/78var os = require('os'),9stackTrace = require('stack-trace');1011var exception = exports;1213exception.getAllInfo = function (err) {14return {15date: new Date().toString(),16process: exception.getProcessInfo(),17os: exception.getOsInfo(),18trace: exception.getTrace(err),19stack: err.stack && err.stack.split('\n')20};21};2223exception.getProcessInfo = function () {24return {25pid: process.pid,26uid: process.getuid ? process.getuid() : null,27gid: process.getgid ? process.getgid() : null,28cwd: process.cwd(),29execPath: process.execPath,30version: process.version,31argv: process.argv,32memoryUsage: process.memoryUsage()33};34};3536exception.getOsInfo = function () {37return {38loadavg: os.loadavg(),39uptime: os.uptime()40};41};4243exception.getTrace = function (err) {44var trace = err ? stackTrace.parse(err) : stackTrace.get();45return trace.map(function (site) {46return {47column: site.getColumnNumber(),48file: site.getFileName(),49function: site.getFunctionName(),50line: site.getLineNumber(),51method: site.getMethodName(),52native: site.isNative(),53}54});55};565758