Update logger settings

This commit is contained in:
Ramon Wenger 2021-03-05 11:14:05 +01:00
parent b9a32354ce
commit 62dec16667
3 changed files with 70 additions and 40 deletions

View File

@ -1,17 +1,16 @@
'use strict' 'use strict';
const path = require('path') const path = require('path');
const config = require('../config') const config = require('../config');
const VueLoaderPlugin = require('vue-loader/lib/plugin') const VueLoaderPlugin = require('vue-loader/lib/plugin');
const {isDev, styleRule, assetsPath} = require('./utils'); const {isDev, styleRule, assetsPath} = require('./utils');
function resolve(dir) { function resolve(dir) {
return path.join(__dirname, '..', dir) return path.join(__dirname, '..', dir);
} }
const createLintingRule = () => ({ const createLintingRule = () => ({
test: /\.(js|vue)$/, test: /\.(js|vue)$/,
loader: 'eslint-loader', loader: 'eslint-loader',
@ -19,9 +18,9 @@ const createLintingRule = () => ({
include: [resolve('src'), resolve('test')], include: [resolve('src'), resolve('test')],
options: { options: {
formatter: require('eslint-friendly-formatter'), formatter: require('eslint-friendly-formatter'),
emitWarning: !config.dev.showEslintErrorsInOverlay emitWarning: !config.dev.showEslintErrorsInOverlay,
} },
}) });
//todo: mini-css-extract-plugin? upgrade to webpack 4, then use this //todo: mini-css-extract-plugin? upgrade to webpack 4, then use this
//https://github.com/webpack-contrib/mini-css-extract-plugin //https://github.com/webpack-contrib/mini-css-extract-plugin
@ -29,21 +28,21 @@ const createLintingRule = () => ({
module.exports = { module.exports = {
context: path.resolve(__dirname, '../'), context: path.resolve(__dirname, '../'),
entry: { entry: {
app: './src/main.js' app: './src/main.js',
}, },
output: { output: {
path: config.build.assetsRoot, path: config.build.assetsRoot,
filename: '[name].js', filename: '[name].js',
publicPath: isDev publicPath: isDev
? config.dev.assetsPublicPath ? config.dev.assetsPublicPath
: config.build.assetsPublicPath : config.build.assetsPublicPath,
}, },
resolve: { resolve: {
extensions: ['.js', '.vue', '.json', '.gql', '.graphql', '.scss'], extensions: ['.js', '.vue', '.json', '.gql', '.graphql', '.scss'],
alias: { alias: {
'@': resolve('src'), '@': resolve('src'),
styles: resolve('src/styles') styles: resolve('src/styles'),
} },
}, },
module: { module: {
rules: [ rules: [
@ -56,53 +55,60 @@ module.exports = {
video: ['src', 'poster'], video: ['src', 'poster'],
source: 'src', source: 'src',
img: 'src', img: 'src',
image: 'xlink:href' image: 'xlink:href',
} },
} },
}, },
{ {
test: /\.js$/, test: /\.js$/,
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
presets: ['@babel/preset-env'] presets: ['@babel/preset-env'],
}, },
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')] include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')],
}, },
{ {
test: /\.(gql|graphql)$/, test: /\.(gql|graphql)$/,
loader: 'graphql-tag/loader', use: [
exclude: /node_modules/ {
loader: 'webpack-graphql-loader',
options: {
output: 'document',
},
},
],
exclude: /node_modules/,
}, },
{ {
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader', loader: 'url-loader',
options: { options: {
limit: 10000, limit: 10000,
name: assetsPath('img/[name].[hash:7].[ext]') name: assetsPath('img/[name].[hash:7].[ext]'),
} },
}, },
{ {
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader', loader: 'url-loader',
options: { options: {
limit: 10000, limit: 10000,
name: assetsPath('media/[name].[hash:7].[ext]') name: assetsPath('media/[name].[hash:7].[ext]'),
} },
}, },
{ {
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader', loader: 'url-loader',
options: { options: {
limit: 10000, limit: 10000,
name: assetsPath('fonts/[name].[hash:7].[ext]') name: assetsPath('fonts/[name].[hash:7].[ext]'),
} },
}, },
styleRule(false), // css rule styleRule(false), // css rule
styleRule(true) // sass rule styleRule(true), // sass rule
] ],
}, },
plugins: [ plugins: [
new VueLoaderPlugin() new VueLoaderPlugin(),
], ],
node: { node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue // prevent webpack from injecting useless setImmediate polyfill because Vue
@ -114,6 +120,6 @@ module.exports = {
fs: 'empty', fs: 'empty',
net: 'empty', net: 'empty',
tls: 'empty', tls: 'empty',
child_process: 'empty' child_process: 'empty',
} },
} };

5
server/core/logger.py Normal file
View File

@ -0,0 +1,5 @@
import logging
def get_logger(name):
return logging.getLogger(f'skillbox.{name}')

View File

@ -290,6 +290,9 @@ LOGGING = {
'simple_format': { 'simple_format': {
'format': '%(levelname)s %(name)s: %(message)s' 'format': '%(levelname)s %(name)s: %(message)s'
}, },
'debug_format': {
'format': '__debug__ %(levelname)s %(name)s: %(message)s'
}
}, },
'disable_existing_loggers': True, 'disable_existing_loggers': True,
'handlers': { 'handlers': {
@ -300,20 +303,37 @@ LOGGING = {
'console': { 'console': {
'level': 'INFO', 'level': 'INFO',
'class': 'logging.StreamHandler', 'class': 'logging.StreamHandler',
'stream': sys.stdout,
'formatter': 'simple_format' 'formatter': 'simple_format'
}, },
'debug_console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'debug_format'
}
}, },
'loggers': { 'loggers': {
'': { '': {
'handlers': ['console'], 'handlers': ['console'],
'level': 'INFO', 'level': 'WARNING'
'propagate': True,
}, },
'django.security.DisallowedHost': { 'skillbox': {
'handlers': ['mail_admins'], 'handlers': ['console'],
'level': 'CRITICAL', 'level': 'INFO',
'propagate': False, 'propagate': False
},
'graphql': {
'handlers': ['console'],
'level': 'WARNING',
'propagate': False
},
'django': {
'handlers': ['console'],
'level': 'WARNING'
},
'django.server': {
'handlers': ['console'],
'level': 'WARNING',
'propagate': True,
}, },
} }
} }
@ -400,7 +420,6 @@ TASKBASE_SUPERPASSWORD = os.environ.get("TASKBASE_SUPERPASSWORD")
TASKBASE_BASEURL = os.environ.get("TASKBASE_BASEURL") TASKBASE_BASEURL = os.environ.get("TASKBASE_BASEURL")
ENABLE_SPELLCHECK = True if TASKBASE_BASEURL else False ENABLE_SPELLCHECK = True if TASKBASE_BASEURL else False
TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner'
TEST_OUTPUT_DIR = './test-reports/' TEST_OUTPUT_DIR = './test-reports/'
TEST_OUTPUT_VERBOSE = 1 TEST_OUTPUT_VERBOSE = 1