# rpmio/rpmlog.c File Reference

`#include "system.h"`
`#include <stdarg.h>`
`#include <rpmlog.h>`
`#include "debug.h"`
Include dependency graph for rpmlog.c:

Go to the source code of this file.

## Defines

#define | _RPMLOG_INTERNAL

## Functions

static void * | _free (const void *p)
| Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
int | rpmlogGetNrecs (void)
| Return number of messages.
int | rpmlogCode (void)
| Return error code from last rpmError() message.
const char * | rpmlogMessage (void)
| Return text of last rpmError() message.
const char * | rpmlogRecMessage (rpmlogRec rec)
| Retrieve log message string from rpmlog record.
rpmlogLvl | rpmlogRecPriority (rpmlogRec rec)
| Retrieve log priority from rpmlog record.
void | rpmlogPrint (FILE *f)
| Print all rpmError() messages.
void | rpmlogClose (void)
| Close desriptor used to write to system logger.
void | rpmlogOpen (const char *ident, int option, int facility)
| Open connection to system logger.
int | rpmlogSetMask (int mask)
| Set the log mask level.
rpmlogCallback | rpmlogSetCallback (rpmlogCallback cb, rpmlogCallbackData data)
| Set rpmlog callback function.
void | rpmlogGetCallback (rpmlogCallback *cb, rpmlogCallbackData *data)
| Get rpmlog callback function and data.
static int | rpmlogDefault (rpmlogRec rec)
FILE * | rpmlogSetFile (FILE *fp)
| Set rpmlog file handle.
const char * | rpmlogLevelPrefix (rpmlogLvl pri)
| Return translated prefix string (if any) given log level.
static int | vsnprintf (char *buf, int nb, const char *fmt, va_list ap)
static void | vrpmlog (unsigned code, const char *fmt, va_list ap)
void | rpmlog (int code, const char *fmt,...)
| Generate a log message using FMT string and option arguments.

## Variables

static int | nrecs = 0
static rpmlogRec | recs = NULL
static unsigned | rpmlogMask = RPMLOG_UPTO( RPMLOG_NOTICE )
static rpmlogCallback | _rpmlogCallback = NULL
static rpmlogCallbackData | _rpmlogCallbackData = NULL
static FILE * | _stdlog = NULL
static const char * | rpmlogMsgPrefix []

## Detailed Description

Definition in file rpmlog.c.

## Define Documentation

#define _RPMLOG_INTERNAL

Definition at line 7 of file rpmlog.c.

## Function Documentation

static void* _free | ( | const void * | p | ) | `[inline, static]`

Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.

Parameters:

  | p | memory to free

Return values:

  | NULL | always

Definition at line 24 of file rpmlog.c.

