2014-02-26 07:51:06 +01:00
|
|
|
/* log.h
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Toxic All Rights Reserved.
|
|
|
|
*
|
|
|
|
* This file is part of Toxic.
|
|
|
|
*
|
|
|
|
* Toxic 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.
|
|
|
|
*
|
|
|
|
* Toxic 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 Toxic. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-09-23 03:24:45 +02:00
|
|
|
#ifndef LOG_H
|
|
|
|
#define LOG_H
|
2014-06-12 00:06:55 +02:00
|
|
|
|
2014-03-25 13:25:10 +01:00
|
|
|
struct chatlog {
|
|
|
|
FILE *file;
|
|
|
|
uint64_t lastwrite;
|
2014-09-22 10:29:28 +02:00
|
|
|
char path[MAX_STR_SIZE];
|
2014-03-25 13:25:10 +01:00
|
|
|
bool log_on; /* specific to current chat window */
|
|
|
|
};
|
|
|
|
|
2014-09-22 23:09:39 +02:00
|
|
|
enum {
|
|
|
|
LOG_GROUP,
|
|
|
|
LOG_PROMPT,
|
|
|
|
LOG_CHAT,
|
|
|
|
} LOG_TYPE;
|
2014-02-26 12:35:19 +01:00
|
|
|
|
2014-03-04 01:21:52 +01:00
|
|
|
/* formats/writes line to log file */
|
2014-07-29 20:54:34 +02:00
|
|
|
void write_to_log(const char *msg, const char *name, struct chatlog *log, bool event);
|
2014-03-01 13:10:44 +01:00
|
|
|
|
2014-03-04 01:21:52 +01:00
|
|
|
/* enables logging for specified log and creates/fetches file if necessary */
|
2014-09-22 23:09:39 +02:00
|
|
|
void log_enable(char *name, const char *selfkey, const char *otherkey, struct chatlog *log, int logtype);
|
2014-03-04 01:21:52 +01:00
|
|
|
|
|
|
|
/* disables logging for specified log and closes file */
|
2014-03-02 00:06:35 +01:00
|
|
|
void log_disable(struct chatlog *log);
|
2014-06-12 00:06:55 +02:00
|
|
|
|
2014-09-22 10:29:28 +02:00
|
|
|
/* Loads previous history from chat log */
|
|
|
|
void load_chat_history(ToxWindow *self, struct chatlog *log);
|
|
|
|
|
2014-09-27 08:28:11 +02:00
|
|
|
/* renames chatlog file replacing src with dest.
|
|
|
|
Returns 0 on success or if no log exists, -1 on failure. */
|
|
|
|
int rename_logfile(char *src, char *dest, const char *selfkey, const char *otherkey, int winnum);
|
|
|
|
|
2014-09-23 03:24:45 +02:00
|
|
|
#endif /* #define LOG_H */
|