How to enable msg and debug logging with Log::Message::Simple - perl

I'm using Log::Message::Simple and error()s appear immediately. However, calls to debug() and msg() do nothing -- I have to call Log::Message::Simple->stack_as_string() to get these. How can I get this logging to appear immediately?

I'm not sure that this is the best solution, but I've fixed this by specifying the optional 'verbose' parameter to msg() and debug(), for example
msg("my message", 1);

For the stack_as_string, I thought you had to enable the flag.
Log::Message::Simple->stack_as_string(1);
HTH

Related

ImperativeExpression for ToolItems

I add the same ImperativeExpression to DirectToolItem and DirectMenuItem, but my #Evaluate method in class for expression was called only for DirectMenuItem. So I can't manage the visibility of DirectToolItem by ImperativeExpression. This is bug or I need to send some event to update visibility? Something like UIEvents.REQUEST_ENABLEMENT_UPDATE_TOPIC?
Unfortunately the visible-when expression for a tool item does not currently work at all. Eclipse bug 494663 describes the problem.

how to downgrade dut_error to dut_warning in specman

I have a test where I am using a expect #eventA-> eventually #eventB
else dut_error
However, my test treats that dut_error as a dut_warning and the test passed.
Is there any runtime switch in specman that downgrades all dut_errors to dut_warnings ?
For changing the effect of all checks, you cal also issue
"set check WARNING"
I recommend that you give names to the checks, among other things - it simplifies controlling their effect.
e.g. -
expect data_flow is #eventA-> eventually #eventB else ...
and then -
set check -name = my_checker.data_flow WARNING;
A nice thing is that if you name the expect, you can override it.
expect data_flow #eventA-> {[3..13]; #eventB} else ...
Yes, set_check can change the error level.
extend sys {
setup() is also {
set_check("...", WARNING);
};
};

How to make EF log sql queries globally?

How do I "tell" EF to log queries globally? I was reading this blog post: EF logging which tells in general how to log sql queries. But I still have a few questions regarding this logger.
Where would I need to place this line context.Database.Log = s =>
logger.Log("EFApp", s);?
Can it be globally set? Or do I have to place it everywhere I do DB
operations?
In the "Failed execution" section, the blogger wrote that, and I
quote:
For commands that fail by throwing an exception, the output contains the message from the exception.
Will this be logged too if I don't use the context.Database.Log?
Whenever you want the context to start logging.
It appears to be done on the context object so it should be done every time you create a new context. You could add this line of code in your constructor though to ensure that it is always enabled.
It will not log if you do not enable the logging.
I don't recommend to use that's functionality, because, it hasn't reason to exists in the real case.
Thats it use a lot of to debug code only. But, wether you wanna know more than details ... access link... https://cmatskas.com/logging-and-tracing-with-entity-framework-6/
In this case you can put code like this
public void Mylog()
{
//Thats a delegate where you can set this property to log using
//delegate type Action, see the code below
context.Database.Log = k=>Console.Write("Any query SQL")
//Or
context.Database.Log = k=>Test("Any query SQL")
}
public void Test(string x){
Console.Write(x)
}
I hope thats useufull

How to silence DataMapper in Sinatra

So, a simple little question. Every time I perform some transaction with DataMapper inside one of my "get" or "post" blocks, I get output looking something like this...
core.local - - [19/Sep/2012:09:04:54 CEST] "GET /eval_workpiece/state?id=24 HTTP/1.1" 200 4
- -> /eval_workpiece/state?id=24
It's a little too verbose for my liking. Can I turn this feedback off?
This isn’t Datamapper logging, this is the logging done by the WEBrick server, which logs all requests using these two formats by default.
(Note this isn’t Rack logging either, although the Rack::CommonLogger uses the same (or at least very similar) format).
The simplest way to stop this would be to switch to another server that doesn’t add its own logging, such as Thin.
If you want to continue using WEBrick, you’ll need to find a way to pass options to it from your Sinatra app. The current released Sinatra gem (1.3.3) doesn’t allow an easy way to do this, but the current master allows you to set the :server_options setting which Sinatra will then pass on. So in the future you should be able to do this:
set :server_settings, {:AccessLog => []}
in order to silence WEBrick.
For the time being you can add something like this to the end of your app file (I’m assuming you’re launching your app with something like ruby my_app_file.rb):
disable :run
Sinatra::Application.run! do |server|
server.config[:AccessLog] = []
end
To cut off all logging:
DataMapper.logger = nil
To change verbosity:
DataMapper.logger.set_log(logger, :warn) # where logger is Sinatra's logging object
Other levels are :fatal => 7, :error => 6, :warn => 4, :info => 3, :debug => 0 (http://rubydoc.info/gems/dm-core/1.1.0/DataMapper/Logger)
If you're running with ActiveSupport, you can use the Kernel extension:
quietly { perform_a_noisy_task }
This temporarily binds STDOUT and SDTERR to /dev/null for the duration of the block. Since you may not want to suppress all output, theoretically you can do:
with_warnings(:warn) { # or :fatal or :error or :info or :debug
perform_a_noisy_task
}
and appropriate messages will be suppressed. (NB: I say 'theoretically' because using with_warnings gave me a seemingly unrelated error in my Padrino/DataMapper environment. YMMV.)

Zend Framework - ZFDebug - Log - Log Custom Errors

When using ZFDebug, is it possible to add custom messages to the 'Log' tab?
So you could use something like:
$this->log('Error: Couldn't find the user');
Has anyone managed to achieve this?
I have never used ZFDebug before and wasn't aware of it. Your post piqued my interest, so I installed it and have been trying to achieve what you want to do. I will probably add it to my dev toolbox as I use ZF a lot.
You can achieve what you want by using the mark() method of ZFDebug_Controller_Plugin_Debug_Plugin_Log which takes two arguments. The first is the message you want to send and the second is a boolean which, when set to true (default is false), will send your message to the 'log' tab.
The following code worked for me:-
$debug = Zend_Controller_Front::getInstance()
->getPlugin('ZFDebug_Controller_Plugin_Debug');
$logger = $debug->getPlugin('log');
$logger->mark('Logging a message now', true);
Or to use your example (with the syntax error fixed :) )
$logger->mark("Error: Couldn't find the user", true);
As you can see this produced the desired output:-
Not quite as simple as you wanted, I know, but it's close and you could always wrap it in a function.