-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.c
More file actions
61 lines (53 loc) · 2.16 KB
/
Copy pathmain.c
File metadata and controls
61 lines (53 loc) · 2.16 KB
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
/**
* @file main.c
* @brief ThreadSafeCLogger: A high-performance, thread-safe logging library for C applications.
* @author Harshith Sunku
* @date [12/22/2023]
* @version 1.0
* @website https://www.harshith.in/ | https://harshithsunku.in/
* @repository https://github.com/harshithsunku/ThreadSafeCLogger
*
* @note This file is part of ThreadSafeCLogger, which provides multi-threaded
* logging capabilities in a thread-safe manner.
* @details Further details about the implementation can be found in
* the README or the official documentation at the above website/github.
*
* ThreadSafeCLogger is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ThreadSafeCLogger is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ThreadSafeCLogger. If not, see <https://www.gnu.org/licenses/>.
*
* @bugs No known bugs at the time of writing.
* @todo Features or fixes planned for future versions.
*/
#include <stdio.h>
#include "logger.h"
/*
* Main function of the application.
* Initializes the logger, performs application tasks, and then closes the logger.
*/
int main() {
// Initialize the logger
if (log_init("log.txt", LOG_LEVEL_INFO) != 0) {
fprintf(stderr, "Failed to initialize logger\n");
return 1;
}
// Write a log message indicating the application has started
log_write(LOG_LEVEL_INFO, "Application started");
// Application code here
// Write a log message indicating the application is ending
log_write(LOG_LEVEL_INFO, "Application ending");
//Function to print the log in reverse order.
read_log_reverse_thread_safe("log.txt");
// Close the logger
log_close();
return 0;
}