var winston = require('winston');
var Config = require('../.').Config;
var HazelcastClient = require('../.').Client;

if(process.argv.length != 3){
    console.log('You must give exactly one argument to run this tool!!!');
}else{


    var cfg = new Config.ClientConfig();
    cfg.properties['hazelcast.logging'] = process.argv[2];
    
    switch (cfg.properties['hazelcast.logging']){
       
        case 'winston':
            var winstonAdapter = {
                logger: new (winston.Logger)({
                    transports: [
                        new (winston.transports.Console)()
                    ]
                }),

                levels: [
                    'error',
                    'warn',
                    'info',
                    'debug',
                    'silly'
                ],

                log: function(level, className, message, furtherInfo) {
                    this.logger.log(this.levels[level], className + ' ' + message);
                }
            };
            
            
            //winston logging is active in case of winston object given as property
            cfg.properties['hazelcast.logging'] = winstonAdapter;
            break;
            
       
        case 'default':
            cfg.properties['hazelcast.logging'] = 'default';
            break;
       
        case 'empty':
            cfg.properties['hazelcast.logging'] = 'default';
            break;
       
        case 'off':
            cfg.properties['hazelcast.logging'] = 'off';
            console.log('Client starting with off-logger');
            break;
        
        default:
            cfg.properties['hazelcast.logging'] = 'unknown';
            console.log('Options for logging are '+'1-)winston 2-)default 3-)empty, 4-)off');
            break;
    }

    if(cfg.properties['hazelcast.logging'] != 'unknown')   {
        HazelcastClient.newHazelcastClient(cfg).then(function(client){
            client.shutdown(); 
        });
    }
}


@@ -162,74 +162,101 @@
 og('
-You must give exactly one argument to run this tool!!!
+Run as node logging.js %5Blogger%5D');%0A    console.log('%5Blogger%5D: winston/default/off
 ');%0A%7D
+ 
 else
+ 
 %7B
-%0A%0A
 %0A   
@@ -297,158 +297,50 @@
 ();%0A
+%0A
     
-cfg.properties%5B'hazelcast.logging'%5D = process.argv%5B2%5D;%0A    %0A    switch (cfg.properties%5B'hazelcast.logging'%5D)%7B%0A       %0A        case 'winston':%0A    
+if (process.argv%5B2%5D === 'winston') %7B%0A
     
@@ -366,20 +366,16 @@
 ter = %7B%0A
-    
         
@@ -425,20 +425,16 @@
         
-    
 transpor
@@ -435,28 +435,24 @@
 ansports: %5B%0A
-    
             
@@ -514,18 +514,10 @@
     
-    %5D%0A    
+%5D%0A
     
@@ -541,20 +541,16 @@
         
-    
 levels: 
@@ -547,28 +547,24 @@
   levels: %5B%0A
-    
             
@@ -596,20 +596,16 @@
     
-    
 'warn',%0A
     
@@ -600,20 +600,16 @@
 'warn',%0A
-    
         
@@ -640,20 +640,16 @@
         
-    
 'debug',
@@ -649,20 +649,16 @@
 debug',%0A
-    
         
@@ -689,20 +689,12 @@
     
-    %5D,%0A%0A    
+%5D,%0A%0A
     
@@ -773,20 +773,16 @@
         
- 
-   
 this.log
@@ -853,18 +853,10 @@
     
-    %7D%0A    
+%7D%0A
     
@@ -874,866 +874,145 @@
     
-    %0A            %0A            //winston logging is active in case of winston object given as property%0A            cfg.properties%5B'hazelcast.logging'%5D = winstonAdapter;%0A            break;%0A            %0A       %0A        case 'default':%0A            cfg.properties%5B'hazelcast.logging'%5D = 'default';%0A            break;%0A       %0A        case 'empty':%0A            cfg.properties%5B'hazelcast.logging'%5D = 'default';%0A            break;%0A       %0A        case 'off':%0A            cfg.properties%5B'hazelcast.logging'%5D = 'off';%0A            console.log('Client starting with off-logger');%0A            break;%0A        %0A        default:%0A            cfg.properties%5B'hazelcast.logging'%5D = 'unknown';%0A            console.log('Options for logging are '+'1-)winston 2-)default 3-)empty, 4-)off');%0A            break;
+cfg.properties%5B'hazelcast.logging'%5D = winstonAdapter;%0A    %7D else %7B%0A        cfg.properties%5B'hazelcast.logging'%5D = process.argv%5B2%5D;%0A
 %0A    %7D%0A
-%0A
-    if(cfg.properties%5B'hazelcast.logging'%5D != 'unknown')   %7B%0A    
     
@@ -1082,20 +1082,16 @@
         
-    
 client.s
@@ -1104,27 +1104,16 @@
 n();
- %0A   
+%0A
     
- 
 %7D);%0A
-    %7D%0A
 %7D%0A%0A

Refactor logging code sample