$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: John Torjo (john.lists_at_[hidden])
Date: 2005-05-19 11:39:20
Gennadiy Rozental wrote:
>>What about this:
>>
>>time_t slow_time()
>>{
>>  BOOST_LOG(x) << "going to sleep at " << time(0);
>>  sleep(1);
>>  time_t t;
>>  BOOST_LOG(x) << "waking up at " << t = time(0);
>>  return t;
>>}
>>
>>void f()
>>{
>> BOOST_LOG(x) << "slow_time returned " << slow_time() << " then " << 
>>slow_time();
>>}
>>
>>Resulting in (I ran this test a long time ago, boot time isn't bad either 
>>:-) :
>>
>>going to sleep at 0
>>waking up at 1
>>going to sleep at 1
>>waking up at 2
>>slow time returned 1 then 2
> 
> 
> I have several questions about this:
> 
> 1. How do you know in general which log present trace of first invocation, 
> and which one second:
> 
> void acess_db( ... ) {
>     if( some error )
>        log << "invalid account key" << key;
> }
> 
> int get_balance(...){
>     ...
>    if( !access_db(...)  )
>        return 0;
> }
> 
> ...
> 
> log << "Mary has balance: " << get_balance() << " and John has balance: " << 
> get_balance()
> 
I would assume you meant something like:
log << "Mary has balance: " << get_balance("mary") << " and John has 
balance: " <<  get_balance("john");
If so, when you have a bad key, you should have some extra information 
to log (the name, or something).
 >
 > 2. How does the log system know when to dump the cash? Does it 
introduce any scope guards?
Have you actually taken a look at the code? A temporary variable is 
created, and in its destructor I perform the logging.
 >
 > 4. What kind of overhead it introduces? Now instead of directly 
writing into
 > stream we keep second copy of every piece of log essentially doubling 
the
 > memory usage and increasing log overhead, isn't it?
 >
Have you actually tested it in a multi-threading environment, or is this 
just your guts?
Best,
John
-- John Torjo, Contributing editor, C/C++ Users Journal -- "Win32 GUI Generics" -- generics & GUI do mix, after all -- http://www.torjo.com/win32gui/ -v1.6.3 (Resource Splitter) -- http://www.torjo.com/cb/ - Click, Build, Run!