{"_id":"553d394e9660ba0d00569d1d","user":"543466ea0e8e2b0e00341818","category":{"_id":"553d394d9660ba0d00569d08","pages":["553d394e9660ba0d00569d13","553d394e9660ba0d00569d14","553d394e9660ba0d00569d15","553d394e9660ba0d00569d16","553d394e9660ba0d00569d17","553d394e9660ba0d00569d18","553d394e9660ba0d00569d19","553d394e9660ba0d00569d1a","553d394e9660ba0d00569d1b","553d394e9660ba0d00569d1c","553d394e9660ba0d00569d1d","553d394e9660ba0d00569d1e","553d394e9660ba0d00569d1f","553d394e9660ba0d00569d20","553d394e9660ba0d00569d21","553d394e9660ba0d00569d22","553d394e9660ba0d00569d23"],"project":"543467200ef9c00800164ecc","version":"553d394d9660ba0d00569d07","__v":1,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-15T18:00:23.862Z","from_sync":false,"order":0,"slug":"glim","title":"GLIM"},"version":{"_id":"553d394d9660ba0d00569d07","project":"543467200ef9c00800164ecc","forked_from":"54bedb2fffb79c320030db1f","__v":1,"createdAt":"2015-04-26T19:15:25.245Z","releaseDate":"2015-04-26T19:15:25.245Z","categories":["553d394d9660ba0d00569d08","553d394d9660ba0d00569d09"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"0.11.2","version":"0.11.2"},"githubsync":"","__v":0,"project":"543467200ef9c00800164ecc","metadata":{"title":"","description":"","image":[]},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-10-15T18:16:52.130Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"never","params":[],"url":""},"isReference":false,"order":8,"body":"Glim has logging feature using python's standart `logging` module. In glim, there exists 2 types(instances) of logging module. One of them is the \"app\" logger that is used inside web application flow. The other one is called \"glim\" logger which is used internally inside the framework. You can configure logging by the `log` key of configuration;\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"# app/config/<env>.py\\nconfig = {\\n  # ...\\n\\t'log' : {\\n  \\t\\t'app' : {\\n          'level': 'info',\\n          'format': '[%(levelname)s] - application : %(message)s',\\n          'colored': True,\\n          'file' : 'app/storage/logs/app.log'\\n      },\\n    \\t'glim' : {\\n          'level' : 'info',\\n          'format' : '[%(levelname)s] : %(message)s',\\n          'colored': True\\n          'file' : 'app/storage/logs/glim.log'  \\n    \\t},\\n  },\\n  # ...\\n}\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\nThis dictionary means that the logging will be done in \"info\" level and the format will be like \n\"[INFO] : msg\". `file` key stands for the file path of the log file. These keys have default values. If you don't provide a particular key, the default one will be configured. Here is a mapping of the default keys;\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"key\",\n    \"0-0\": \"level\",\n    \"h-1\": \"default value\",\n    \"0-1\": \"debug\",\n    \"1-0\": \"format\",\n    \"1-1\": \"\\\"%(message)s\\\"\",\n    \"2-0\": \"file\",\n    \"2-1\": \"STD_OUT\",\n    \"3-0\": \"colored\",\n    \"3-1\": \"True\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Usage\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"from glim import Log\\n\\n# write a colorless string in debug level\\nLog.write('this is a log without color in debug level')\\n\\n# log info level\\nLog.info('this is info') \\n\\n# log warning level\\nLog.warning('this is warning')\\n\\n# log debug level\\nLog.debug('this is debug')\\n\\n# log error level\\nLog.error('this is error')\\n\\n# log critical level\\nLog.critical('this is critical')\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"logging","type":"basic","title":"Logging"}
Glim has logging feature using python's standart `logging` module. In glim, there exists 2 types(instances) of logging module. One of them is the "app" logger that is used inside web application flow. The other one is called "glim" logger which is used internally inside the framework. You can configure logging by the `log` key of configuration; [block:code] { "codes": [ { "code": "# app/config/<env>.py\nconfig = {\n # ...\n\t'log' : {\n \t\t'app' : {\n 'level': 'info',\n 'format': '[%(levelname)s] - application : %(message)s',\n 'colored': True,\n 'file' : 'app/storage/logs/app.log'\n },\n \t'glim' : {\n 'level' : 'info',\n 'format' : '[%(levelname)s] : %(message)s',\n 'colored': True\n 'file' : 'app/storage/logs/glim.log' \n \t},\n },\n # ...\n}", "language": "python" } ] } [/block] This dictionary means that the logging will be done in "info" level and the format will be like "[INFO] : msg". `file` key stands for the file path of the log file. These keys have default values. If you don't provide a particular key, the default one will be configured. Here is a mapping of the default keys; [block:parameters] { "data": { "h-0": "key", "0-0": "level", "h-1": "default value", "0-1": "debug", "1-0": "format", "1-1": "\"%(message)s\"", "2-0": "file", "2-1": "STD_OUT", "3-0": "colored", "3-1": "True" }, "cols": 2, "rows": 4 } [/block] [block:api-header] { "type": "basic", "title": "Usage" } [/block] [block:code] { "codes": [ { "code": "from glim import Log\n\n# write a colorless string in debug level\nLog.write('this is a log without color in debug level')\n\n# log info level\nLog.info('this is info') \n\n# log warning level\nLog.warning('this is warning')\n\n# log debug level\nLog.debug('this is debug')\n\n# log error level\nLog.error('this is error')\n\n# log critical level\nLog.critical('this is critical')", "language": "python" } ] } [/block]