Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
log.h
1// SPDX-FileCopyrightText: © 2019-2023 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#ifndef __UTILS_LOG_H__
5#define __UTILS_LOG_H__
6
7#include "gtk_wrapper.h"
8
9typedef struct _LogViewerWidget LogViewerWidget;
10typedef struct MPMCQueue MPMCQueue;
11typedef struct ObjectPool ObjectPool;
12
19#define LOG (zlog)
20
21typedef struct Log
22{
23 FILE * logfile;
24
25#if 0
26 /* Buffers to fill in */
27 GtkTextBuffer * messages_buf;
28 GtkTextBuffer * warnings_buf;
29 GtkTextBuffer * critical_buf;
30#endif
31
34
38
41
44
45 bool initialized;
46
54
61
63 LogViewerWidget * viewer;
64
67
76} Log;
77
79extern Log * zlog;
80
88NONNULL void
89log_init_writer_idle (Log * self, unsigned int secs);
90
94NONNULL int
96
106NONNULL char *
107log_get_last_n_lines (Log * self, int n);
108
115NONNULL_ARGS (1, 2, 3)
117 Log * self,
118 char ** ret_dir,
119 char ** ret_path,
120 GError ** error);
121
132WARN_UNUSED_RESULT bool
133log_init_with_file (Log * self, const char * filepath, GError ** error);
134
138CONST
139WARN_UNUSED_RESULT Log **
140log_get (void);
141
147Log *
148log_new (void);
149
153NONNULL void
154log_free (Log * self);
155
160#endif
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
Log * zlog
Global variable, available to all files.
CONST WARN_UNUSED_RESULT Log ** log_get(void)
Returns a pointer to the global zlog.
NONNULL void log_free(Log *self)
Stops logging and frees any allocated memory.
Log * log_new(void)
Creates the logger and sets the writer func.
NONNULL void log_init_writer_idle(Log *self, unsigned int secs)
Initializes logging to a file.
NONNULL char * log_get_last_n_lines(Log *self, int n)
Returns the last n lines as a newly allocated string.
NONNULL int log_idle_cb(Log *self)
Idle callback.
bool log_generate_compressed_file(Log *self, char **ret_dir, char **ret_path, GError **error)
Generates a compressed log file (for sending with bug reports).
WARN_UNUSED_RESULT bool log_init_with_file(Log *self, const char *filepath, GError **error)
Initializes logging to a file.
Definition log.h:22
gint64 last_bt_time
Last timestamp a backtrace was obtained.
Definition log.h:75
bool use_structured_for_console
Whether to use structured log when writing to the console.
Definition log.h:53
char * log_filepath
Current log file path.
Definition log.h:33
LogViewerWidget * viewer
Currently opened log viewer.
Definition log.h:63
guint writer_source_id
ID of the source function.
Definition log.h:66
char * log_domains
Used by the writer func.
Definition log.h:43
GLogLevelFlags min_log_level_for_test_console
Minimum log level for the console.
Definition log.h:60
ObjectPool * obj_pool
Object pool for the queue.
Definition log.h:40
MPMCQueue * mqueue
Message queue, for when messages are sent from a non-gtk thread.
Definition log.h:37
Multiple Producer Multiple Consumer lock-free queue.
Definition mpmc_queue.h:69