GithubHelp home page GithubHelp logo

pymumu / tinylog Goto Github PK

View Code? Open in Web Editor NEW
198.0 8.0 61.0 293 KB

A lightweight C, C++ logging library developed for Linux, It is designed with high performance, asynchronized, thread-safe and process-safe; tinylog是一个专为UNIX设计的轻量级的C/C++日志模块,其提供了高性能,异步,线程安全,进程安全的日志功能。

License: Other

Makefile 1.59% C 82.65% CMake 0.99% C++ 14.77%
log logging-library lightweight logging asynchronous multithreading tinylog library c cpp

tinylog's People

Contributors

pymumu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinylog's Issues

tlog_exit 有问题

tlog_init()
tlog_open()
tlog_close()
tlog_exit()

err:开始
tlog_init() 报 已初始化
tlog_open() 报 未初始化

output format

Hello

This library is awesome. But it doesnt write funciton for output. can you add function name ?

Thanks.

Mingw64 Support

Hello,

I tried to compile tinylog in mingw64, but since some of the header files do not exist I couldn't succeed.
Is there any way for it?
#include <sys/resource.h>
#include <sys/syscall.h>
#include <sys/wait.h>

Installation of the header file tlog.h in cmake

In CMakeLists.txt,with install cmd:

install(FILES tlog.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tlog.h)

will install tlog.h to:/usr/include/tlog.h/tlog.h,is this expected behavior?

If you just want to install tlog.h to /usr/incldue, it should be like this:

install(FILES tlog.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

Shared library support

Hello,

I have used tlog, by converting it to a so shared library, with a few programs and didn't see any problems.
Is there actually any inconveniences for that?

gcc -O3 -Wall -fpic -c tlog.c -o tlog.o
gcc -shared -o libtlog.so tlog.o -pthread

Thank you.

When I use tinylog in multiprocess, it make me confuse.

The another.log file only record the parent process's print info, Did I lack of some func revoke?

#include "tlog.h"

#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <time.h>
#define PID_IS_CHILD 0

tlog_log *log = NULL;
int printlog()
{
	int i = 0;
	tlog_printf(log, "This is child log stream %d\n", i++);
	while (i<1000)
	{
		tlog_printf(log, "This is child log stream %d\n", i++);
		usleep(10);
	}

	return 0;
}


int paraentprint()
{
	int i = 0;
	while (i<10000)
	{
		tlog_printf(log, "This is paraent log stream %d\n", i++);
		usleep(10);
	}

	return 0;
}
int main(int argc, char *argv[])
{

    /* init and output log message */
    tlog_init("example.log", 1024 * 1024, 8, 0, 0);
    //tlog(TLOG_INFO, "This is a log message.\n");

    /* c++ cout style log */
    //tlog_info << "This is a c++ style log.\n";
    
    /* open another log file, and output message*/
    log = tlog_open("another.log", 1024*1024 * 1024, 8, 0, TLOG_SEGMENT);
    tlog_printf(log, "This is a separate log stream\n");
    /* c++ style log */
    tlog_out(log) << "This is a separate c++ log stream\n"; 
    

	int pid = fork();
	if (pid == PID_IS_CHILD)
	{
		fprintf(stderr, "child func start\n");
		printlog();
	}
	else if (pid < 0) 
	{
		tlog_printf(log, "bad func start\n");
	}
	else 
	{
		tlog_printf(log, "is parent func start\n");
	}

	paraentprint();
    /* close log stream */
	sleep(100);
    tlog_close(log);

    /* flush pending message, and exit tlog */
    tlog_exit();
    return 0;
}

Time-based log rotation

Does not support time-based log rotation. Rotating and deleting logs not only after a specified interval but also at a specified time.

i cant use tlog_init

==29745== 144 bytes in 1 blocks are possibly lost in loss record 9 of 18
==29745== at 0x4842260: calloc (vg_replace_malloc.c:752)
==29745== by 0x400CCFD: allocate_dtv (dl-tls.c:286)
==29745== by 0x400D33B: _dl_allocate_tls (dl-tls.c:532)
==29745== by 0x4C3E58F: allocate_stack (allocatestack.c:621)
==29745== by 0x4C3E58F: pthread_create@@GLIBC_2.4 (pthread_create.c:669)
==29745== by 0x22A37: tlog_init (tlog.c:1673)

view for valgrind,but i can use it when before

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.