Created
December 18, 2019 01:44
-
-
Save satomacoto/e347e5045a76d36844e51c8f86811744 to your computer and use it in GitHub Desktop.
logging for jupyter
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import logging\n", | |
"import sys\n", | |
"\n", | |
"logging.basicConfig(\n", | |
" stream=sys.stdout,\n", | |
" level=logging.INFO,\n", | |
" format=\"%(asctime)s - %(name)s - %(levelname)s - %(message)s\"\n", | |
")" | |
], | |
"outputs": [], | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false, | |
"outputHidden": false, | |
"inputHidden": false | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"logger = logging.getLogger(__name__)" | |
], | |
"outputs": [], | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false, | |
"outputHidden": false, | |
"inputHidden": false | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"logger.debug(\"debug\")" | |
], | |
"outputs": [], | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false, | |
"outputHidden": false, | |
"inputHidden": false | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"logger.info(\"info\")" | |
], | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"2019-12-18 10:43:20,896 - __main__ - INFO - info\n" | |
] | |
} | |
], | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false, | |
"outputHidden": false, | |
"inputHidden": false | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"logger.warning(\"warning\")\n", | |
"logger.error(\"error\")" | |
], | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"2019-12-18 10:43:36,858 - __main__ - WARNING - warning\n", | |
"2019-12-18 10:43:36,859 - __main__ - ERROR - error\n" | |
] | |
} | |
], | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": false, | |
"outputHidden": false, | |
"inputHidden": false | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [], | |
"outputs": [], | |
"execution_count": null, | |
"metadata": { | |
"collapsed": false, | |
"outputHidden": false, | |
"inputHidden": false | |
} | |
} | |
], | |
"metadata": { | |
"kernel_info": { | |
"name": "python3" | |
}, | |
"language_info": { | |
"name": "python", | |
"version": "3.6.4", | |
"mimetype": "text/x-python", | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"pygments_lexer": "ipython3", | |
"nbconvert_exporter": "python", | |
"file_extension": ".py" | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"language": "python", | |
"display_name": "Python 3" | |
}, | |
"nteract": { | |
"version": "0.12.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment