Readme, and comments

testing v0.4
marcelb 9 months ago
parent 4f47abbade
commit b0dab7ac6e
  1. 52
      README.md
  2. 48
      lib/log.hpp

@ -1,5 +1,55 @@
# A simple Logging library for C++ # A simple Logging library for C++ programs
Logging errors to a file, daily file rotation, date and time stamps. Configurable record structure etc. Logging errors to a file, daily file rotation, date and time stamps. Configurable record structure etc.
## Features
- Object oriented
- Customizable directory for files
- Daily file rotation
- Protection of recording consecutive errors
- Thread safe
- Exceptions
- The possibility of printing logs in the console
- Ability to keep log file open for faster speed
- Supports multiple simultaneous log files by custom directories
## Installation
Just download the latest release and unzip it into your project. You can turn it on with:
```
#include "log/lib/log.hpp"
using namespace marcelb;
```
## Usage
```c++
/**
* Initialization and declaration
*/
log mylog("../log");
/**
* Put log in file
*/
mylog.put("[EVENT] Start loging");
```
## License
[APACHE 2.0](http://www.apache.org/licenses/LICENSE-2.0/)
## Support & Feedback
For support and any feedback, contact the address: marcelb96@yahoo.com.
## Contributing
Contributions are always welcome!
Feel free to fork and start working with or without a later pull request. Or contact for suggest and request an option.

@ -13,8 +13,10 @@ namespace marcelb {
using namespace std; using namespace std;
/**
* Log class - used at the level of one log directory
*/
class log { class log {
public:
string dir; string dir;
bool isKeepOpen; bool isKeepOpen;
bool printInConsole; bool printInConsole;
@ -24,16 +26,54 @@ class log {
string path; string path;
mutex io; mutex io;
log (string _dir, bool _isKeepOpen = true, bool _printInConsole = false); /**
* Checking if the path is in the string dir directory
*/
bool isdir(); bool isdir();
/**
* Opens the log file
*/
bool open(); bool open();
/**
* Closes the log file
*/
void loose(); void loose();
/**
* Get time
*/
void setMoment(); void setMoment();
/**
* Generate full log file path
*/
void setPath(); void setPath();
void put(string logline);
/**
* Set log line time prefix
*/
void setPrefix(string &logline); void setPrefix(string &logline);
public:
/**
* Constructor,
* receives the log directory path,
* optional: a bool variable if it keeps the file open,
* and a bool variable if it prints log lines to the console
*/
log (string _dir, bool _isKeepOpen = true, bool _printInConsole = false);
/**
* Put string log in file
*/
void put(string logline);
/**
* Destruktor, close log files
*/
~log(); ~log();
}; };

Loading…
Cancel
Save