Package couchdbkit
[hide private]
[frames] | no frames]

Source Code for Package couchdbkit

 1  # -*- coding: utf-8 - 
 2  # 
 3  # This file is part of couchdbkit released under the MIT license. 
 4  # See the NOTICE for more information. 
 5   
 6  from .version import version_info, __version__ 
 7   
 8  from .resource import  RequestFailed, CouchdbResource 
 9  from .exceptions import InvalidAttachment, DuplicatePropertyError,\ 
10  BadValueError, MultipleResultsFound, NoResultFound, ReservedWordError,\ 
11  DocsPathNotFound, BulkSaveError, ResourceNotFound, ResourceConflict, \ 
12  PreconditionFailed 
13   
14  from .client import Server, Database, ViewResults 
15  from .changes import ChangesStream 
16  from .consumer import Consumer 
17  from .designer import document, push, pushdocs, pushapps, clone 
18  from .external import External 
19  from .loaders import BaseDocsLoader, FileSystemDocsLoader 
20   
21  from .schema import ( 
22      Property, IntegerProperty, DecimalProperty, BooleanProperty, FloatProperty, StringProperty, 
23      DateTimeProperty, DateProperty, TimeProperty, 
24      dict_to_json, dict_to_json, dict_to_json, 
25      value_to_python, dict_to_python, 
26      DocumentSchema, DocumentBase, Document, StaticDocument, contain, 
27      QueryMixin, AttachmentMixin, 
28      SchemaProperty, SchemaListProperty, SchemaDictProperty, 
29      ListProperty, DictProperty, StringListProperty, SetProperty 
30  ) 
31   
32  import logging 
33   
34  LOG_LEVELS = { 
35      "critical": logging.CRITICAL, 
36      "error": logging.ERROR, 
37      "warning": logging.WARNING, 
38      "info": logging.INFO, 
39      "debug": logging.DEBUG 
40  } 
41   
42 -def set_logging(level, handler=None):
43 """ 44 Set level of logging, and choose where to display/save logs 45 (file or standard output). 46 """ 47 if not handler: 48 handler = logging.StreamHandler() 49 50 loglevel = LOG_LEVELS.get(level, logging.INFO) 51 logger = logging.getLogger('couchdbkit') 52 logger.setLevel(loglevel) 53 format = r"%(asctime)s [%(process)d] [%(levelname)s] %(message)s" 54 datefmt = r"%Y-%m-%d %H:%M:%S" 55 56 handler.setFormatter(logging.Formatter(format, datefmt)) 57 logger.addHandler(handler)
58