我的问题很简单:写入日志的内容.有没有约定?我该怎么办?
由于我的应用程序必须发布,我希望有友好的日志,大多数人都可以阅读,而不会询问它是什么.
我已经有了一些想法,比如时间戳,每个函数/方法的唯一标识符等等.我想要有几个日志级别,比如跟踪/调试,信息,错误/警告.
您是否使用了一些预先格式化的日志资源?
谢谢
假设:
A. WIN32下的C++.
B.正确对齐的易失性整数使用InterlockedIncrement()和递增和递减InterlockedDecrement().
__declspec (align(8)) volatile LONG _ServerState = 0;
Run Code Online (Sandbox Code Playgroud)
如果我想简单地读取_ServerState,我是否需要通过InterlockedXXX函数读取变量?
例如,我见过如下代码:
LONG x = InterlockedExchange(&_ServerState, _ServerState);
Run Code Online (Sandbox Code Playgroud)
和
LONG x = InterlockedCompareExchange(&_ServerState, _ServerState, _ServerState);
Run Code Online (Sandbox Code Playgroud)
目标是简单地读取当前的值_ServerState.
我不能简单地说:
if (_ServerState == some value)
{
// blah blah blah
}
Run Code Online (Sandbox Code Playgroud)
这个问题似乎有些混乱.我理解在Windows中注册大小的读取是原子的,所以我认为这个InterlockedXXX函数是不必要的.
马特J.
好的,谢谢你的回复.顺便说一句,这是Visual C++ 2005和2008.
如果这是真的,我应该使用一个InterlockedXXX函数来读取它的值_ServerState,即使只是为了清楚起见,最好的方法是什么?
LONG x = InterlockedExchange(&_ServerState, _ServerState);
Run Code Online (Sandbox Code Playgroud)
这具有修改值的副作用,当我真正想做的就是阅读它.不仅如此,如果存在上下文切换,我可以将标志重置为错误的值,因为_ServerState在准备调用时将值推到堆栈上InterlockedExchange().
LONG x = InterlockedCompareExchange(&_ServerState, _ServerState, _ServerState);
Run Code Online (Sandbox Code Playgroud)
我从我在MSDN上看到的一个例子中得到了这个.
见http://msdn.microsoft.com/en-us/library/ms686355(VS.85).aspx
我所需要的只是一条线:
lock mov …Run Code Online (Sandbox Code Playgroud) 我有一个基类DockedToolWindow:Form,以及从DockedToolWindow派生的许多类.我有一个容器类,用于保存和分配事件到DockedToolWindow对象,但是我想调用子类中的事件.
我实际上有一个关于如何实现这个MSDN网站告诉我要做的事情的问题.以下这节给我的问题是:
// The event. Note that by using the generic EventHandler<T> event type
// we do not need to declare a separate delegate type.
public event EventHandler<ShapeEventArgs> ShapeChanged;
public abstract void Draw();
//The event-invoking method that derived classes can override.
protected virtual void OnShapeChanged(ShapeEventArgs e)
{
// Make a temporary copy of the event to avoid possibility of
// a race condition if the last subscriber unsubscribes
// immediately after the null check and before the event …Run Code Online (Sandbox Code Playgroud) 我注意到一些不太老的VM语言,比如用C语写的Lua,NekoVM和Potion.
看起来他们正在重新实现许多C++功能.
用C而不是C++编写它们有什么好处?
我试图找到正确的语法将varible传递给我的JQuery Post.
var id = empid;
$.ajax({
type: "POST",
url: "../Webservices/EmployeeService.asmx/GetEmployeeOrders",
data: "{empid: empid}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(result) {
alert(result.d);
}
Run Code Online (Sandbox Code Playgroud)
我不认为数据:价值是非常正确的.有人让我直截了当?
谢谢!
我想知道是否有比Django的flatpages应用程序更好的东西,因为flatpages甚至不支持状态(草稿,发布)或发布日期等内容.那里有什么吗?
有没有办法从range()函数中获取最后一个数字?我需要在前20个术语的Fibonacci序列中得到最后一个数字,还是应该使用列表而不是range()?
我对使用IE6和7个特定错误的页面的HTML/CSS/JS调试感到不满意.
我知道IE8有一个名为'Developer Tools'的Firebug克隆.
是否有可能安装了IE8(可能在虚拟机上,我不介意),将其设置为兼容模式(有一个IE6?),然后执行JS调试和现场HTML的变化,使用IE8的开发工具,只是就像我们可以在Firebug中一样?
非常感谢mieze
javascript firebug internet-explorer-8 internet-explorer-7 internet-explorer-6
在Share Point Web应用程序级别上处理SharePoint列表和文档库的所有新添加的文档和项目的最佳方法是什么.
我的情况是,我想在添加任何新文档或项目时对数据库进行一些插入.
1- 未预定义站点集合,Web或子站点和列表.
2-我需要在现有和新的文档库和列表上应用处理程序.
1-分析共享点日志.
2-向所有SPLists添加事件接收器.
有什么建议吗?
我有一个perl脚本(特别是XMLTV系列的" 抓取器" tv_grab_oztivo).
我可以像这样成功运行它:
/sw/bin/perl /path/to/tv_grab_oztivo --output /path/to/tv.xml
Run Code Online (Sandbox Code Playgroud)
我使用完整路径来消除工作目录中的问题.权限应该不是问题.
所以,如果我从终端(Mac OSX)运行它,它的工作正常.
但是当我将它设置为通过cron作业运行时,似乎根本没有发生任何事情.没有创建输出等.
据我所知,crontab没有任何问题,因为如果我用helloworld.pl替换实际的脚本,它会在正确的时间运行得很好.
那么,我该怎么做才能调试?从%ENV两种情况看,我可以看到环境非常不同,但我可以采取哪些其他方法进行调试?如何查看cron作业的输出,这可能是来自shell或其他任何东西的某种"死"消息或"未找到"消息?
或者我应该尝试以某种方式给命令的cron版本提供与我运行时相同的环境?
c++ ×2
python ×2
ajax ×1
asp.net ×1
base-class ×1
c ×1
c# ×1
cron ×1
django ×1
events ×1
fibonacci ×1
firebug ×1
interlocked ×1
javascript ×1
jquery ×1
locking ×1
logging ×1
methodology ×1
perl ×1
post ×1
range ×1
sharepoint ×1
shell ×1
web-services ×1
windows ×1