First version of table journald overview is done

pull/62/head
Ivan Yartsev 2 years ago
parent c3b63593e7
commit 667c7b5c18

@ -267,13 +267,34 @@ void on_inspector_jornald_read_async(inspector_window *window){
}
char output[4092];
GtkTreeIter iter;
// while (1){
// if(fgets(output,4092,fl)){
// gtk_list_store_append(window->list, &iter);
main_config.remove_thread=0;
while (main_config.remove_thread==0){
if(fgets(output,4092,fl)){
if(strcmp(output,"")){
gtk_list_store_append(window->list, &iter);
char *identifier="";
char *temp = yon_char_new(output);
char *log=temp;
if (strstr(log,"\033[H\033[2J\033[3"))
yon_char_divide(log,strlen("\033[H\033[2J\033[3"));
log = yon_char_divide_search(log,"\n",-1);
if (window->last_mode<5){
identifier = log;
log=strstr(log,":")+1;
log=strstr(log,":")+1;
log=strstr(log,":")+1;
char *iden = yon_char_new(identifier);
identifier=yon_char_divide(iden,strlen(identifier)-strlen(log)-1);
free(iden);
}
// gtk_list_store_set(window->list,&iter,0,&);
// }
// }
gtk_list_store_set(window->list,&iter,0,identifier,1,log,-1);
free(temp);
}
}
// g_usleep(100);
}
}
void on_inspector_update(GtkWidget *self, inspector_window *window){
@ -282,64 +303,42 @@ void on_inspector_update(GtkWidget *self, inspector_window *window){
config_str output;
if (!strcmp(window->journal_name,"journald")){
GtkWidget *terminal = (GtkWidget*)window->terminals->first->data;
if (self==window->UpdateButton){
switch(window->last_mode){
case 0:
yon_terminal_integrated_start(terminal, get_journal_output_command,NULL,NULL);
break;
case 1:
yon_terminal_integrated_start(terminal, get_journal_output_since_boot_command,NULL,NULL);
break;
case 2:
yon_terminal_integrated_start(terminal, get_journal_output_followed_command,NULL,NULL);
break;
case 3:
yon_terminal_integrated_start(terminal, get_journal_output_kernel_command,NULL,NULL);
break;
case 4:
yon_terminal_integrated_start(terminal, get_journal_output_prioritied_command,NULL,NULL);
break;
case 5:
yon_terminal_integrated_start(terminal, get_journal_all_boots_command,NULL,NULL);
break;
case 6:
yon_terminal_integrated_start(terminal, get_journal_all_units_command,NULL,NULL);
break;
case 7:
yon_terminal_integrated_start(terminal, get_journal_init_tree_command,NULL,NULL);
break;
}
}
gtk_widget_hide(window->LoggingNotebook);
gtk_widget_show(gtk_widget_get_parent(window->JournaldTree));
if (self==window->ShowSinceBootButton){
window->last_mode=1;
yon_terminal_integrated_start(terminal, get_journal_output_since_boot_command,NULL,NULL);
}
if (self==window->NewMessagesButton){
window->last_mode=2;
yon_terminal_integrated_start(terminal, get_journal_output_followed_command,NULL,NULL);
}
if (self==window->ShowKernelButton){
window->last_mode=3;
yon_terminal_integrated_start(terminal, get_journal_output_kernel_command,NULL,NULL);
}
if (self==window->ShowPriorityButton){
window->last_mode=4;
yon_terminal_integrated_start(terminal, get_journal_output_prioritied_command,NULL,NULL);
}
if (self==window->ShowAllBootsButton){
window->last_mode=5;
yon_terminal_integrated_start(terminal, get_journal_all_boots_command,NULL,NULL);
}
if (self==window->ShowAllUnitsButton){
window->last_mode=6;
yon_terminal_integrated_start(terminal, get_journal_all_units_command,NULL,NULL);
}
if (self==window->ShowInitTreeButton){
window->last_mode=7;
yon_terminal_integrated_start(terminal, get_journal_init_tree_command,NULL,NULL);
}
main_config.remove_thread++;
gtk_tree_view_set_model(GTK_TREE_VIEW(window->JournaldTree),GTK_TREE_MODEL(window->list));
gtk_list_store_clear(window->list);
gtk_tree_view_set_model(GTK_TREE_VIEW(window->JournaldTree),GTK_TREE_MODEL(window->list));
if (main_config.inspector_thread){
main_config.remove_thread=1;
pthread_join(main_config.inspector_thread,NULL);
}
pthread_create(&main_config.inspector_thread, NULL, (void *)on_inspector_jornald_read_async, window);
} else {
if (window->terminals){
gtk_widget_hide(gtk_widget_get_parent(window->JournaldTree));
gtk_widget_show(window->LoggingNotebook);
dictionary *dict=NULL;
for_dictionaries (dict,window->terminals){
GtkWidget *terminal = (GtkWidget*)dict->data;
@ -381,6 +380,10 @@ GtkWidget *yon_inspector_add_terminal(inspector_window *window,char *page_name,i
}
void on_inspector_close(GtkWidget *self){
main_config.remove_thread++;
}
void on_inspector_open(GtkWidget *self, main_window *widgets){
inspector_window *window = malloc(sizeof(inspector_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_inspector_path);
@ -395,6 +398,8 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){
window->LoggingNotebook=yon_gtk_builder_get_widget(builder,"MainNotebook");
window->UpdateButton=yon_gtk_builder_get_widget(builder,"UpdateButton");
window->JournalActionsBox=yon_gtk_builder_get_widget(builder,"JournalActionsBox");
window->JournaldTree=yon_gtk_builder_get_widget(builder,"JournaldTree");
window->list=GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1"));
yon_window_config_custom_window_setup(GTK_WINDOW(window->MainWindow),"InspectorWindow");
gtk_window_set_title(GTK_WINDOW(window->MainWindow),TITLE_LABEL);
gtk_window_set_transient_for(GTK_WINDOW(window->MainWindow),GTK_WINDOW(widgets->Window));
@ -402,6 +407,7 @@ void on_inspector_open(GtkWidget *self, main_window *widgets){
GtkTreeIter iter;
char *name;
char *paths;
g_signal_connect(G_OBJECT(window->MainWindow),"destroy", G_CALLBACK(on_inspector_close),window);
g_signal_connect(G_OBJECT(window->UpdateButton),"clicked", G_CALLBACK(on_inspector_update),window);
g_signal_connect(G_OBJECT(window->ShowKernelButton),"clicked", G_CALLBACK(on_inspector_update),window);
g_signal_connect(G_OBJECT(window->NewMessagesButton),"clicked", G_CALLBACK(on_inspector_update),window);
@ -2262,6 +2268,7 @@ void config_init(){
main_config.lock_save_local=0;
main_config.logrotate_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
main_config.logrotate_apps_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
main_config.remove_thread=-1;
PolkitSubject *subject = NULL;

@ -49,14 +49,14 @@
#define JOURNALD(key) yon_char_unite("JOURNALD[",key,"]",NULL)
#define LOGROTATE(key) yon_char_unite("LOGROTATE[",key,"]",NULL)
#define get_journal_output_command "clear;journalctl --no-pager"
#define get_journal_output_since_boot_command "clear;journalctl --no-pager -b"
#define get_journal_output_followed_command "clear;journalctl --no-pager -f"
#define get_journal_output_kernel_command "clear;journalctl --no-pager -k"
#define get_journal_output_prioritied_command "clear;journalctl --no-pager -p err..alert"
#define get_journal_all_boots_command "clear;journalctl --list-boots"
#define get_journal_all_units_command "clear;systemd-analyze blame --no-pager"
#define get_journal_init_tree_command "clear;systemd-analyze critical-chain"
#define get_journal_output_command "clear;SYSTEMD_COLORS=false journalctl --no-pager"
#define get_journal_output_since_boot_command "clear;SYSTEMD_COLORS=false journalctl --no-pager -b"
#define get_journal_output_followed_command "clear;SYSTEMD_COLORS=false journalctl --no-pager -f"
#define get_journal_output_kernel_command "clear;SYSTEMD_COLORS=false journalctl --no-pager -k"
#define get_journal_output_prioritied_command "clear;SYSTEMD_COLORS=false journalctl --no-pager -p err..alert"
#define get_journal_all_boots_command "clear;SYSTEMD_COLORS=false journalctl --no-pager --list-boots"
#define get_journal_all_units_command "clear;SYSTEMD_COLORS=false systemd-analyze blame --no-pager"
#define get_journal_init_tree_command "clear;SYSTEMD_COLORS=false systemd-analyze critical-chain --no-pager"
#define group_list_path "/etc/group"
@ -99,6 +99,9 @@ typedef struct {
config_str *saved_logs;
GPermission *permissions;
pthread_t inspector_thread;
int remove_thread;
} config;
typedef struct {
@ -188,22 +191,24 @@ typedef struct {
} add_log_window;
typedef struct {
GtkWidget *MainWindow;
GtkWidget *plugBox;
GtkWidget *ShowSinceBootButton;
GtkWidget *NewMessagesButton;
GtkWidget *ShowKernelButton;
GtkWidget *ShowPriorityButton;
GtkWidget *UpdateButton;
GtkWidget *ShowAllBootsButton;
GtkWidget *ShowAllUnitsButton;
GtkWidget *ShowInitTreeButton;
GtkWidget *LoggingNotebook;
GtkWidget *JournalActionsBox;
dictionary *terminals;
int last_mode;
char *journal_name;
int journal_size;
GtkWidget *MainWindow;
GtkWidget *plugBox;
GtkWidget *ShowSinceBootButton;
GtkWidget *NewMessagesButton;
GtkWidget *ShowKernelButton;
GtkWidget *ShowPriorityButton;
GtkWidget *UpdateButton;
GtkWidget *ShowAllBootsButton;
GtkWidget *ShowAllUnitsButton;
GtkWidget *ShowInitTreeButton;
GtkWidget *LoggingNotebook;
GtkWidget *JournalActionsBox;
GtkListStore *list;
GtkWidget *JournaldTree;
dictionary *terminals;
int last_mode;
char *journal_name;
int journal_size;
config_str journal_paths;
} inspector_window;

@ -53,11 +53,19 @@
<property name="can-focus">False</property>
<property name="icon-name">com.ublinux.ubl-settings-logging.generic7-symbolic</property>
</object>
<object class="GtkListStore" id="liststore1"/>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
<!-- column-name gchararray2 -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkWindow" id="MainWindow">
<property name="width-request">800</property>
<property name="height-request">600</property>
<property name="can-focus">False</property>
<property name="modal">True</property>
<property name="default-width">800</property>
<property name="default-height">600</property>
<property name="icon-name">com.ublinux.ubl-settings-logging</property>
@ -249,33 +257,47 @@
</packing>
</child>
<child>
<object class="GtkTreeView" id="JournaldTree">
<property name="visible">True</property>
<object class="GtkScrolledWindow">
<property name="can-focus">True</property>
<property name="model">liststore1</property>
<property name="headers-visible">False</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</child>
<property name="shadow-type">in</property>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">column</property>
<object class="GtkTreeView" id="JournaldTree">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="model">liststore1</property>
<property name="headers-visible">False</property>
<property name="enable-grid-lines">both</property>
<property name="tooltip-column">0</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
<object class="GtkTreeViewColumn">
<property name="sizing">fixed</property>
<property name="fixed-width">175</property>
<property name="min-width">75</property>
<property name="title" translatable="yes">column</property>
<child>
<object class="GtkCellRendererText">
<property name="ellipsize">end</property>
</object>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">column</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">column</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText">
<property name="wrap-mode">word</property>
<property name="wrap-width">500</property>
</object>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>

Loading…
Cancel
Save