import logging
from logging.handlers import TimedRotatingFileHandler
import sys
def get_logger():
logger = logging.getLogger()
hd = logging.StreamHandler(sys.stdout)
# hd = TimedRotatingFileHandler('mylog.log', when='D',maxBytes=10240000 backupCount=30)
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
hd.setFormatter(formatter)
logger.addHandler(hd)
logger.setLevel(logging.DEBUG)
return logger
月度归档:2018年10月
Yii2 composer安装慢的解决办法
修改fxp-asset为Asset Packagist
参考官方安装指南Yii advanced template installation提到:
It uses asset-packagist for managing bower and npm package dependencies through Composer. Also you can use asset-plugin, as in earlier versions, but it works slowly.
找到
"config": {
"process-timeout": 1800,
"fxp-asset":{
"installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
},
"replace": {
"bower-asset/jquery": ">=1.11.0",
"bower-asset/inputmask": ">=3.2.0",
"bower-asset/punycode": ">=1.3.0",
"bower-asset/yii2-pjax": ">=2.0.0"
}
修改为
"config": {
"process-timeout": 1800,
"fxp-asset": {
"enabled": false
}
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
]
修改config/main.php
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
Asset Packagist介绍
from https://asset-packagist.org/
Composer + Bower + NPM = friends forever!
This repository allows installation of Bower and NPM packages as native Composer packages.
NO plugins and NO Node.js are required.
At the moment we’ve added most popular Bower and NPM packages 4000+ each.
In case Composer fails to install some asset package, use the search line at the top of the page to check specific package health.
For NPM scoped packages use scope--package
instead of @scope/package
, e.g. npm-asset/pusher--chatkit
.
Got tired of fxp/composer-asset-plugin.
Why Asset Packagist
Got tired of fxp/composer-asset-plugin.
It’s a good project with nice idea and good implementation. But it has some issues: it slows down composer update a lot and requires global installation, so affects all projects. Also there are Travis and Scrutinizer integration special problems, that are a bit annoying.