/usr/include/log4shib/FixedContextCategory.hh is in liblog4shib-dev 1.0.9-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | /*
* FixedContextCategory.hh
*
* Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
* Copyright 2001, Bastiaan Bakker. All rights reserved.
*
* See the COPYING file for the terms of usage and distribution.
*/
#ifndef _LOG4SHIB_FIXEDCONTEXTCATEGORY_HH
#define _LOG4SHIB_FIXEDCONTEXTCATEGORY_HH
#include <log4shib/Portability.hh>
#include <log4shib/Category.hh>
namespace log4shib {
/**
* This Category subclass replaces the NDC field in LoggingEvents with
* a fixed context string. All handling of Appenders, etc. is delgated
* to the 'normal' Category with the same name. Its intended use is
* for object instances that serve a single client: they contruct a
* FixedContextCategory with the client identifier as context.
* Unlike with regular Category instances one has to explicitly create
* FixedContextCategory instances using the constructor. This also
* implies one has to take cake of destruction of the instance as well.
* @since 0.2.4
**/
class LOG4SHIB_EXPORT FixedContextCategory : public Category {
public:
/**
* Constructor
* @param name the fully qualified name of this Categories delegate
* Category.
* @param context the context to fill the NDC field of LoggingEvents
* with.
**/
FixedContextCategory(const std::string& name,
const std::string& context = "");
/**
* Destructor for Category.
**/
virtual ~FixedContextCategory();
/**
* Set the context string used as NDC.
* @param context the context string
**/
virtual void setContext(const std::string& context);
/**
* Return the context string used as NDC.
* @return the context string.
**/
virtual std::string getContext() const;
/**
* Returns the assigned Priority, if any, for this Category.
* @return Priority - the assigned Priority, can be Priority::NOTSET
**/
virtual Priority::Value getPriority() const throw();
/**
* Starting from this Category, search the category hierarchy for a
* set priority and return it. Otherwise, return the priority
* of the root category.
*
* <p>The Category class is designed so that this method executes as
* quickly as possible.
**/
virtual Priority::Value getChainedPriority() const throw();
/**
* For the moment this method does nothing.
**/
virtual void addAppender(Appender* appender) throw();
/**
* For the moment this method does nothing.
**/
virtual void addAppender(Appender& appender);
/**
* Returns the Appender for this Category, or NULL if no Appender has
* been set.
* @returns The Appender.
**/
virtual Appender* getAppender() const;
/**
* Returns the specified Appender for this Category, or NULL if
* the Appender is not attached to this Category.
* @since 0.2.7
* @returns The Appender.
**/
virtual Appender* getAppender(const std::string& name) const;
/**
* Returns the set of Appenders currently attached to this Catogory.
* @since 0.3.1
* @returns The set of attached Appenders.
**/
virtual AppenderSet getAllAppenders() const;
/**
* Removes all appenders set for this Category. Currently a Category
* can have only one appender, but this may change in the future.
**/
virtual void removeAllAppenders();
/**
* FixedContextAppenders cannot own Appenders.
* @returns false
**/
virtual bool ownsAppender() const throw();
/**
* FixedContextAppenders cannot own Appenders.
* @returns false
**/
virtual bool ownsAppender(Appender* appender)
const throw();
/**
* Call the appenders in the hierarchy starting at
* <code>this</code>. If no appenders could be found, emit a
* warning.
*
* <p>This method always calls all the appenders inherited form the
* hierracy circumventing any evaluation of whether to log or not to
* log the particular log request.
*
* @param event The LoggingEvent to log.
**/
virtual void callAppenders(const LoggingEvent& event) throw();
/**
* Set the additivity flag for this Category instance.
**/
virtual void setAdditivity(bool additivity);
/**
* Returns the additivity flag for this Category instance.
**/
virtual bool getAdditivity() const throw();
protected:
/**
* Unconditionally log a message with the specified priority.
* @param priority The priority of this log message.
* @param message string to write in the log file
**/
virtual void _logUnconditionally2(Priority::Value priority,
const std::string& message) throw();
private:
/**
* The delegate category of this FixedContextCategory.
**/
Category& _delegate;
/** The context of this FixedContextCategory. */
std::string _context;
};
}
#endif // _LOG4SHIB_FIXEDCONTEXTCATEGORY_HH
|