This repository has been archived by the owner on Mar 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
shengxiang
committed
Mar 10, 2016
1 parent
6132ce6
commit 9035a56
Showing
4 changed files
with
34 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
|
||
import logging | ||
|
||
|
||
_inited = {} | ||
|
||
def getLogger(name): | ||
logger = logging.getLogger(name) | ||
if not _inited.get(name): | ||
ch = logging.StreamHandler() | ||
_inited[name] = ch | ||
fmt = "%(asctime)s %(levelname)-8.8s [%(name)s:%(lineno)4s] %(message)s" | ||
formatter = logging.Formatter(fmt) | ||
ch.setFormatter(formatter) | ||
logger.addHandler(ch) | ||
return logger | ||
|
||
|
||
if __name__ == '__main__': | ||
log = getLogger('test') | ||
log.setLevel(logging.DEBUG) | ||
log.info("Hello") | ||
log.debug("dd Hello") | ||
log = getLogger('test') | ||
log.warn("dd Hello") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters