Code Monkey home page Code Monkey logo

mmap_log's Introduction

使用MMAP写的日志

MMAP:MMAP基本概念

  • 1、直接映射文件到内存中,写文件如同写内存一样快速
  • 2、初始化映射文件为1M,如果超过,则自动进行以2倍于当前文件进行扩容,即 2M,4M,8M...
  • 3、定时分割日志文件(每日零晨1点)
  • 4、正常退出时,清除文件的占位符
win10(64bit 8G) linux子系统 
普通日志100W次写入需要耗时:18.01s
MMAP日志100W次定稿需要耗时:1.679s

问题

因为mmap的特性,导致服务一旦crash,则日志文件会遗留大量的占位符 目前不支持windows系统,使用一般的文件写入方式

注意事项

  • 一、直接使用写日志时,默认使用终端打印日志
  • 二、如果需要使用mmap来写日志,则需要调用文件exported.go中的SetPath()方法,指定日志文件
  • 三、日志打印级别默认为info,如果需要指定其他级别,则需要调用文件exported.go中的SetLevel()方法,重新设定日志级别
  • 四、具体可调用方法,参照:日志方法

mmap_log's People

Contributors

wiwieo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.