1+ var os = require ( 'os' ) ,
2+ send = require ( './sender' ) ,
3+ access = require ( '.access' ) ,
4+ logger = require ( './logger' ) ,
5+ CONFIG = require ( './config' ) ,
6+ pkginfo = require ( 'pkginfo' ) ( module , 'name' ) ,
7+
8+ options = {
9+ host : CONFIG . HOST ,
10+ port : CONFIG . PORT ,
11+ method : 'POST' ,
12+ headers : {
13+ Content - Type : 'application/json' ,
14+ X- Stackify - Key : CONFIG . LICENSE_KEY ,
15+ X - Stackify - PV : 'V1'
16+ }
17+ }
18+
19+ module . exports = {
20+
21+ identifyApp : function identifyApp ( licenseKey ) {
22+ var options = options ,
23+ data = {
24+ "DeviceName" : os . hostname ( ) ,
25+ "AppName" : module . exports . name
26+ } ,
27+ callback = function ( data ) {
28+ CONFIG . APP_DETAILS = data . toJSON ( ) ;
29+ } ,
30+ fail = function ( ) {
31+ setTimeout ( function ( ) {
32+ identifyApp ( licenseKey )
33+ } , CONFIG . REQUEST_TIMER )
34+ }
35+
36+ options . path = CONFIG . IDENTIFY_PATH ;
37+
38+ send ( options , data , callback , fail ) ;
39+ } ;
40+
41+ postLogs: function postLogs ( messages , cb , fail ) {
42+ var options = options ,
43+ callback = cb || function ( data ) {
44+ logger . storage = logger . storage . slice ( CONFIG . MSG_LIMIT )
45+ } ,
46+ fail = function ( ) {
47+ setTimeout ( function ( ) {
48+ postLogs ( messages , callback , fail )
49+ } , CONFIG . REQUEST_TIMER )
50+ } ,
51+ data = CONFIG . APP_DETAILS ;
52+
53+ data . Msgs = messages ;
54+ options . path = CONFIG . LOG_SAVE_PATH ;
55+
56+ send ( options , data , callback , fail ) ;
57+ } ;
58+ }
0 commit comments