simlock
병렬 코딩 에이전트가 동일 시뮬레이터를 놓고 충돌하지 않도록 제어 평면 제공
zlog는 신뢰성·고성능·스레드 안전·유연한·명확한 모델을 갖춘 순수 C 로깅 라이브러리입니다
A reliable, high-performance, thread safe, flexsible, clear-model, pure C logging library.
개발 도구C · PythonGitHub @HardySimpson직접 설치운영자 미확인
써 보셨어요? 한 번만 눌러 주세요. 로그인은 필요 없어요.
개인 계정의 공개 저장소 소유자는 GitHub로 로그인해 운영자를 확인하고 소개를 직접 관리할 수 있습니다. 관리자 승인은 필요하지 않습니다.
로그인한 뒤 확인 파일을 만들어 이 저장소의 기본 브랜치에 30분 안에 커밋해 주세요. 다른 브랜치나 포크의 파일은 인정하지 않습니다. 파일을 올린 뒤 아래에서 확인하면 관리자 승인 없이 관리할 수 있습니다. 자격을 유지하려면 파일을 남겨 두세요.
로그인이 필요하면 로그인 화면으로 이동합니다. 로그인 후 이곳으로 돌아와 원하는 확인 버튼을 다시 눌러 주세요.
설치형 프로젝트는 배포 도메인 없이도 확인할 수 있습니다. 개인 저장소는 GitHub 로그인으로, 조직 저장소는 위의 저장소 확인 파일로 직접 확인해 주세요.
README 전체를 불러오는 중입니다. 아래는 저장된 발췌입니다.
zlog is a reliable, high-performance, thread safe, flexible, clear-model, pure C logging library.
Actually, in the C world there was NO good logging library for applications like logback in java or log4cxx in c++.
Using printf can work, but can not be redirected or reformatted easily. syslog is slow and is designed for system use.
So I wrote zlog.
It is faster, safer and more powerful than log4c. So it can be widely used.
zlog can be built either with CMake or with the plain makefile. Both produce the same shared and static libraries, the
zlog-chk-conf tool and a pkg-config file.README 전문 보기 ↗zlog is a reliable, high-performance, thread safe, flexible, clear-model, pure C logging library.
Actually, in the C world there was NO good logging library for applications like logback in java or log4cxx in c++. Using printf can work, but can not be redirected or reformatted easily. syslog is slow and is designed for system use. So I wrote zlog. It is faster, safer and more powerful than log4c. So it can be widely used.
Downloads: https://github.com/HardySimpson/zlog/releases
tar -zxvf zlog-latest-stable.tar.gz
cd zlog-latest-stable/
zlog can be built either with CMake or with the plain makefile. Both produce the same shared and static libraries, the
zlog-chk-conf tool and a pkg-config file.
Needs CMake 3.12 or newer.
cmake -DCMAKE_BUILD_TYPE=Release -B build
cmake --build build -j8
sudo cmake --install build
CMAKE_INSTALL_PREFIX says where it goes, /usr/local by default. The GNU install directories are honoured, so
distributions that keep their libraries in lib64 can ask for that:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/zlog -DCMAKE_INSTALL_LIBDIR=lib64 -B build
Configure with -DUNIT_TEST=ON to build the test suite, which ctest then runs:
cmake -DUNIT_TEST=ON -B build
cmake --build build -j8
ctest --test-dir build
Besides the usual Debug and Release, the build types Tsan and Asan build the library and the tests under the
thread and address sanitizers. See doc/developer.md.
make
sudo make install
Or
make PREFIX=/usr/local/
sudo make PREFIX=/usr/local/ install
PREFIX indicates the installation destination for zlog, and LIBRARY_PATH the library directory under it (lib by
default, so pass LIBRARY_PATH=lib64 where that is the convention).
Refresh your dynamic linker to make sure your program can find the zlog library.
$ sudo vi /etc/ld.so.conf
/usr/local/lib
$ sudo ldconfig
Before running a real program, make sure libzlog.so is in the directory where the system's dynamic lib loader can find it. The command mentioned above are for linux. Other systems will need a similar set of actions.
There are 3 important concepts in zlog: categories, formats and rules.
Categories specify different kinds of log entries. In the zlog source code, category is a zlog_category_t * variable.
In your program, different categories for the log entries will distinguish them from each other.
Formats describe log patterns, such as: with or without time stamp, source file, source line.
Rules consist of category, level, output file (or other channel) and format. In brief, if the category string in a rule in the configuration file equals the name of a category variable in the source, then they match. Still there is complex match range of category. Rule decouples variable conditions. For example, log4j must specify a level for each logger(or inherit from father logger). That's not convenient when each grade of logger has its own level for output(child logger output at the level of debug, when father logger output at the level of error)
Now create a configuration file. The function zlog_init takes the files path as its only argument.
$ cat /etc/zlog.conf
[formats]
simple = "%m%n"
[rules]
my_cat.DEBUG >stdout; simple
In the configuration file log messages in the category my_cat and a level of DEBUG or higher are output to standard
output, with the format of simple %m - usermessage %n - newline. If you want to direct out to a file and limit the
files maximum size, use this configuration
my_cat.DEBUG "/var/log/aa.log", 1M; simple
$ vi test_hello.c
#include <stdio.h>
#include "zlog.h"
int main(int argc, char** argv)
{
int rc;
zlog_category_t *c;
rc = zlog_init("/etc/zlog.conf");
if (rc) {
printf("init failed\n");
return -1;
}
c = zlog_get_category("my_cat");
if (!c) {
printf("get cat fail\n");
zlog_fini();
return -2;
}
zlog_info(c, "hello, zlog");
zlog_fini();
return 0;
}
$ cc -c -o test_hello.o test_hello.c -I/usr/local/include
$ cc -o test_hello test_hello.o -L/usr/local/lib -lzlog -lpthread
$ ./test_hello
hello, zlog
Both builds install a pkg-config file, so the flags above can also be queried:
$ cc -o test_hello test_hello.c $(pkg-config --cflags --libs zlog)
Add --static when linking against libzlog.a, so that the private dependencies are pulled in as well.
The CMake build also installs a package config, so a CMake project can just ask for zlog:
find_package(zlog REQUIRED)
target_link_libraries(test_hello PRIVATE zlog::zlog)
zlog::zlog_s is the static library. Both targets carry the include directory and the thread flags, so nothing else
needs setting.