在这里,我有一个应用程序,下面有多个软件包,我不想将日志写入一个文件。比如说:
src/packageA/snmp.go
src/packageA/http.go
我想将日志从snmp.go写入/var/log/snmp.log
和http.go
到/var/log/http.log
詹姆斯
答案 0 :(得分:1)
如果您使用logrus
,则可能有用https://github.com/rifflock/lfshook
答案 1 :(得分:0)
runtime.Caller(0)
应该可以获得这些信息。例如:
void MyGraphicsScene :: drawBackground(QPainter * p, const QRectF & r)
{
if (_isInBackgroundUpdate == false) // anti-infinite-recursion guard
{
QGraphicsScene::drawBackground(p, r);
const QRectF rect = sceneRect();
p->fillRect(rect, backgroundBrush().color());
// Render the scene's static objects as pixels
// into the QGraphicsView's view-background-cache
this->_isInBackgroundUpdate = true; // anti-infinite-recursion guard
render(p, sceneRect());
this->_isInBackgroundUpdate = false;
}
}
// overridden to draw only the items appropriate to our current
// mode (foreground items OR background items but not both!)
void MyGraphicsScene :: drawItems(QPainter *painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[], QWidget *widget)
{
// Go through the items-list and only keep items that we are supposed to be
// drawing in this pass (either foreground or background, depending)
int count = 0;
for (int i=0; i<numItems; i++)
{
const bool isItemBackgroundItem = (_backgroundItemsTable.find(items[i]) != _backgroundItemsTable.end());
if (isItemBackgroundItem == this->_isInBackgroundUpdates) items[count++] = items[i];
}
QGraphicsScene::drawItems(painter, count, items, options, widget);
}
此示例将输出:
jsonParser.makeHttpRequest("http://192.168.1.4/android_connect/update11.php",
"POST", params);
}
这只是一个例子。 Try experimenting with a different integer parameter to runtime.Caller()
如果这不起作用。