About the log class in Go

Source: Internet
Author: User

After you create a new log file, run three threads:

1, responsible for timing check whether the file exists, if it does not exist, re-create, and clear the expired log

2. Change the name of the file and add the date after the original name.

3. Flush the cache contents to the log regularly

When calling functions such as log Errorf:

1. Determine if the log level is within the configured range

2, with runtime. Caller get the function call stack, get the file that runs the current command, the row, and other information

3. Create a buffer to temporarily store string log information

4. Write the buffer contents to a file

5, if the buffer is very large, then do not do processing, to the garbage collection mechanism; If buffer is small, save it and continue with it the next time. Increase the utilization of system resources.

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.