Skip to content

Commit

Permalink
chore: downgrade logging from message to debug
Browse files Browse the repository at this point in the history
These messages are very verbose (possibly many messages per second), yet
not interesting to a regular user, they're only for developers debugging
the app. Yet, they were logged to the system journal at the NOTICE
level, which is higher (numerically smaller) than even INFO, and so were
highligheted as important in the journalctl output.

Downgrade the logging to use debug (), which results in the messages not
being logged to the journal at all by default. It is still possible to
see the debugging messages by setting G_MESSAGES_DEBUG=Tuba (or "all").
  • Loading branch information
bugaevc committed Aug 5, 2023
1 parent d953fb6 commit 5244ec5
Show file tree
Hide file tree
Showing 34 changed files with 78 additions and 78 deletions.
4 changes: 2 additions & 2 deletions src/API/Attachment.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Tuba.API.Attachment : Entity, Widgetizable {
// }

public static async Attachment upload (string uri) throws Error {
message (@"Uploading new media: $(uri)");
debug (@"Uploading new media: $(uri)");

uint8[] contents;
string mime;
Expand Down Expand Up @@ -67,7 +67,7 @@ public class Tuba.API.Attachment : Entity, Widgetizable {
var parser = Network.get_parser_from_inputstream (in_stream);
var node = network.parse_node (parser);
var entity = accounts.active.create_entity<API.Attachment> (node);
message (@"OK! ID $(entity.id)");
debug (@"OK! ID $(entity.id)");
return entity;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/API/Poll.vala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class Tuba.API.Poll : GLib.Object, Json.Serializable {
ArrayList<string> selection,
string id
) {
message (@"Voting poll $(id)");
debug (@"Voting poll $(id)");
//Creating json to send
var builder = new Json.Builder ();
builder.begin_object ();
Expand Down
2 changes: 1 addition & 1 deletion src/API/Relationship.vala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Tuba.API.Relationship : Entity {
var parser = Network.get_parser_from_inputstream (in_stream);
var node = network.parse_node (parser);
invalidate (node);
message (@"Performed \"$operation\" on Relationship $id");
debug (@"Performed \"$operation\" on Relationship $id");
});

if (param != null)
Expand Down
2 changes: 1 addition & 1 deletion src/API/Status.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Gee;
public class Tuba.API.Status : Entity, Widgetizable {

~Status () {
message (@"[OBJ] Destroyed $(uri ?? "")");
debug (@"[OBJ] Destroyed $(uri ?? "")");
}

public string id { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace Tuba {
try {
var lines = troubleshooting.split ("\n");
foreach (unowned string line in lines) {
message (line);
debug (line);
}
Adw.init ();

Expand Down Expand Up @@ -192,13 +192,13 @@ namespace Tuba {
if (accounts.saved.is_empty) {
if (main_window != null && destroy_main)
main_window.hide ();
message ("Presenting NewAccount dialog");
debug ("Presenting NewAccount dialog");
if (add_account_window == null)
new Dialogs.NewAccount ();
add_account_window.present ();
}
else {
message ("Presenting MainWindow");
debug ("Presenting MainWindow");
if (main_window == null) {
main_window = new Dialogs.MainWindow (this);
is_rtl = Gtk.Widget.get_default_direction () == Gtk.TextDirection.RTL;
Expand Down
2 changes: 1 addition & 1 deletion src/Dialogs/Composer/AttachmentsPageAttachment.vala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Tuba.AttachmentsPageAttachment : Widgets.Attachment.Item {

~AttachmentsPageAttachment () {
close_dialog ();
message ("Destroying AttachmentsPageAttachment");
debug ("Destroying AttachmentsPageAttachment");
}

public AttachmentsPageAttachment (
Expand Down
6 changes: 3 additions & 3 deletions src/Dialogs/Composer/Completion/CompletionProvider.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public abstract class Tuba.CompletionProvider: Object, GtkSource.CompletionProvi
protected bool set_input_capture (bool state) {
this.is_capturing_input = state;
if (state) {
message ("Capturing input");
debug ("Capturing input");
}
else {
message ("Stopped capturing input");
debug ("Stopped capturing input");
this.empty_triggers = 0;
}
return state;
Expand Down Expand Up @@ -68,7 +68,7 @@ public abstract class Tuba.CompletionProvider: Object, GtkSource.CompletionProvi

var word = context.get_word ();
if (word == "") {
message ("Empty trigger");
debug ("Empty trigger");
this.empty_triggers++;

if (this.empty_triggers > 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/Dialogs/Composer/Dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public class Tuba.Dialogs.Compose : Adw.Window {
});
}
~Compose () {
message ("Destroying composer");
debug ("Destroying composer");
foreach (var page in t_pages) {
page.dispose ();
}
Expand Down Expand Up @@ -440,7 +440,7 @@ public class Tuba.Dialogs.Compose : Adw.Window {
var parser = Network.get_parser_from_inputstream (publish_req.response_body);
var node = network.parse_node (parser);
var status = API.Status.from (node);
message (@"Published post with id $(status.id)");
debug (@"Published post with id $(status.id)");
if (cb != null) cb (status);

on_close ();
Expand Down
2 changes: 1 addition & 1 deletion src/Dialogs/Composer/Page.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Tuba.ComposerPage : Gtk.Box {
}

~ComposerPage () {
message (@"Destroying $title Page");
debug (@"Destroying $title Page");
}

construct {
Expand Down
20 changes: 10 additions & 10 deletions src/Dialogs/NewAccount.vala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class Tuba.Dialogs.NewAccount: Adw.Window {

// GLib.Process.spawn_command_line_sync (@"xdg-mime default $(Build.DOMAIN).desktop x-scheme-handler/tuba");

// message ("Successfully associated MIME type for automatic authorization");
// debug ("Successfully associated MIME type for automatic authorization");
return "tuba://auth_code";
}
catch (Error e) {
Expand All @@ -80,7 +80,7 @@ public class Tuba.Dialogs.NewAccount: Adw.Window {
}

void reset () {
message ("Reset state");
debug ("Reset state");
clear_errors ();
use_auto_auth = true;
account = new InstanceAccount.empty (account.instance);
Expand Down Expand Up @@ -108,7 +108,7 @@ public class Tuba.Dialogs.NewAccount: Adw.Window {
}

void setup_instance () throws Error {
message ("Checking instance URL");
debug ("Checking instance URL");

var str = instance_entry.text
.replace ("/", "")
Expand All @@ -123,7 +123,7 @@ public class Tuba.Dialogs.NewAccount: Adw.Window {
}

async void register_client () throws Error {
message ("Registering client");
debug ("Registering client");

var msg = new Request.POST ("/api/v1/apps")
.with_account (account)
Expand All @@ -141,14 +141,14 @@ public class Tuba.Dialogs.NewAccount: Adw.Window {

account.client_id = root.get_string_member ("client_id");
account.client_secret = root.get_string_member ("client_secret");
message ("OK: Instance registered client");
debug ("OK: Instance registered client");

deck.visible_child = code_step;
open_confirmation_page ();
}

void open_confirmation_page () {
message ("Opening permission request page");
debug ("Opening permission request page");

var esc_scopes = Uri.escape_string (SCOPES);
var esc_redirect = Uri.escape_string (redirect_uri);
Expand All @@ -161,7 +161,7 @@ public class Tuba.Dialogs.NewAccount: Adw.Window {
if (code_entry.text.char_count () <= 10)
throw new Oopsie.USER (_("Please enter a valid authorization code"));

message ("Requesting access token");
debug ("Requesting access token");
var token_req = new Request.POST ("/oauth/token")
.with_account (account)
.with_form_data ("client_id", account.client_id)
Expand All @@ -182,19 +182,19 @@ public class Tuba.Dialogs.NewAccount: Adw.Window {

account = accounts.create_account (account.to_json ());

message ("Saving account");
debug ("Saving account");
accounts.add (account);

done_page.title = _("Hello, %s!").printf (account.display_name);
deck.visible_child = done_step;

message ("Switching to account");
debug ("Switching to account");
accounts.activate (account);
}

public void redirect (string t_uri) {
present ();
message (@"Received uri: $t_uri");
debug (@"Received uri: $t_uri");

string code_from_params = "";
try {
Expand Down
4 changes: 2 additions & 2 deletions src/Dialogs/ProfileEdit.vala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
public class Tuba.Dialogs.ProfileEdit : Adw.Window {
~ProfileEdit () {
message (@"Destroying ProfileEdit for $(profile.handle)");
debug (@"Destroying ProfileEdit for $(profile.handle)");
}

public class Avatar : Adw.Bin {
Expand Down Expand Up @@ -46,7 +46,7 @@ public class Tuba.Dialogs.ProfileEdit : Adw.Window {

public class Field : Adw.ExpanderRow {
~Field () {
message ("Destroying ProfileEdit.Field");
debug ("Destroying ProfileEdit.Field");
}

Adw.EntryRow key_row;
Expand Down
10 changes: 5 additions & 5 deletions src/Services/Accounts/AccountStore.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public abstract class Tuba.AccountStore : GLib.Object {
}

public virtual void add (InstanceAccount account) throws GLib.Error {
message (@"Adding new account: $(account.handle)");
debug (@"Adding new account: $(account.handle)");
saved.add (account);
changed (saved);
save ();
ensure_active_account ();
}

public virtual void remove (InstanceAccount account) throws GLib.Error {
message (@"Removing account: $(account.handle)");
debug (@"Removing account: $(account.handle)");
account.removed ();
saved.remove (account);
changed (saved);
Expand All @@ -79,10 +79,10 @@ public abstract class Tuba.AccountStore : GLib.Object {
active.deactivated ();

if (account == null) {
message ("Reset active account");
debug ("Reset active account");
return;
} else {
message (@"Activating $(account.handle)…");
debug (@"Activating $(account.handle)…");
account.verify_credentials.begin ((obj, res) => {
try {
account.verify_credentials.end (res);
Expand Down Expand Up @@ -152,7 +152,7 @@ public abstract class Tuba.AccountStore : GLib.Object {
throw new Oopsie.INTERNAL ("This instance is unsupported.");
else {
account.backend = backend;
message (@"$(account.instance) is using $(account.backend)");
debug (@"$(account.instance) is using $(account.backend)");
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/Services/Accounts/InstanceAccount.vala
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
var updated = API.Account.from (node);
patch (updated);

message (@"$handle: profile updated");
debug (@"$handle: profile updated");
}

public async Entity resolve (string url) throws Error {
message (@"Resolving URL: \"$url\"");
debug (@"Resolving URL: \"$url\"");
var results = yield API.SearchResults.request (url, this);
var entity = results.first ();
message (@"Found $(entity.get_class ().get_name ())");
debug (@"Found $(entity.get_class ().get_name ())");
return entity;
}

Expand Down Expand Up @@ -268,7 +268,7 @@ public class Tuba.InstanceAccount : API.Account, Streamable {
}

public void read_notifications (int up_to_id) {
message (@"Reading notifications up to id $up_to_id");
debug (@"Reading notifications up to id $up_to_id");

if (up_to_id > last_read_id) {
last_read_id = up_to_id;
Expand Down Expand Up @@ -309,7 +309,7 @@ public class Tuba.InstanceAccount : API.Account, Streamable {

// public void read_notification (int id) {
// if (id <= last_read_id) {
// message (@"Read notification with id: $id");
// debug (@"Read notification with id: $id");
// app.withdraw_notification (id.to_string ());
// unread_toasts.unset (id);
// }
Expand Down
8 changes: 4 additions & 4 deletions src/Services/Accounts/SecretAccountStore.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Tuba.SecretAccountStore : AccountStore {
GLib.HashTable<string,SchemaAttributeType> schema_attributes;

public override void init () throws GLib.Error {
message (@"Using libsecret v$(Secret.MAJOR_VERSION).$(Secret.MINOR_VERSION).$(Secret.MICRO_VERSION)");
debug (@"Using libsecret v$(Secret.MAJOR_VERSION).$(Secret.MINOR_VERSION).$(Secret.MICRO_VERSION)");

schema_attributes = new GLib.HashTable<string,SchemaAttributeType> (str_hash, str_equal);
schema_attributes["login"] = SchemaAttributeType.STRING;
Expand Down Expand Up @@ -93,15 +93,15 @@ public class Tuba.SecretAccountStore : AccountStore {
});
changed (saved);

message (@"Loaded $(saved.size) accounts");
debug (@"Loaded $(saved.size) accounts");
}

public override void save () throws GLib.Error {
saved.foreach (account => {
account_to_secret (account);
return true;
});
message (@"Saved $(saved.size) accounts");
debug (@"Saved $(saved.size) accounts");
}

public override void remove (InstanceAccount account) throws GLib.Error {
Expand Down Expand Up @@ -215,7 +215,7 @@ public class Tuba.SecretAccountStore : AccountStore {
(obj, async_res) => {
try {
Secret.password_store.end (async_res);
message (@"Saved secret for $(account.handle)");
debug (@"Saved secret for $(account.handle)");
}
catch (GLib.Error e) {
warning (e.message);
Expand Down
12 changes: 6 additions & 6 deletions src/Services/Cache/AbstractCache.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Tuba.AbstractCache : Object {
}

bool maintenance_func () {
// message ("maintenance start");
// debug ("maintenance start");
if (size > 0) {
uint cleared = 0;
var iter = items.map_iterator ();
Expand All @@ -52,17 +52,17 @@ public class Tuba.AbstractCache : Object {
// }
if (obj.ref_count < min_ref_count) {
cleared++;
message (@"Freeing: $(iter.get_key ())");
debug (@"Freeing: $(iter.get_key ())");
iter.unset ();
obj.dispose ();
}
}

if (cleared > 0)
message (@"Freed $cleared items from cache. Size: $size");
debug (@"Freed $cleared items from cache. Size: $size");
}

// message ("maintenance end");
// debug ("maintenance end");
return Source.CONTINUE;
}

Expand All @@ -88,7 +88,7 @@ public class Tuba.AbstractCache : Object {

protected string insert (string id, owned Object obj) {
var key = get_key (id);
message (@"Inserting: $key");
debug (@"Inserting: $key");
items.@set (key, (owned) obj);

var nobj = items.@get (key);
Expand All @@ -98,7 +98,7 @@ public class Tuba.AbstractCache : Object {
}

public void nuke () {
message ("Clearing cache");
debug ("Clearing cache");
items.clear ();
items_in_progress.clear ();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/Cache/EntityCache.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Tuba.EntityCache : AbstractCache {
// Entity can be reused from cache
if (contains (id)) {
entity = lookup (get_key (id)) as Entity;
message (@"Reused: $id");
debug (@"Reused: $id");
}
// It's a new instance and we need to store it
else {
Expand Down
Loading

0 comments on commit 5244ec5

Please sign in to comment.