Referenced by _tagGenerate(), _tagName(), _tagValue(), addChangelog(), addFile(), addFileToTag(), addFileToTagAux(), addOrAppendListEntry(), addReqProv(), addSource(), addTE(), archScore(), argiFree(), argvFree(), armorFormat(), base64Format(), buildSpec(), checkFiles(), checkForDuplicates(), checkForValidArchitectures(), checkPackageSet(), checkSpec(), Chroot(), closeCallback(), closeSpec(), compressFilelist(), cpio_doio(), cpioHeaderRead(), db3close(), db3open(), db3stat(), db_init(), dbiFreeIndexSet(), dbiTagsInit(), defaultMachine(), delTE(), dnlFreeIterator(), dodigest(), doIcon(), doPatch(), doRmSource(), doSetupMacro(), doUntar(), ensureOlder(), extractRegular(), fillOutMainPackage(), findErases(), findPreambleTag(), formatValue(), freeAttrRec(), freeBadDeps(), freeFileList(), freeFormat(), freeFSM(), freeHardLink(), freeNames(), freePackage(), freeSl(), freeSources(), freeSpec(), freeSplitString(), freeSt(), freeStringBuf(), freeTriggerFiles(), fsmCommitLinks(), fsmMakeLinks(), fsmMapPath(), fsmStage(), fssizesTag(), genCpioListAndHeader(), genSourceRpmName(), getFilesystemList(), getOutputFrom(), getSignid(), handleInstInstalledFiles(), handleOneTrigger(), handleOverlappedFiles(), handlePreambleTag(), handleRmvdInstalledFiles(), hCopyTag(), hdr_subscript(), hdrKeyList(), hdrSprintf(), hdrUnload(), headerAddI18NString(), headerCheck(), headerCopy(), headerCopyLoad(), headerCopyTags(), headerFini(), headerFree(), headerLoad(), headerMacrosLoad(), headerMacrosUnload(), headerMergeLegacySigs(), headerModifyEntry(), headerNEVRA(), headerRegenSigHeader(), headerReload(), headerRemoveEntry(), headerSetOrigin(), headerSprintf(), headerUnload(), hGetColor(), hGetNVRA(), hLoadTID(), i18nTag(), IDTXfree(), IDTXglob(), IDTXload(), ignoreDep(), initSourceHeader(), instprefixTag(), isMemberInEntry(), isPart(), leaveChroot(), localeTag(), lookupPackage(), lzdClose(), lzdReadOpen(), lzdWriteOpen(), main(), makeGPGSignature(), makeHDRSignature(), mapFreeIterator(), markReplacedFiles(), miFreeHeader(), mireFreeAll(), mireSkip(), packageBinaries(), packageSources(), parseBuildInstallClean(), parseChangelog(), parseCVOG(), parseDescription(), parseExpressionBoolean(), parseExpressionString(), parseFiles(), parseForRegexLang(), parseForSimple(), parsePreamble(), parseRCPOT(), parseScript(), parseSpec(), pgpArmorWrap(), pgpDigClean(), pgpDigFree(), pgpExtractPubkeyFingerprint(), pgpGrabPkts(), pgpPrtPkts(), pgpPrtUserID(), pgpPubkeyFingerprint(), pgpReadPkts(), popMacro(), prepFetch(), prepFetchVerbose(), printFileInfo(), printNewSpecfile(), processBinaryFile(), processBinaryFiles(), processMetadataFile(), processPackageFiles(), providePackageNVR(), pushMacro(), rdLead(), rdSignature(), readFile(), readLine(), readLineFromOFI(), rebuildCompatTables(), relocateFileList(), rpmalAllFileSatisfiesDepend(), rpmalAllSatisfiesDepend(), rpmalDel(), rpmalFree(), rpmalFreeIndex(), rpmCheckPassPhrase(), rpmcliAllArgCallback(), rpmcliConfigured(), rpmcliFini(), rpmcliImportPubkey(), rpmcliImportPubkeys(), rpmcliInit(), rpmcliInstall(), rpmcliInstallSuggests(), rpmcliQuery(), rpmdbAdd(), rpmdbClose(), rpmdbExportInfo(), rpmdbFindByFile(), rpmdbFindFpList(), rpmdbFreeIterator(), rpmdbInitIterator(), rpmdbMoveDatabase(), rpmdbNew(), rpmdbNextIterator(), rpmdbRebuild(), rpmdbRemove(), rpmdbRemoveDatabase(), rpmdbSetIteratorRE(), rpmdbURIPath(), rpmds_compare(), rpmdsCompare(), rpmdsCpuinfo(), rpmdsELF(), rpmdsFree(), rpmdsFreePRCO(), rpmdsGetconf(), rpmdsLdconfig(), rpmdsMerge(), rpmdsNew(), rpmdsNext(), rpmdsNVRMatchesDep(), rpmdsPipe(), rpmdsSysinfo(), rpmdsThis(), rpmecFree(), rpmExpandNumeric(), rpmfcClassify(), rpmfcExec(), rpmfcFree(), rpmfcGenerateDepends(), rpmfcGenerateDependsHelper(), rpmfcGenerateScriptletDeps(), rpmfd_Fopen(), rpmfiBuildFClasses(), rpmfiBuildFContexts(), rpmfiBuildFDeps(), rpmfiBuildFNames(), rpmfiBuildFSContexts(), rpmfiBuildREContexts(), rpmfiFree(), rpmfiNew(), rpmFreeFilesystems(), rpmFreeMacros(), rpmFreeRpmrc(), rpmfts_dealloc(), rpmfts_initialize(), rpmGenPath(), rpmGetFilesystemUsage(), rpmgiFree(), rpmgiGlobArgv(), rpmgiInitFilter(), rpmgiLoadReadHeader(), rpmgiNext(), rpmgiOpen(), rpmGlob(), rpmHeadersIdentical(), rpmheClean(), rpmInitMacros(), rpmInstallSource(), rpmInstallSourcePackage(), rpmlogClose(), rpmmgFree(), rpmnsClean(), rpmnsProbeSignature(), rpmPlatform(), rpmps_ass_sub(), rpmpsFree(), rpmpsFreeIterator(), rpmpsmFree(), rpmpsmStage(), rpmpsPrint(), rpmQueryVerify(), rpmReadConfigFiles(), rpmReadHeader(), rpmReadHeaders(), rpmReadPackageFile(), rpmReadPackageManifest(), rpmReadRC(), rpmRebuildTargetVars(), rpmReSign(), rpmRollback(), rpmSetMachine(), rpmShowProgress(), rpmShowRC(), rpmSingleHeaderFromFD(), rpmsxFree(), rpmsxParse(), rpmsxSort(), rpmteChain(), rpmteFree(), rpmteFreeTSI(), rpmTempFile(), rpmteNew(), rpmts_Check(), rpmts_HdrCheck(), rpmts_IDTXglob(), rpmts_Run(), rpmtsAddInstallElement(), rpmtsAvailable(), rpmtsCallback(), rpmtsCheck(), rpmtsClean(), rpmtsCreate(), rpmtsFindPubkey(), rpmtsFree(), rpmtsImportPubkey(), rpmtsInitDSI(), rpmtsOpenDB(), rpmtsOpenSDB(), rpmtsOrder(), rpmtsRollback(), rpmtsRun(), rpmtsSetCurrDir(), rpmtsSetRootDir(), rpmtsSolve(), rpmVerifySignatures(), rpmVersionCompare(), rpmWriteHeader(), runImmedTriggers(), runInstScript(), runScript(), saveHardLink(), scpFree(), scpResetAv(), scpResetKeys(), showQueryPackage(), skipFiles(), spec_get_buildroot(), sql_cclose(), sql_cget(), sql_close(), sql_initDB(), sql_open(), sql_stat(), stashSt(), tagClean(), tagLoadATags(), tagStoreFree(), tarHeaderReadName(), timeCheck(), triggercondsTag(), triggertypeTag(), unsatisfiedDepend(), urlFind(), urlFreeCache(), urlGetFile(), urlSplit(), valueFree(), verifyMD5Signature(), verifySHA1Signature(), vrpmlog(), writeLinkedFile(), writeRPM(), XfdFree(), xmlFormat(), XrpmtsiFree(), XurlFree(), yamlFormat(), and zapRelation().

