libsir 2.2.5
Standard Incident Reporter
Loading...
Searching...
No Matches
config.h File Reference

Compile-time configuration. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SIR_TIMEFORMAT   "%H:%M:%S"
 The time stamp format string at the start of log messages-not including milliseconds (as::SIR_MSECFORMAT), which is added separately.
 
#define SIR_MSECFORMAT   ".%03ld"
 The format for milliseconds (1000ths of a second) in time stamps.
 
#define SIR_EOL_CR   "\r"
 The carriage return (CR) character to use in the end of line sequence when SIR_USE_EOL_CRLF is defined.
 
#define SIR_EOL_LF   "\n"
 The line feed (LF) character to use in the end of line sequence.
 
#define SIR_EOL   SIR_EOL_LF
 The end of line sequence.
 
#define SIR_LEVELPREFIX   "["
 The string placed directly before the human-readable logging level.
 
#define SIR_LEVELSUFFIX   "]"
 The string placed directly after the human-readable logging level.
 
#define SIR_PIDPREFIX   "("
 The string placed directly before process and thread IDs.
 
#define SIR_PIDSUFFIX   ")"
 The character placed directly after process and thread IDs.
 
#define SIR_PIDFORMAT   "%d"
 The format for the current process ID.
 
#define SIR_TIDFORMAT   "%d"
 The format for the current thread ID.
 
#define SIR_PIDSEPARATOR   "."
 The string to place between process and thread IDs.
 
#define SIR_FOPENMODE   "a"
 The string passed to fopen/fopen_s for log files.
 
#define SIR_FROLLSIZE   (1024 * 1024 * 5)
 The size, in bytes, at which a log file will be rolled/archived.
 
#define SIR_FHTIMEFORMAT   "%H:%M:%S %a %d %b %Y (%z)"
 The time format string used in file headers (see SIR_FHFORMAT).
 
#define SIR_FHFORMAT   SIR_EOL SIR_EOL "----- %s %s -----" SIR_EOL SIR_EOL
 The format string written to a log file when logging begins or the file is rolled/archived.
 
#define SIR_FHBEGIN   "session begin @"
 The string included in SIR_FHFORMAT when a logging session begins.
 
#define SIR_FHROLLED   "archived as %s due to size @"
 The string included in SIR_FHFORMAT when a file is rolled/archived due to becoming larger than SIR_FROLLSIZE bytes in size.
 
#define SIR_FNAMETIMEFORMAT   "%Y-%m-%d-%H%M%S"
 The time format string for rolled/archived log files (see SIR_FNAMEFORMAT).
 
#define SIR_FNAMESEQFORMAT   "-%hu"
 The sequence number format string for rolled/archived log files (see SIR_FNAMEFORMAT).
 
#define SIR_FNAMEFORMAT   "%s-%s%s%s"
 The format string for rolled/archived log file names.
 
#define SIRL_S_EMERG   "emrg"
 The human-readable form of the SIRL_EMERG level.
 
#define SIRL_S_ALERT   "alrt"
 The human-readable form of the SIRL_ALERT level.
 
#define SIRL_S_CRIT   "crit"
 The human-readable form of the SIRL_CRIT level.
 
#define SIRL_S_ERROR   "erro"
 The human-readable form of the SIRL_ERROR level.
 
#define SIRL_S_WARN   "warn"
 The human-readable form of the SIRL_WARN level.
 
#define SIRL_S_NOTICE   "noti"
 The human-readable form of the SIRL_NOTICE level.
 
#define SIRL_S_INFO   "info"
 The human-readable form of the SIRL_INFO level.
 
#define SIRL_S_DEBUG   "debg"
 The human-readable form of the SIRL_DEBUG level.
 
#define SIR_MAXFILES   16
 The maximum number of log files that may be registered at one time.
 
#define SIR_MAXPLUGINS   16
 The maximum number of plugin modules that may be loaded at one time.
 
#define SIR_MAXFHEADER   128
 The size, in characters, of the buffer used to hold file header format strings.
 
#define SIR_MAXMESSAGE   4096
 The maximum number of characters allowable in one log message.
 
#define SIR_MAXTIME   64
 The size, in characters, of the buffer used to hold time format strings.
 
#define SIR_MAXMSEC   5
 The size, in characters, of the buffer used to hold millisecond strings.
 
#define SIR_MAXLEVEL   7
 The size, in characters, of the buffer used to hold level format strings.
 
#define SIR_MAXNAME   32
 The size, in characters, of the buffer used to hold process/appname format strings.
 
