Revision 653b0597 kamaki/kamaki.py

b/kamaki/kamaki.py
50 50
RCFILE = '.kamakirc'
51 51

  
52 52

  
53
log = logging.getLogger('kamaki')
54

  
55

  
53 56
def print_addresses(addresses, margin):
54 57
    for address in addresses:
55 58
        if address['id'] == 'public':
......
156 159
        self.parser = parser
157 160
    
158 161
    def _init_logging(self):
159
        ch = logging.StreamHandler()
160
        ch.setFormatter(logging.Formatter('%(message)s'))
161
        logger = logging.getLogger()
162
        logger.addHandler(ch)
163
        
164 162
        if self.debug:
165
            level = logging.DEBUG
163
            log.setLevel(logging.DEBUG)
166 164
        elif self.verbose:
167
            level = logging.INFO
165
            log.setLevel(logging.INFO)
168 166
        else:
169
            level = logging.WARNING
167
            log.setLevel(logging.WARNING)
170 168
        
171
        logger.setLevel(level)
172
    
173 169
    def _init_conf(self):
174 170
        if not self.api:
175 171
            self.api = os.environ.get(API_ENV, None)
......
258 254
            for p in self.personality:
259 255
                lpath, sep, rpath = p.partition(',')
260 256
                if not lpath or not rpath:
261
                    logging.error("Invalid personality argument '%s'", p)
257
                    log.error("Invalid personality argument '%s'", p)
262 258
                    return
263 259
                if not os.path.exists(lpath):
264
                    logging.error("File %s does not exist", lpath)
260
                    log.error("File %s does not exist", lpath)
265 261
                    return
266 262
                with open(lpath) as f:
267 263
                    personality.append((rpath, f.read()))
......
663 659
        cmd = cls(argv)
664 660
        cmd.execute()
665 661
    except ClientError, err:
666
        logging.error('%s', err.message)
667
        logging.info('%s', err.details)
662
        log.error('%s', err.message)
663
        log.info('%s', err.details)
668 664

  
669 665

  
670 666
if __name__ == '__main__':
667
    ch = logging.StreamHandler()
668
    ch.setFormatter(logging.Formatter('%(message)s'))
669
    log.addHandler(ch)
670
    
671 671
    main()

Also available in: Unified diff