void rpmlog | ( | int | code,
|  | const char * | fmt,
|  |  | ... |
| ) |  |  |

Generate a log message using FMT string and option arguments.

Definition at line 293 of file rpmlog.c.

References vrpmlog().

Referenced by _specQuery(), addChangelog(), addFile(), addFileToTagAux(), addMacro(), addSource(), buildHost(), buildSpec(), checkFiles(), checkForDuplicates(), checkForRequired(), checkForValidArchitectures(), checkOwners(), copyFile(), copyNextLineFromOFI(), cpio_copy(), cpio_doio(), cvtdberr(), db3close(), db3open(), db_fini(), db_init(), dbiFindMatches(), dbiOpen(), dnlInitIterator(), doAddSubtract(), doDefine(), doIcon(), doLogical(), doMultiplyDivide(), doOutput(), doPatch(), doPatchMacro(), doPrimary(), doRelational(), doSetupMacro(), doUndefine(), doUntar(), expandMacro(), expandMacros(), findErases(), findPreambleTag(), flushBuffer(), freeArgs(), fsmMapAttrs(), fsmMkdirs(), fsmStage(), genCpioListAndHeader(), getFilesystemList(), getGidS(), getGname(), getGnameS(), getOutputFrom(), getUidS(), getUname(), getUnameS(), grabArgs(), handlePreambleTag(), headerCheck(), IDTXglob(), ignoreDep(), installArgCallback(), isCompressed(), makeGPGSignature(), makeHDRSignature(), manageFile(), miFreeHeader(), packageBinaries(), parseBuildInstallClean(), parseDescription(), parseExpressionBoolean(), parseExpressionString(), parseFiles(), parseForAttr(), parseForConfig(), parseForDev(), parseForLang(), parseForSimple(), parseForVerify(), parseNoSource(), parsePreamble(), parsePrep(), parseRCPOT(), parseScript(), parseSpec(), prepFetch(), prepFetchVerbose(), printDeps(), printNewSpecfile(), printSize(), processBinaryFile(), processBinaryFiles(), processMetadataFile(), processPackageFiles(), processScriptFiles(), processSourceFiles(), psmWait(), queryHeader(), rdToken(), readFile(), readLine(), readLineFromOFI(), relocateFileList(), rpmCheckPassPhrase(), rpmcliImportPubkeys(), rpmcliInit(), rpmcliInstall(), rpmcliInstallProblems(), rpmcliInstallSuggests(), rpmcliSign(), rpmdbAdd(), rpmdbCheckSignals(), rpmdbCountPackages(), rpmdbExportInfo(), rpmdbFindByFile(), rpmdbGrowIterator(), rpmdbInitIterator(), rpmdbMoveDatabase(), rpmdbNew(), rpmdbNextIterator(), rpmdbRebuild(), rpmdbRemove(), rpmdsCompare(), rpmdsNotify(), rpmdsProblem(), rpmErase(), rpmfcClassify(), rpmfcGenerateDependsHelper(), rpmfiDecideFate(), rpmGetFilesystemUsage(), rpmgiInitFilter(), rpmgiNext(), rpmgiOpen(), rpmgiWalkPathFilter(), rpmInitMacros(), rpmInstallSource(), rpmInstallSourcePackage(), rpmioMkpath(), rpmmgBuffer(), rpmmgFile(), rpmmgNew(), rpmMkdirPath(), rpmpsmStage(), rpmQueryVerify(), rpmReadHeaders(), rpmReadPackageFile(), rpmReadPackageManifest(), rpmReSign(), rpmRollback(), rpmShowProgress(), rpmSingleHeaderFromFD(), rpmspecQuery(), rpmTempFile(), rpmtsAddInstallElement(), rpmtsCheck(), rpmtsFindPubkey(), rpmtsInitDSI(), rpmtsInitIterator(), rpmtsOpenDB(), rpmtsOpenSDB(), rpmtsOrder(), rpmtsRollback(), rpmtsRun(), rpmtsSolve(), rpmVerifySignatures(), runScript(), scpReset(), showQueryPackage(), skipFiles(), sql_busy_handler(), sql_byteswapped(), sql_cdel(), sql_cget(), sql_close(), sql_cput(), sql_initDB(), sql_open(), sql_stat(), timeCheck(), urlConnect(), urlGetFile(), urlSplit(), verifyDependencies(), verifyHeader(), writeRPM(), wrSignature(), and zapRelation().

