[Cocos2dx note 006] flow format log

Source: Internet
Author: User
In cocos2dx 2.2.2, Cocos uses the clog write date, and the format is C's printf method to generate logs. There are also many c ++ stream logs, similar to cout operations. I have read a lot, such as log4cxx. But personal movement is a little big. I added support for streaming in my original logs. And smoothly transplanted to the cocos2dx environment for use. Download is an example used in cocos2dx.
Cocos2dx log end class:
# Ifndef _ x_cocos2d_log_end_h _
# DEFINE _ x_cocos2d_log_end_h _
# Include <xlog. h>
# Include "platform/ccplatformmacros. H"
Namespace ZDH
{
Using_ns_cc;
Class xlogendcocos2d: Public xlogendbase
{
Public:
Virtual void outlog (INT/* paramloglevel */, const xansistring & paramlog)
{
Cclog ("% s", paramlog. c_str ());
}
};
}
# Endif then, you can add it during initialization.
Zdh_log_object-> addlogend (New ZDH: xlogendcocos2d ());
# If defined (OS _windows)
ZDH: xlogendfile * plogendfile = new ZDH: xlogendfile ();
Plogendfile-> Init ("erase. log ");
Zdh_log_object-> addlogend (plogendfile );
# Endif
Stream_info <"Hello cocos2dx"; currently, this is a single thread. If multithreading is supported, you only need to refer to the definition of xnulllock, then, change the template parameter from xnulllock to a new lock class. For details, see my open code.

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.