有没有办法让Python logging
每次运行脚本/应用程序时都创建一个新的日志文件?我只是想创建一个名称像时间戳一样独特的日志。
知道如何配置记录器来执行此操作吗?
logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': False,
'handlers': {
"file": {
"level": "DEBUG",
"filename": "test.log",
},
},
'loggers': {
'': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True
}
}
})
答案 0 :(得分:5)
我没有使用dictConfig,但我确实使用此设置找到了成功。
$("ul").on("click", "a", function(e) {
e.preventDefault();
e.stopPropagation();
})
$("#wiki").one('click', function(e) {
var articleName = $(this).data('subject');
$.getJSON("https://en.wikipedia.org/w/api.php?callback=?", {
srsearch: articleName,
action: "query",
list: "search",
format: "json"
}, function(data) {
$("#results ul").empty();
$("#results ul").append("<h3>Results for <b>" + articleName + "</b></h3>").text();
//For each result i set a <li> with the title and snippet.
//The title will be a disabled link with the
//data-attributes to load the modal
$.each(data.query.search, function(i, item) {
$("#results").append("<li><a href='https://en.wikipedia.org/wiki/" + encodeURIComponent(item.title) + "' data-toggle='modal' data-target='.bs-example-modal-lg'>" + item.title + "</a><br>" + item.snippet + "</li");
// At this point I set the url in a variable
// Probably I should save the url in an array since I may have many results
var myLink = $("#results ul li a").attr("href");
// Here I disable the link
$("#results div a").attr("href", "#");
});
// Here I say that as soon as the modal is open,
//I should make another query based on the title and get the full article
// This is where I have the issue as the URL should be what I have saved
$('.modal').on('show.bs.modal', function (e) {
$.getJSON("https://en.wikipedia.org/w/api.php?action=parse&format=json&callback=?", {
page: e.relatedTarget.textContent,
prop:"text"
}, function(data) {
$(".modal-content").html(data.parse.text['*']);
});
});
});
});