void rpmlogClose | ( | void |  | ) |

Close desriptor used to write to system logger.

Todo:
  Implement.

Definition at line 78 of file rpmlog.c.

References _free(), nrecs, and recs.

Referenced by rpmioClean().

int rpmlogCode | ( | void |  | ) |

Return error code from last rpmError() message.

Deprecated:
  Perl-RPM needs, what's really needed is predictable, non-i18n encumbered, error text that can be retrieved through rpmlogMessage() and parsed IMHO.

Returns:
  code from last message

Definition at line 35 of file rpmlog.c.

References nrecs, and recs.

static int rpmlogDefault | ( | rpmlogRec | rec | ) | `[static]`

Definition at line 143 of file rpmlog.c.

References _stdlog, RPMLOG_ALERT, RPMLOG_CRIT, RPMLOG_DEBUG, RPMLOG_EMERG, RPMLOG_ERR, RPMLOG_EXIT, RPMLOG_INFO, RPMLOG_NOTICE, RPMLOG_WARNING, and rpmlogLevelPrefix().

Referenced by vrpmlog().

void rpmlogGetCallback | ( | rpmlogCallback * | cb,
|  | rpmlogCallbackData * | data |
| ) |  |  |

Get rpmlog callback function and data.

Parameters:

  | cb | pointer to rpmlog callback function
  | data | pointer to callback private (user) data

Returns:
  none

Definition at line 132 of file rpmlog.c.

References _rpmlogCallback, and _rpmlogCallbackData.

int rpmlogGetNrecs | ( | void |  | ) |

Return number of messages.

Returns:
  number of messages

Definition at line 30 of file rpmlog.c.

References nrecs.

Referenced by buildSpec().

const char* rpmlogLevelPrefix | ( | rpmlogLvl | pri | ) |

Return translated prefix string (if any) given log level.

Parameters:

  | pri | log priority

Returns:
  message prefix (or "" for none)

Definition at line 196 of file rpmlog.c.

References rpmlogMsgPrefix.

Referenced by rpmlogDefault().

const char* rpmlogMessage | ( | void |  | ) |

Return text of last rpmError() message.

Returns:
  text of last message

Definition at line 42 of file rpmlog.c.

References _, nrecs, and recs.

void rpmlogOpen | ( | const char * | ident,
|  | int | option,
|  | int | facility |
| ) |  |  |

