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 <stdbool.h>
8
9#include <gtk/gtk.h>
10
11typedef struct _LogViewerWidget LogViewerWidget;
12typedef struct MPMCQueue MPMCQueue;
13typedef struct ObjectPool ObjectPool;
14
21#define LOG (zlog)
22
23typedef struct Log
24{
25 FILE * logfile;
26
27#if 0
28 /* Buffers to fill in */
29 GtkTextBuffer * messages_buf;
30 GtkTextBuffer * warnings_buf;
31 GtkTextBuffer * critical_buf;
32#endif
33
36
40
43
46
47 bool initialized;
48
56
63
65 LogViewerWidget * viewer;
66
69
78} Log;
79
81extern Log * zlog;
82
90NONNULL void
91log_init_writer_idle (Log * self, unsigned int secs);
92
96NONNULL int
98
108NONNULL char *
109log_get_last_n_lines (Log * self, int n);
110
117NONNULL_ARGS (1, 2, 3)
119 Log * self,
120 char ** ret_dir,
121 char ** ret_path,
122 GError ** error);
123
134WARN_UNUSED_RESULT bool
135log_init_with_file (Log * self, const char * filepath, GError ** error);
136
140CONST
141WARN_UNUSED_RESULT Log **
142log_get (void);
143
149Log *
150log_new (void);
151
155NONNULL void
156log_free (Log * self);
157
162#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:24
gint64 last_bt_time
Last timestamp a backtrace was obtained.
Definition log.h:77
bool use_structured_for_console
Whether to use structured log when writing to the console.
Definition log.h:55
char * log_filepath
Current log file path.
Definition log.h:35
LogViewerWidget * viewer
Currently opened log viewer.
Definition log.h:65
guint writer_source_id
ID of the source function.
Definition log.h:68
char * log_domains
Used by the writer func.
Definition log.h:45
GLogLevelFlags min_log_level_for_test_console
Minimum log level for the console.
Definition log.h:62
ObjectPool * obj_pool
Object pool for the queue.
Definition log.h:42
MPMCQueue * mqueue
Message queue, for when messages are sent from a non-gtk thread.
Definition log.h:39
Multiple Producer Multiple Consumer lock-free queue.
Definition mpmc_queue.h:69