#define SIR_MAX_SYSLOG_ID   128
 The size, in characters, of the buffer used to hold system logger identity strings.
 
#define SIR_MAX_SYSLOG_CAT   64
 The size, in characters, of the buffer used to hold system logger category strings.
 
#define SIR_MAXMISC   7
 The maximum number of whitespace and miscellaneous characters included in output.
 
#define SIR_MAXSTYLE   43
 The size, in characters, of the buffer used to hold a sequence of styling data in any color mode (the largest possible sequence, which is: \x1b[a;fb;m;rrr;ggg;bbb;fb;m;rrr;ggg;bbbm) plus a null terminator.
 
#define SIR_MAXOUTPUT
 The maximum size, in characters, of final formatted output.
 
#define SIR_MAXERROR   256
 The maximum size, in characters, of an error message.
 
#define SIR_ERRORFORMAT   "Error in %s (%s:%u): '%s'"
 The format string for error messages returned by sir_geterror.
 
#define SIR_UNKNOWN   "<unknown>"
 The string that represents any unknown.
 
#define SIR_DESTNAME_STDERR   "stderr"
 stderr destination string.
 
#define SIR_DESTNAME_STDOUT   "stdout"
 stdout destination string.
 
#define SIR_DESTNAME_SYSLOG   "syslog"
 System logger destination string.
 
#define SIR_FALLBACK_SYSLOG_ID   "libsir"
 Fallback system logger identity.
 
#define SIR_FALLBACK_SYSLOG_CAT   "general"
 Fallback system logger category.
 
#define SIR_NUMLEVELS   8
 The number of actual levels; SIRL_NONE, SIRL_ALL, and SIRL_DEFAULT are pseudo levels and end up being mapped (or not) to the others.
 
#define SIR_NUMOPTIONS   8
 The number of actual options; SIRO_ALL, SIRO_DEFAULT, and SIRO_MSGONLY are pseudo options that end up being mapped (or not) to the others.
 
#define SIR_HNAME_CHK_INTERVAL   60
 The number of seconds to let elapse before checking if the hostname needs refreshing.
 
#define SIR_THRD_CHK_INTERVAL   333.0
 The number of milliseconds to let elapse before re-formatting the current thread identifier and/or name.
 
#define SIR_FILE_CHK_SIZE_WRITES   10
 The number of writes to a file to let occur before checking its current size to determine if it needs to be rolled.
 
#define SIR_SQUELCH_THRESHOLD   5
 The number of consecutive duplicate messages that will cause libsir to squelch further identical messages, and instead log the message SIR_SQUELCH_MSG_FORMAT.
 
#define SIR_SQUELCH_BACKOFF_FACTOR   2
 If duplicate messages continue to be logged after the threshold is met, the threshold will be multiplied by this number, resulting in longer intervals between SIR_SQUELCH_MSG_FORMAT messages.
 
#define SIR_SQUELCH_MSG_FORMAT   "previous message repeated %zu times"
 The message to be logged when SIR_SQUELCH_THRESHOLD (or a multiple thereof) consecutive duplicate messages are logged.
 

Detailed Description

Compile-time configuration.

The definitions herein may be modified for fine-grained control over the appearance and content of log messages, default values, and various thresholds (e.g. file and buffer sizes).

Version
2.2.5

SPDX-License-Identifier: MIT

Copyright (c) 2018-2024 Ryan M. Lederman leder.nosp@m.man@.nosp@m.gmail.nosp@m..com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Macro Definition Documentation

◆ SIR_EOL

#define SIR_EOL   SIR_EOL_LF

The end of line sequence.

If SIR_USE_EOL_CRLF is defined, the sequence will be SIR_EOL_CR + SIR_EOL_LF; otherwise just SIR_EOL_LF.

◆ SIR_ERRORFORMAT

#define SIR_ERRORFORMAT   "Error in %s (%s:%u): '%s'"

The format string for error messages returned by sir_geterror.

  • The first %s format specifier is the function name.
  • The second %s is the file name.
  • The %lu is the line number in the file.
  • The third %s is the error message.

Example

Error in findneedle (haystack.c:384): 'Too much hay'

◆ SIR_FHBEGIN

#define SIR_FHBEGIN   "session begin @"

The string included in SIR_FHFORMAT when a logging session begins.

Remarks
Only applies if SIRO_NOHDR is not set.

◆ SIR_FHFORMAT

#define SIR_FHFORMAT   SIR_EOL SIR_EOL "----- %s %s -----" SIR_EOL SIR_EOL

The format string written to a log file when logging begins or the file is rolled/archived.

Remarks
Only applies if SIRO_NOHDR is not set.

◆ SIR_FHROLLED

#define SIR_FHROLLED   "archived as %s due to size @"

The string included in SIR_FHFORMAT when a file is rolled/archived due to becoming larger than SIR_FROLLSIZE bytes in size.

Remarks
Only applies if SIRO_NOHDR is not set.

The %s format specifier is the path of the archived file.

◆ SIR_FHTIMEFORMAT

#define SIR_FHTIMEFORMAT   "%H:%M:%S %a %d %b %Y (%z)"

The time format string used in file headers (see SIR_FHFORMAT).

Remarks
Only applies if SIRO_NOHDR is not set.

Example

15:13:41 Fri 9 Jun 2023 (-0600)

◆ SIR_FNAMEFORMAT

#define SIR_FNAMEFORMAT   "%s-%s%s%s"

The format string for rolled/archived log file names.

  • The first %s format specifier is the original file name, up to but not including the last full stop (.), if any exist.
  • The second %s is the time stamp as defined by SIR_FNAMETIMEFORMAT.
  • The third %s is a sequence number, which may be used in the event that a log file with the same name already exists (i.e., 2 or more files are rolled/archived within a second). Its format is defined by SIR_FNAMESEQFORMAT.
  • The fourth %s is the original file name including, and beyond the last full stop, if one was found.

Example

`oldname.log` -> `oldname-23-06-09-122049-1.log`

◆ SIR_FNAMESEQFORMAT

#define SIR_FNAMESEQFORMAT   "-%hu"

The sequence number format string for rolled/archived log files (see SIR_FNAMEFORMAT).

Example

-1

◆ SIR_FNAMETIMEFORMAT

#define SIR_FNAMETIMEFORMAT   "%Y-%m-%d-%H%M%S"

The time format string for rolled/archived log files (see SIR_FNAMEFORMAT).

Example

2023-06-09-122049

◆ SIR_FROLLSIZE

#define SIR_FROLLSIZE   (1024 * 1024 * 5)

The size, in bytes, at which a log file will be rolled/archived.

Remarks
Default = 5 MiB.

◆ SIR_HNAME_CHK_INTERVAL

#define SIR_HNAME_CHK_INTERVAL   60

The number of seconds to let elapse before checking if the hostname needs refreshing.

The default is an eager 1 minute. Better safe than wrong?

◆ SIR_LEVELPREFIX

#define SIR_LEVELPREFIX   "["

The string placed directly before the human-readable logging level.

Remarks
Only applies if SIRO_NOLEVEL is not set.

◆ SIR_LEVELSUFFIX

#define SIR_LEVELSUFFIX   "]"

The string placed directly after the human-readable logging level.

Remarks
Only applies if SIRO_NOLEVEL is not set.

◆ SIR_MAXMESSAGE

#define SIR_MAXMESSAGE   4096

The maximum number of characters allowable in one log message.

This does not include accompanying formatted output (see SIR_MAXOUTPUT).

◆ SIR_MSECFORMAT

#define SIR_MSECFORMAT   ".%03ld"

The format for milliseconds (1000ths of a second) in time stamps.

Remarks
Only applies if SIRO_NOTIME or SIRO_NOMSEC are not set.
SIRO_NOTIME implies SIRO_NOMSEC.

Example

.034

◆ SIR_PIDFORMAT

#define SIR_PIDFORMAT   "%d"

The format for the current process ID.

Remarks
Only applies if SIRO_NOPID is not set.

◆ SIR_PIDPREFIX

#define SIR_PIDPREFIX   "("

The string placed directly before process and thread IDs.

Remarks
Only applies if SIRO_NONAME is not set.

◆ SIR_PIDSEPARATOR

#define SIR_PIDSEPARATOR   "."

The string to place between process and thread IDs.

Remarks
Only applies if both SIRO_NOPID and SIRO_NOTID are not set.

Example

3435.1189

◆ SIR_PIDSUFFIX

#define SIR_PIDSUFFIX   ")"

The character placed directly after process and thread IDs.

Remarks
Only applies if SIRO_NONAME is not set.

◆ SIR_TIDFORMAT

#define SIR_TIDFORMAT   "%d"

The format for the current thread ID.

Remarks
Only applies if SIRO_NOTID is not set.

◆ SIR_TIMEFORMAT

#define SIR_TIMEFORMAT   "%H:%M:%S"

The time stamp format string at the start of log messages-not including milliseconds (as::SIR_MSECFORMAT), which is added separately.

Remarks
Only applies if SIRO_NOTIME is not set.

Example

23:30:26