Open connection to system logger.

Todo:
  Implement.

Definition at line 93 of file rpmlog.c.

void rpmlogPrint | ( | FILE * | f | ) |

Print all rpmError() messages.

Parameters:

  | f | file handle (NULL uses stderr)

Definition at line 62 of file rpmlog.c.

References nrecs, and recs.

Referenced by buildSpec().

const char* rpmlogRecMessage | ( | rpmlogRec | rec | ) |

Retrieve log message string from rpmlog record.

Parameters:

  | rec | rpmlog record

Returns:
  log message

Definition at line 49 of file rpmlog.c.

rpmlogLvl rpmlogRecPriority | ( | rpmlogRec | rec | ) |

Retrieve log priority from rpmlog record.

Parameters:

  | rec | rpmlog record

Returns:
  log priority

Definition at line 55 of file rpmlog.c.

rpmlogCallback rpmlogSetCallback | ( | rpmlogCallback | cb,
|  | rpmlogCallbackData | data |
| ) |  |  |

Set rpmlog callback function.

Parameters:

  | cb | rpmlog callback function
  | data | callback private (user) data

Returns:
  previous rpmlog callback function

Definition at line 122 of file rpmlog.c.

References _rpmlogCallback, and _rpmlogCallbackData.

FILE* rpmlogSetFile | ( | FILE * | fp | ) |

Set rpmlog file handle.

Parameters:

  | fp | rpmlog file handle (NULL uses stdout/stderr)

Returns:
  previous rpmlog file handle

Definition at line 173 of file rpmlog.c.

References _stdlog.

Referenced by setLogFile().

int rpmlogSetMask | ( | int | mask | ) |

Set the log mask level.

Parameters:

  | mask | log mask (0 is no operation)

Returns:
  previous log mask

Definition at line 106 of file rpmlog.c.

References rpmlogMask.

Referenced by doFoo().

static void vrpmlog | ( | unsigned | code,
|  | const char * | fmt,
|  | va_list | ap |
| ) |  |  | `[static]`

Definition at line 212 of file rpmlog.c.

References _free(), _rpmlogCallback, _rpmlogCallbackData, EXIT_FAILURE, nrecs, recs, RPMLOG_DEFAULT, RPMLOG_EXIT, RPMLOG_FAC, RPMLOG_MASK, RPMLOG_PRI, RPMLOG_WARNING, rpmlogDefault(), rpmlogMask, vsnprintf(), xmalloc(), xrealloc(), and xstrdup().

Referenced by rpmlog().

static int vsnprintf | ( | char * | buf,
|  | int | nb,
|  | const char * | fmt,
|  | va_list | ap |
| ) |  |  | `[inline, static]`

Definition at line 202 of file rpmlog.c.

Referenced by vrpmlog().

## Variable Documentation

rpmlogCallback _rpmlogCallback = NULL`[static]`

Definition at line 117 of file rpmlog.c.

Referenced by rpmlogGetCallback(), rpmlogSetCallback(), and vrpmlog().

rpmlogCallbackData _rpmlogCallbackData = NULL`[static]`

Definition at line 120 of file rpmlog.c.

Referenced by rpmlogGetCallback(), rpmlogSetCallback(), and vrpmlog().

FILE* _stdlog = NULL`[static]`

Definition at line 141 of file rpmlog.c.

Referenced by rpmlogDefault(), and rpmlogSetFile().

int nrecs = 0`[static]`

Definition at line 14 of file rpmlog.c.

Referenced by rpmlogClose(), rpmlogCode(), rpmlogGetNrecs(), rpmlogMessage(), rpmlogPrint(), and vrpmlog().

rpmlogRec recs = NULL`[static]`

Definition at line 16 of file rpmlog.c.

Referenced by handleOverlappedFiles(), rpmlogClose(), rpmlogCode(), rpmlogMessage(), rpmlogPrint(), and vrpmlog().

unsigned rpmlogMask = RPMLOG_UPTO( RPMLOG_NOTICE )`[static]`

Definition at line 99 of file rpmlog.c.

Referenced by rpmlogSetMask(), and vrpmlog().

const char* rpmlogMsgPrefix[]`[static]`

Initial value:

     {
        N_("fatal error: "),
        N_("fatal error: "),
        N_("fatal error: "),
        N_("error: "),
        N_("warning: "),
        "",
        "",
        "D: ",
    }

Definition at line 184 of file rpmlog.c.

Referenced by rpmlogLevelPrefix().