@@ -2,6 +2,7 @@ var url = require('url'),
22 os = require ( 'os' ) ,
33
44 helpers = require ( './helpers' ) ,
5+ exc = require ( './exception' ) ,
56 CONFIG = require ( '../config/config' ) ,
67
78 // object that contains all the errors and their numbers logged during the current minute
@@ -39,15 +40,29 @@ module.exports = {
3940 return errorStorage [ min ] [ key ] <= CONFIG . MSG . MAX_DUP_ERROR_PER_MINUTE ;
4041 } ,
4142
42- // getting source method and source method line of code
43- getStackTraceItem : function getStackTraceItem ( err ) {
44- var trace = helpers . getTrace ( err ) ;
45- return {
46- SrcMethod : trace [ 0 ] . Method ,
47- SrcLine : trace [ 0 ] . LineNum
48- } ;
43+ // getting source method and source method line of code, not_direct is a flag indicating if the message was sent via direct logger
44+ getStackTraceItem : function getStackTraceItem ( err , not_direct ) {
45+ var trace = helpers . getTrace ( err ) ,
46+ result = { } ,
47+ lastElement = trace [ trace . length - 1 ] ;
48+
49+ if ( not_direct && ! exc . excCaught ) {
50+ if ( lastElement . CodeFileName === 'module.js' ) {
51+ result . SrcMethod = trace [ trace . length - 2 ] . Method ;
52+ result . SrcLine = trace [ trace . length - 2 ] . LineNum ;
53+ } else {
54+ result . SrcMethod = lastElement . Method ;
55+ result . SrcLine = lastElement . LineNum ;
56+ }
57+ } else {
58+ result . SrcMethod = trace [ 0 ] . Method ;
59+ result . SrcLine = trace [ 0 ] . LineNum ;
60+ }
61+
62+ return result ;
4963 } ,
5064
65+
5166 // create the exception details object
5267 formatEx : function formatEx ( err , req , msg ) {
5368 var trace = helpers . getTrace ( err ) ,
0 commit comments