{"id":23431974,"url":"https://github.com/keremtan/logger","last_synced_at":"2025-04-13T00:30:25.048Z","repository":{"id":162767225,"uuid":"590168999","full_name":"KeremTAN/Logger","owner":"KeremTAN","description":"A logging class will be designed in this repository that can control the number of log files and the frequency of their occurrence.","archived":false,"fork":false,"pushed_at":"2023-03-08T10:18:09.000Z","size":1370,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T18:22:28.016Z","etag":null,"topics":["cpp","cpp11","logger","logging","logging-library","oop-in-cpp","oop-principles","queue","singleton-pattern","thread","threading"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KeremTAN.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-17T19:59:33.000Z","updated_at":"2024-12-07T15:29:40.000Z","dependencies_parsed_at":"2023-05-27T10:30:40.485Z","dependency_job_id":null,"html_url":"https://github.com/KeremTAN/Logger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeremTAN%2FLogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeremTAN%2FLogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeremTAN%2FLogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KeremTAN%2FLogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KeremTAN","download_url":"https://codeload.github.com/KeremTAN/Logger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650591,"owners_count":21139670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","cpp11","logger","logging","logging-library","oop-in-cpp","oop-principles","queue","singleton-pattern","thread","threading"],"created_at":"2024-12-23T10:51:53.565Z","updated_at":"2025-04-13T00:30:25.030Z","avatar_url":"https://github.com/KeremTAN.png","language":"C++","readme":"# Logger\n* [Summary Information](#si)\n* [config.json](#config)\n* [JsonParser \u0026 Logger](#jl)\n    * [Code example using JsonParser and Logger objects;](#exm)\n* [Example Image of Terminal](#img)\n\n\u003ca name=\"si\"\u003e\u003c/a\u003e\nWith this logging class, you will be able to log daily, hourly, minute and second, and create a separate log file for each logging. The naming of the log files will be the UTC format of that date. If the number of log files you keep is more than the maximum number you set, your oldest log file will be deleted by automatically.\n\nThe created log files will be in the **logs** directory.\n\nYou can control the number of log files, the frequency of occurrence and the type of log that will be created in this application.\n\n\u003ca name=\"config\"\u003e\u003c/a\u003e\nYou can change the data in the **configs/config.json** file to set the properties mentioned above.\n\nYou can change the variable maxLogFiles to set the number of log files. According to the value here, your old log files will be deleted as new log files are added.\n\nYou can change the variable logFrequency to set the frequency of occurrence of log files. File occurrence frequencies are **second**, **minute**, **hourly** and **daily**.\n\nYou can change the variable logLevel to set the level of the logged log files. Log levels are **warn**, **info**, **debug** and **error**.\n\nExample of config.json\n```json\n{\n    \"maxLogFiles\":  3,\n    \"logFrequency\": \"second\",\n    \"logLevel\":     \"warn\"\n}\n```\n\u003ca name=\"jl\"\u003e\u003c/a\u003e\nThere is one JsonParse class for parsing the json object shown in the above example. You just need to give the path of your json file to the constructor of this class.\n\nI have added nlohmann's json library to this project in case you need a professional json library. You can use that library directly if you wish.\nFor detailed information about nlohmann's json library, go to the link (https://github.com/nlohmann/json).\n\nHowever, if you use nlohmann's library, you will need to convert the data that you parse into **LogFrequency and LogLevel types** with **Frequency and Level namespaces**.\n```c++\n    LogFrequency    logFrequency = Frequency::convert(j[\"logFrequency\"]);\n    LogLevel        logLevel = Level::convert(j[\"logLevel\"]);\n```\n\nAfter parsing the data in the config.json file, you need to create a Logger object. While creating the Logger class, its constructor expects 4 parameters. These parameters are respectively maximum number of files, log file creation frequency, log level and a bool value for pressing the terminal while saving the logs. If these parameters are not entered while creating the Logger object, these parameters will work with their default values.\n\nAfter the logger object is created, you just need to call the log method.\n\n\u003ca name=\"exm\"\u003e\u003c/a\u003e\nCode example using JsonParser and Logger objects;\n```c++\nint main(int argc, char** argv){\n  JsonParser json(\"/configs/config.json\");\n\n  int maxLogFiles = json.getMaxLogFiles();\n  LogFrequency logFrequency = json.getLogFrequency();\n  LogLevel logLevel = json.getLogLevel();\n\n  Logger logger(maxLogFiles, logFrequency, logLevel, true); \n  logger.log(\"This is a log about logger\");\n\n  std::cin.get();\n}\n```\n\u003ca name=\"img\"\u003e\u003c/a\u003e\nAn example image of the terminal outputs you will get when you use this log application; \u003c/br\u003e\n ![UML](https://github.com/KeremTAN/Logger/blob/main/img/terminal.png)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeremtan%2Flogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeremtan%2Flogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeremtan%2Flogger/lists"}