Skip to content

Commit

Permalink
Updated realease branch to the new version of the library(1.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
florianLopitaux committed May 19, 2023
1 parent 7326bd3 commit a6412f7
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 51 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CppLogger Version 1.0
CppLogger is cross-platform develoment light library to display beautiful message of logging in your console or in an output file.
# CppLogger Version 1.1
CppLogger is an open-source cross-platform develoment C++ lightweight library to display beautiful message of logging in your console or in an output file.
More documentation is available in the README.md of the [main branch](https://github.com/florianLopitaux/CppLogger/tree/main) of this repository.

The library can be used simply by doing a basic link edit with the static library at compile time.
Expand Down
70 changes: 33 additions & 37 deletions include/DebugLogger.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file src.include.DebugLogger.h
* @author Florian Lopitaux
* @version 1.0
* @version 1.1
* @brief Header file of the DebugLogger class.
*
* --------------------------------------------------------------------
Expand Down Expand Up @@ -33,7 +33,6 @@

#include <iostream>
#include <fstream>
#include "windows.h"

#include "LoggerColor.h"

Expand All @@ -43,12 +42,6 @@
* @brief Namespace that contains all the class, enum, ... of the CppLogger library.
*/
namespace nsCppLogger {
/**
* @typedef textColor_t
* @brief Type representing the two colors needed by a type log.
*/
typedef std::pair<LoggerColor, LoggerColor> textColor_t;

/**
* @class DebugLogger
* @brief Class representing the logger object.
Expand All @@ -63,10 +56,9 @@ namespace nsCppLogger {

std::ofstream logFile;

HANDLE outHandle;
textColor_t errorColors;
textColor_t warningColors;
textColor_t infoColors;
LoggerColor errorColor;
LoggerColor warningColor;
LoggerColor infoColor;


// PRIVATE METHODS
Expand All @@ -78,10 +70,17 @@ namespace nsCppLogger {
/**
* @brief Initialize everything to print in a log file.
*
* @param path [in] The path of the log file
* @param path {std::string} [in] The path of the log file
*/
void enableLogFileMode(const std::string & path);

/**
* @brief Set the text color of the terminal output.
*
* @param color {nsCppLogger::LoggerColor} [in] The color to applied on the text
*/
void setTerminalColor(const LoggerColor color) const;


public:
// CONSTRUCTORS & DESTRUCTOR
Expand All @@ -91,7 +90,7 @@ namespace nsCppLogger {
* Instantiate an object of the DebugLogger class,
* initialize everything to begin to print in the console.
*
* @param level [in] [optional] The level of debugging, 0 by default
* @param level {unsigned} [in] [optional] The level of debugging, 0 by default
*/
DebugLogger(const unsigned level = 0);

Expand All @@ -103,8 +102,8 @@ namespace nsCppLogger {
*
* If the path parameter is an empty string, we activate the console print mode.
*
* @param logFilePath [in] The path of the file to print the logs.
* @param level [in] [optional] The level of debugging, 0 by default
* @param logFilePath {std::string} [in] The path of the file to print the logs
* @param level {unsigned} [in] [optional] The level of debugging, 0 by default
*/
DebugLogger(const std::string & logFilePath, const unsigned level = 0);

Expand All @@ -122,7 +121,7 @@ namespace nsCppLogger {
*
* Get the current debugging level of the logger.
*
* @return The level of debugging
* @return {unsigned} The level of debugging
*/
unsigned getDebugLevel();

Expand All @@ -133,39 +132,36 @@ namespace nsCppLogger {
*
* Change the current debugging level of the logger.
*
* @param level [in] The new debugging level
* @param level {unsigned} [in] The new debugging level
*/
void setDebugLevel(const unsigned level);

/**
* @brief Setter of the 'errorColors' attribute.
*
* Change the colors used to print the error in the terminal.
* Change the color used to print the error in the terminal.
*
* @param primaryColor [in] The color used to the error balise and the error type
* @param secondaryColor [in] The color used to the description message
* @param color {LoggerColor} [in] The color used to the error logs
*/
void setErrorColors(const LoggerColor primaryColor, const LoggerColor secondaryColor);
void setErrorColors(const LoggerColor color);

/**
* @brief Setter of the 'warningColors' attribute.
*
* Change the colors used to print the warning in the terminal.
* Change the color used to print the warning in the terminal.
*
* @param primaryColor [in] The color used to the warning balise
* @param secondaryColor [in] The color used to the description message
* @param color {LoggerColor} [in] The color used to the warning logs
*/
void setWarningColors(const LoggerColor primaryColor, const LoggerColor secondaryColor);
void setWarningColors(const LoggerColor color);

/**
* @brief Setter of the 'infoColors' attribute.
*
* Change the colors used to print the information in the terminal.
* Change the color used to print the information in the terminal.
*
* @param primaryColor [in] The color used to the information balise
* @param secondaryColor [in] The color used to the description message
* @param color {LoggerColor} [in] The color used to the information logs
*/
void setInformationColors(const LoggerColor primaryColor, const LoggerColor secondaryColor);
void setInformationColors(const LoggerColor color);


// PUBLIC METHODS
Expand All @@ -174,9 +170,9 @@ namespace nsCppLogger {
*
* Print the trace of the error with the custom displaying.
*
* @param logLevel [in] The level needed to print the log
* @param typeError [in] The text resume of the error
* @param msg [in] The complete message description of the error
* @param logLevel {unsigned} [in] The level needed to print the log
* @param typeError {std::string} [in] The text resume of the error
* @param msg {std::string} [in] The complete message description of the error
*/
void error(const unsigned logLevel, const std::string & typeError, const std::string & msg);

Expand All @@ -185,8 +181,8 @@ namespace nsCppLogger {
*
* Print the trace of the warning with the custom displaying.
*
* @param logLevel [in] The level needed to print the log
* @param msg [in] The message of the warning
* @param logLevel {unsigned} [in] The level needed to print the log
* @param msg {std::string} [in] The message of the warning
*/
void warning(const unsigned logLevel, const std::string & msg);

Expand All @@ -195,8 +191,8 @@ namespace nsCppLogger {
*
* Print the trace of the information with the custom displaying.
*
* @param logLevel [in] The level needed to print the log
* @param msg [in] The information to print
* @param logLevel {unsigned} [in] The level needed to print the log
* @param msg {std::string} [in] The information to print
*/
void inform(const unsigned logLevel, const std::string & msg);
};
Expand Down
37 changes: 25 additions & 12 deletions include/LoggerColor.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file src.include.LoggerColor.h
* @author Florian Lopitaux
* @version 1.0
* @version 1.1
* @brief Header file of the LoggerColor enum.
*
* --------------------------------------------------------------------
Expand All @@ -26,7 +26,7 @@
* This banner notice must not be removed.
*
* --------------------------------------------------------------------
*/
*/

#ifndef COLORS_LOGGER_H
#define COLORS_LOGGER_H
Expand All @@ -37,10 +37,12 @@
* @brief Namespace that contains all the class, enum, ... of the CppLogger library.
*/
namespace nsCppLogger {
#ifdef _WIN32 // we are on a windows os

/**
* @enum LoggerColor
* @brief The colors available of the log trace.
*/
*/
enum LoggerColor {
BLACK,
BLUE,
Expand All @@ -49,16 +51,27 @@ namespace nsCppLogger {
RED,
PURPLE,
YELLOW,
WHITE,
GRAY,
LIGHT_BLUE,
LIGHT_GREEN,
LIGHT_AQUA,
LIGHT_RED,
LIGHT_PURPLE,
LIGHT_YELLOW,
BRIGHT_WHITE
WHITE
};

#else // we are on a linux or mac os

/**
* @enum LoggerColor
* @brief The colors available of the log trace.
*/
enum LoggerColor {
BLACK = 30,
RED = 31,
GREEN = 32,
YELLOW = 33,
BLUE = 34,
PURPLE = 35,
CYAN = 36,
WHITE = 37
};

#endif
}

#endif
Binary file modified lib/libCppLogger.a
Binary file not shown.

0 comments on commit a6412f7

Please sign in to comment.