~jstys-z/helioviewer.org/client5

« back to all changes in this revision

Viewing changes to install/helioviewer/__init__.py

  • Committer: Keith Hughitt
  • Date: 2012-04-23 19:07:32 UTC
  • mto: This revision was merged to the branch mainline in revision 732.
  • Revision ID: keith.hughitt@nasa.gov-20120423190732-40hc0ond3dhvo9ek
Reorganized installer and downloader code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Helioviewer Python utility mehtods"""
 
2
import os
 
3
import logging
 
4
 
 
5
def init_logger(filepath):
 
6
    """Initializes logging"""
 
7
    # Check for logging directory
 
8
    directory, filename = os.path.split(os.path.expanduser(filepath))
 
9
    
 
10
    if not os.path.exists(directory):
 
11
        os.makedirs(directory)
 
12
        
 
13
    os.chdir(directory)
 
14
        
 
15
    # TODO: Rotate logs
 
16
    # e.g. Move previous log to hvpull.log.1, hvpull.log.1 to hvpull.log.2, etc
 
17
    # and delete any logs greater than 10.    
 
18
    logging.basicConfig(filename=filename, level=logging.INFO,
 
19
                        format='%(asctime)s.%(msecs)03d [%(levelname)s] %(message)s',
 
20
                        datefmt='%Y-%m-%d %H:%M:%S')
 
21
    
 
22
    # Also log INFO or higher messages to STDOUT
 
23
    console = logging.StreamHandler()
 
24
    console.setLevel(logging.INFO)
 
25
    logging.getLogger('').addHandler(console)
 
 
b'\\ No newline at end of file'