/
lasersquad
/
LogEngine2
Обзор
Документация
Войти
/
lasersquad
/
LogEngine2
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/testFiles/example.lfg
101 строка
4 KB
lasersquad0
Implemented thread safe and thread non-safe two types of loggers
24 апр 2025, 00:42
24 апр 2025, 00:42
2a7912e
Код
Авторство
О чём код?
# each logger has its own section in config file. # name of this section starts with predefined word 'logger' with dot '.' and name of logger after it. # you can define in the file as many loggers as you need # logger and sink names are case insensitive in file. it means that 'MainLogger' and 'mainlogger' are considered and name of one logger [logger.mainLogger] loglevel = debug # there are may be many 'sink' parameters in logger section. # each sink parameter contains name of the sink defined further in [sink.xx] sections in this file. # during parsing all declared sinks will be added to the current logger. # no limits on number of sinks (and sink types) to be added to the logger. sink=s1 sink=s2 asyncmode=false # this is logger with name 'second' [logger.second] LogLevel = warning Sink=s3 Sink=s2 Sink=rotating AsyncMode=true # this section contains parameters of the sink # s1 is sink will be added to MainLogger logger (see above) [SINK.s1] # there are 5 sink types: Stdout, Stderr, String, File, RotatingFile. # they may contain different parameters. # for example FileName parameter is valid for File, RotatingFile only. Type=File # This is file name for the sink. If file name contain spaces it needs to be in quotes????? FileName = s1s1s1s1s1.log # log level for the sink. This is second 'filter' for log messages. First such 'filter' is in Logger. # with sink log level it is possble to send messages of different log levels into different files. loglevel = trace # note this sink is "connected" to two loggers [Sink.s2] # this sink sends error log messages to standard output Type=STDout LOGLEVEL=error ThreadSafety = single [SINK.s3] Type=File FileName = s3 s3 s3 s3.log loglevel = trace [sink.rotating] Type=RotatingFile FileName = RotatingLogfile.log threadsafety= multi # Rotating strategy. can be one of the following values # None - no rotating. logs are written into specified log file without any rotating. In that case RotatingFile is fully equal to FileSink # Single - only one .bak file is created when log file reaches MaxLogfileSize. Old .bak file is deleted. # TimeStamp - .bak files are created with TimeStamp in the name. Unlimited number of such files can be created. # Numbers - when log file reaches MaxLogfileSize, log file is renamed to <logfilename>.1.bak, existing <logfilename>.1.bak is renamed to <logfilename>.2.bak and so on. # maximum number of numerated .bak files is MaxBackupIndex. Extra files are deleted. Strategy = numbers # Maximum log file size when new file will be started. # Value can contain suffixes K, M, G that means kilobytes, megabytes and gigabytes MaxLogfileSize = 6K # Maximum number of "backup" files. Older files will be deleted MaxBackupIndex = 5 #For any sink type it is possible to define error patterns for the message of each log level # each pattern contains text with placeholders # placeholders are replaced by actual values when sink writes log message # full list of placeholders can be found below ErrorPattern = ! %TIME% #%THREAD% : %MSG% WarnPattern = # %TIME% #%THREAD% : %MSG% CritPattern = *!* %TIME% #%THREAD% : %MSG% # this is pattern for all log message levels # use it when you do not need separate pattern for each log level. PatternAll = !WOW! %TIME% #%THREAD% : %MSG% #--------------------------------------------------------------------------------- # Log message patterns. # Each pattern allows to set the format in which log information will be saved to the log file. # Each pattern can be a combination of placeholders and free text. # Letters that are not placeholders will be copied to the output stream without changing. # The example of template line : '%TIME% #%THREAD% : %MSG%' # NOTE! MACROS ARE CASE SENSITIVE AND MUST BE IN UPEER CASE. # List of supported placeholders: # %TIME% - current time # %DATE% - current date # %DATETIME% - the current date and time # %THREAD% - ID of thread that generated this log message # %MSG% - log message itself # %LOGLEVEL% - log level for log message. # %APPNAME% - the name of application # %APPVERSION% - the version of application. Can have x.x.x.x format or other. # %OS% - OS name (for example Microsoft Windows 10) # %OSVERSION% - OS version number (for example "5.1.0.2666")