[Add to favorites] callback the logs in Ace

Source: Internet
Author: User

# include
# include
# include
# include
# include
using namespace STD;
class logcall: Public ace_log_msg_callback
{< br> Public:
logcall () {}< br> ~ Logcall () {}< br> virtual void log (ace_log_record & log_record)
{< br> cout <"this is printed after callback:" cout }< BR >};

Int ace_tmain (INT, ace_tchar * [])
{
Logcall * pcall = new logcall ();
Ace_log_msg-> set_flags (ace_log_msg: msg_callback );
// Ace_log_msg-> clr_flags (ace_log_msg: stderr );
Ace_log_msg-> msg_callback (pcall );
Ace_debug (lm_error, ace_text ("% d hello everyone \ n ")));
Getchar ();
Return 0;
}

File * stream;
Char list [30];
Int I, numread, numwritten;

/* Open File in text mode :*/
If (Stream = fopen ("fread. Out", "W + T "))! = NULL)
{
For (I = 0; I <25; I ++)
List [I] = (char) ('Z'-I );
/* Write 25 characters to stream */
Numwritten = fwrite (list, sizeof (char), 25, stream );
Printf ("wrote % d items \ n", numwritten );
Fclose (Stream );

}
Else
Printf ("problem opening the file \ n ");

If (Stream = fopen ("fread. Out", "R + T "))! = NULL)
{< br>/* attempt to read in 25 characters */
numread = fread (list, sizeof (char), 25, stream );
printf ("number of items read = % d \ n", numread);
printf ("Contents of buffer = %. 25s \ n ", list);
fclose (Stream);
}< br> else
printf (" file cocould not be opened \ n ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.