Commit ed62a468 authored by Adrien Oliva's avatar Adrien Oliva

feat(conf): Create configuration for color

- Implement accessor and mutator for color configuration variable name.

GTLAB #6
parent 43451624
Pipeline #239 passed with stages
in 1 minute and 20 seconds
11 Adrien Oliva <olivaa+gitlab@yapbreak.fr>
14 Adrien Oliva <olivaa+gitlab@yapbreak.fr>
......@@ -17,6 +17,11 @@ void logger::setLevelVariable(const char *level)
InternalLog::setLevelVariable(level);
}
void logger::setColorVariable(const char *color)
{
InternalLog::setColorVariable(color);
}
void logger::unsetDestinationVariable()
{
InternalLog::unsetDestinationVariable();
......@@ -26,3 +31,8 @@ void logger::unsetLevelVariable()
{
InternalLog::unsetLevelVariable();
}
void logger::unsetColorVariable()
{
InternalLog::unsetColorVariable();
}
......@@ -96,8 +96,10 @@ namespace logger {
*/
void setDestinationVariable(const char *dest);
void setLevelVariable(const char *level);
void setColorVariable(const char *color);
void unsetDestinationVariable();
void unsetLevelVariable();
void unsetColorVariable();
};
#endif /* end of include guard: YAPLOG_H_UGV90DZC */
......@@ -8,6 +8,7 @@ using namespace logger;
char *InternalLog::s_destination = NULL;
char *InternalLog::s_level = NULL;
char *InternalLog::s_color = NULL;
InternalLog::InternalLog(log_level level, const log_location &loc,
std::ostream *destination,
......@@ -127,6 +128,11 @@ const char *InternalLog::getLevelVariable()
return s_level ? s_level : YAPLOG_LEVEL_DEFAULT;
}
const char *InternalLog::getColorVariable()
{
return s_color ? s_color : YAPLOG_COLOR_DEFAULT;
}
void InternalLog::setDestinationVariable(const char *dest)
{
unsetDestinationVariable();
......@@ -139,6 +145,12 @@ void InternalLog::setLevelVariable(const char *level)
s_level = strdup(level);
}
void InternalLog::setColorVariable(const char *color)
{
unsetColorVariable();
s_color = strdup(color);
}
void InternalLog::unsetDestinationVariable()
{
if (s_destination != NULL)
......@@ -152,3 +164,10 @@ void InternalLog::unsetLevelVariable()
free(static_cast<void *>(s_level));
s_level = NULL;
}
void InternalLog::unsetColorVariable()
{
if (s_color != NULL)
free(static_cast<void *>(s_color));
s_color = NULL;
}
......@@ -8,6 +8,7 @@
#define YAPLOG_LEVEL_DEFAULT "LOGLEVEL"
#define YAPLOG_DEST_DEFAULT "LOGDESTINATION"
#define YAPLOG_COLOR_DEFAULT "LOGCOLOR"
namespace logger {
......@@ -158,6 +159,12 @@ namespace logger {
* @return Level environment variable
*/
static const char *getLevelVariable();
/**
* @brief Get environment variable to check for log color to show.
*
* @return Color environment variable
*/
static const char *getColorVariable();
/**
* @brief Environment variable name of log destination
......@@ -168,6 +175,10 @@ namespace logger {
* @brief Environment variable name of log level configuration.
*/
static char *s_level;
/**
* @brief Environment variable name of log color configuration.
*/
static char *s_color;
public:
/**
......@@ -183,6 +194,12 @@ namespace logger {
*/
static void setLevelVariable(const char *level);
/**
* @brief Set environment variable to check for log color.
*
* @param color New color environement variable
*/
static void setColorVariable(const char *color);
/**
* @brief Unset environment variable to check for log file destination.
*/
static void unsetDestinationVariable();
......@@ -190,6 +207,10 @@ namespace logger {
* @brief Unset environment variable to check for log level.
*/
static void unsetLevelVariable();
/**
* @brief Unset environment variable to check for log color.
*/
static void unsetColorVariable();
};
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment