Geary.Logging: Remove Flag enum
Now that we have classes logging on sub-domains, and the ability to suppress specific domains, remove flags and switch over to doing domain suppression for manipulating debug settings in the client.
This commit is contained in:
parent
718f02bd8a
commit
3b0815a1dc
23 changed files with 62 additions and 356 deletions
|
|
@ -65,10 +65,9 @@ public class Application.Client : Gtk.Application {
|
|||
private const string OPTION_LOG_CONVERSATIONS = "log-conversations";
|
||||
private const string OPTION_LOG_DESERIALIZER = "log-deserializer";
|
||||
private const string OPTION_LOG_FOLDER_NORM = "log-folder-normalization";
|
||||
private const string OPTION_LOG_NETWORK = "log-network";
|
||||
private const string OPTION_LOG_PERIODIC = "log-periodic";
|
||||
private const string OPTION_LOG_IMAP = "log-imap";
|
||||
private const string OPTION_LOG_REPLAY_QUEUE = "log-replay-queue";
|
||||
private const string OPTION_LOG_SERIALIZER = "log-serializer";
|
||||
private const string OPTION_LOG_SMTP = "log-smtp";
|
||||
private const string OPTION_LOG_SQL = "log-sql";
|
||||
private const string OPTION_HIDDEN = "hidden";
|
||||
private const string OPTION_NEW_WINDOW = "new-window";
|
||||
|
|
@ -111,22 +110,17 @@ public class Application.Client : Gtk.Application {
|
|||
/// Command line option. "Normalization" can also be called
|
||||
/// "synchronization".
|
||||
N_("Log folder normalization"), null },
|
||||
{ OPTION_LOG_NETWORK, 0, 0, GLib.OptionArg.NONE, null,
|
||||
{ OPTION_LOG_IMAP, 0, 0, GLib.OptionArg.NONE, null,
|
||||
/// Command line option
|
||||
N_("Log network activity"), null },
|
||||
{ OPTION_LOG_PERIODIC, 0, 0, GLib.OptionArg.NONE, null,
|
||||
/// Command line option
|
||||
N_("Log periodic activity"), null },
|
||||
N_("Log IMAP messages"), null },
|
||||
{ OPTION_LOG_REPLAY_QUEUE, 0, 0, GLib.OptionArg.NONE, null,
|
||||
/// Command line option. The IMAP replay queue is how changes
|
||||
/// on the server are replicated on the client. It could
|
||||
/// also be called the IMAP events queue.
|
||||
N_("Log IMAP replay queue"), null },
|
||||
{ OPTION_LOG_SERIALIZER, 0, 0, GLib.OptionArg.NONE, null,
|
||||
/// Command line option. Serialization is how commands and
|
||||
/// responses are converted into a stream of bytes for
|
||||
/// network transmission
|
||||
N_("Log IMAP network serialization"), null },
|
||||
{ OPTION_LOG_SMTP, 0, 0, GLib.OptionArg.NONE, null,
|
||||
/// Command line option
|
||||
N_("Log SMTP messages"), null },
|
||||
{ OPTION_LOG_SQL, 0, 0, GLib.OptionArg.NONE, null,
|
||||
/// Command line option
|
||||
N_("Log database queries (generates lots of messages)"), null },
|
||||
|
|
@ -917,23 +911,41 @@ public class Application.Client : Gtk.Application {
|
|||
|
||||
bool activated = false;
|
||||
|
||||
// Logging flags
|
||||
if (options.contains(OPTION_LOG_NETWORK))
|
||||
Geary.Logging.enable_flags(Geary.Logging.Flag.NETWORK);
|
||||
if (options.contains(OPTION_LOG_SERIALIZER))
|
||||
Geary.Logging.enable_flags(Geary.Logging.Flag.SERIALIZER);
|
||||
if (options.contains(OPTION_LOG_REPLAY_QUEUE))
|
||||
Geary.Logging.enable_flags(Geary.Logging.Flag.REPLAY);
|
||||
if (options.contains(OPTION_LOG_CONVERSATIONS))
|
||||
Geary.Logging.enable_flags(Geary.Logging.Flag.CONVERSATIONS);
|
||||
if (options.contains(OPTION_LOG_PERIODIC))
|
||||
Geary.Logging.enable_flags(Geary.Logging.Flag.PERIODIC);
|
||||
if (options.contains(OPTION_LOG_SQL))
|
||||
Geary.Logging.enable_flags(Geary.Logging.Flag.SQL);
|
||||
if (options.contains(OPTION_LOG_FOLDER_NORM))
|
||||
Geary.Logging.enable_flags(Geary.Logging.Flag.FOLDER_NORMALIZATION);
|
||||
if (options.contains(OPTION_LOG_DESERIALIZER))
|
||||
Geary.Logging.enable_flags(Geary.Logging.Flag.DESERIALIZER);
|
||||
// Suppress some noisy domains from third-party libraries
|
||||
Geary.Logging.suppress_domain("GdkPixbuf");
|
||||
Geary.Logging.suppress_domain("GLib-Net");
|
||||
|
||||
// Suppress the engine's sub-domains that are extremely
|
||||
// verbose by default unless requested not to do so
|
||||
if (!options.contains(OPTION_LOG_CONVERSATIONS)) {
|
||||
Geary.Logging.suppress_domain(
|
||||
Geary.App.ConversationMonitor.LOGGING_DOMAIN
|
||||
);
|
||||
}
|
||||
if (!options.contains(OPTION_LOG_DESERIALIZER)) {
|
||||
Geary.Logging.suppress_domain(
|
||||
Geary.Imap.ClientService.DESERIALISATION_LOGGING_DOMAIN
|
||||
);
|
||||
}
|
||||
if (!options.contains(OPTION_LOG_IMAP)) {
|
||||
Geary.Logging.suppress_domain(
|
||||
Geary.Imap.ClientService.PROTOCOL_LOGGING_DOMAIN
|
||||
);
|
||||
}
|
||||
if (!options.contains(OPTION_LOG_REPLAY_QUEUE)) {
|
||||
Geary.Logging.suppress_domain(
|
||||
Geary.Imap.ClientService.REPLAY_QUEUE_LOGGING_DOMAIN
|
||||
);
|
||||
}
|
||||
if (!options.contains(OPTION_LOG_SMTP)) {
|
||||
Geary.Logging.suppress_domain(
|
||||
Geary.Smtp.ClientService.PROTOCOL_LOGGING_DOMAIN
|
||||
);
|
||||
}
|
||||
if (!options.contains(OPTION_LOG_SQL)) {
|
||||
Geary.Logging.suppress_domain(Geary.Db.Context.LOGGING_DOMAIN);
|
||||
}
|
||||
|
||||
if (options.contains(OPTION_HIDDEN)) {
|
||||
warning(
|
||||
/// Warning printed to the console when a deprecated
|
||||
|
|
|
|||
|
|
@ -661,7 +661,6 @@ void main(string[] args) {
|
|||
Gtk.init(ref args);
|
||||
|
||||
Geary.Logging.init();
|
||||
Geary.Logging.enable_flags(Geary.Logging.Flag.NETWORK);
|
||||
Geary.Logging.log_to(stdout);
|
||||
|
||||
ImapConsole console = new ImapConsole();
|
||||
|
|
|
|||
|
|
@ -255,11 +255,6 @@ public abstract class Geary.Account : BaseObject, Logging.Source {
|
|||
public signal void email_flags_changed(Geary.Folder folder,
|
||||
Gee.Map<Geary.EmailIdentifier, Geary.EmailFlags> map);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.ALL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Source? logging_parent { get { return null; } }
|
||||
|
||||
|
|
|
|||
|
|
@ -197,11 +197,6 @@ public abstract class Geary.ClientService : BaseObject, Logging.Source {
|
|||
/** The last reported error, if any. */
|
||||
public ErrorContext? last_error { get; private set; default = null; }
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.ALL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
// XXX see GNOME/vala#119 for why this is necessary
|
||||
public virtual string logging_domain {
|
||||
|
|
|
|||
|
|
@ -292,11 +292,6 @@ public abstract class Geary.Folder : BaseObject, Logging.Source {
|
|||
/** Monitor for notifying of progress when opening the folder. */
|
||||
public abstract Geary.ProgressMonitor opening_monitor { get; }
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.ALL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Source? logging_parent {
|
||||
get { return this.account; }
|
||||
|
|
|
|||
|
|
@ -20,92 +20,6 @@ public const string DOMAIN = "Geary";
|
|||
/** Specifies the default number of log records retained. */
|
||||
public const uint DEFAULT_MAX_LOG_BUFFER_LENGTH = 4096;
|
||||
|
||||
/**
|
||||
* Denotes a type of log message.
|
||||
*
|
||||
* Logging for each type of log message may be dynamically enabled or
|
||||
* disabled at run time by {@link enable_flags} and {@link
|
||||
* disable_flags}.
|
||||
*/
|
||||
[Flags]
|
||||
public enum Flag {
|
||||
NONE = 0,
|
||||
NETWORK,
|
||||
SERIALIZER,
|
||||
REPLAY,
|
||||
CONVERSATIONS,
|
||||
PERIODIC,
|
||||
SQL,
|
||||
FOLDER_NORMALIZATION,
|
||||
DESERIALIZER,
|
||||
ALL = int.MAX;
|
||||
|
||||
public inline bool is_all_set(Flag flags) {
|
||||
return (flags & this) == flags;
|
||||
}
|
||||
|
||||
public inline bool is_any_set(Flag flags) {
|
||||
return (flags & this) != 0;
|
||||
}
|
||||
|
||||
public string to_string() {
|
||||
GLib.StringBuilder buf = new GLib.StringBuilder();
|
||||
if (this == ALL) {
|
||||
buf.append("ALL");
|
||||
} else if (this == NONE) {
|
||||
buf.append("NONE");
|
||||
} else {
|
||||
if (this.is_any_set(NETWORK)) {
|
||||
buf.append("NET");
|
||||
}
|
||||
if (this.is_any_set(SERIALIZER)) {
|
||||
if (buf.len > 0) {
|
||||
buf.append_c('|');
|
||||
}
|
||||
buf.append("SER");
|
||||
}
|
||||
if (this.is_any_set(REPLAY)) {
|
||||
if (buf.len > 0) {
|
||||
buf.append_c('|');
|
||||
}
|
||||
buf.append("REP");
|
||||
}
|
||||
if (this.is_any_set(CONVERSATIONS)) {
|
||||
if (buf.len > 0) {
|
||||
buf.append_c('|');
|
||||
}
|
||||
buf.append("CNV");
|
||||
}
|
||||
if (this.is_any_set(PERIODIC)) {
|
||||
if (buf.len > 0) {
|
||||
buf.append_c('|');
|
||||
}
|
||||
buf.append("PER");
|
||||
}
|
||||
if (this.is_any_set(SQL)) {
|
||||
if (buf.len > 0) {
|
||||
buf.append_c('|');
|
||||
}
|
||||
buf.append("SQL");
|
||||
}
|
||||
if (this.is_any_set(FOLDER_NORMALIZATION)) {
|
||||
if (buf.len > 0) {
|
||||
buf.append_c('|');
|
||||
}
|
||||
buf.append("NRM");
|
||||
}
|
||||
if (this.is_any_set(DESERIALIZER)) {
|
||||
if (buf.len > 0) {
|
||||
buf.append_c('|');
|
||||
}
|
||||
buf.append("DES");
|
||||
}
|
||||
}
|
||||
return buf.str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A record of a single message sent to the logging system.
|
||||
*
|
||||
|
|
@ -129,9 +43,6 @@ public class Record {
|
|||
/** Folder from which the record originated, if any. */
|
||||
public Folder? folder { get; private set; default = null; }
|
||||
|
||||
/** The logged flags, if any. */
|
||||
public Flag? flags = null;
|
||||
|
||||
/** The logged message, if any. */
|
||||
public string? message = null;
|
||||
|
||||
|
|
@ -179,10 +90,6 @@ public class Record {
|
|||
((Source) field.value).to_logging_state();
|
||||
break;
|
||||
|
||||
case "GEARY_FLAGS":
|
||||
this.flags = (Flag) field.value;
|
||||
break;
|
||||
|
||||
case "GLIB_DOMAIN":
|
||||
this.domain = field_to_string(field);
|
||||
break;
|
||||
|
|
@ -219,7 +126,6 @@ public class Record {
|
|||
this.account = other.account;
|
||||
this.service = other.service;
|
||||
this.folder = other.folder;
|
||||
this.flags = other.flags;
|
||||
this.message = other.message;
|
||||
this.source_filename = other.source_filename;
|
||||
this.source_line_number = other.source_line_number;
|
||||
|
|
@ -266,7 +172,6 @@ public class Record {
|
|||
fill_well_known_sources();
|
||||
|
||||
string domain = this.domain ?? "[no domain]";
|
||||
Flag flags = this.flags ?? Flag.NONE;
|
||||
string message = this.message ?? "[no message]";
|
||||
double float_secs = this.timestamp / 1000.0 / 1000.0;
|
||||
double floor_secs = GLib.Math.floor(float_secs);
|
||||
|
|
@ -276,7 +181,7 @@ public class Record {
|
|||
).to_local();
|
||||
GLib.StringBuilder str = new GLib.StringBuilder.sized(128);
|
||||
str.printf(
|
||||
"%s %02d:%02d:%02d.%04d %s",
|
||||
"%s %02d:%02d:%02d.%04d %s:",
|
||||
to_prefix(levels),
|
||||
time.get_hour(),
|
||||
time.get_minute(),
|
||||
|
|
@ -285,12 +190,6 @@ public class Record {
|
|||
domain
|
||||
);
|
||||
|
||||
if (flags != NONE) {
|
||||
str.append_printf("[%s]:", flags.to_string());
|
||||
} else {
|
||||
str.append(":");
|
||||
}
|
||||
|
||||
// Append in reverse so inner sources appear first
|
||||
for (int i = this.states.length - 1; i >= 0; i--) {
|
||||
str.append(" [");
|
||||
|
|
@ -333,7 +232,6 @@ public class Record {
|
|||
public delegate void LogRecord(Record record);
|
||||
|
||||
private int init_count = 0;
|
||||
private Flag logging_flags = Flag.NONE;
|
||||
|
||||
// The two locks below can't be nullable. See
|
||||
// https://gitlab.gnome.org/GNOME/vala/issues/812
|
||||
|
|
@ -398,95 +296,11 @@ public void clear() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the current logging flags with flags. Use Geary.Logging.Flag.NONE to clear all
|
||||
* logging flags.
|
||||
*/
|
||||
public void set_flags(Flag flags) {
|
||||
logging_flags = flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the supplied flags to the current logging flags without disturbing the others.
|
||||
*/
|
||||
public void enable_flags(Flag flags) {
|
||||
logging_flags |= flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the supplied flags from the current logging flags without disturbing the others.
|
||||
*/
|
||||
public void disable_flags(Flag flags) {
|
||||
logging_flags &= ~flags;
|
||||
}
|
||||
|
||||
/** Sets a function to be called when a new log record is created. */
|
||||
public void set_log_listener(LogRecord? new_listener) {
|
||||
listener = new_listener;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current logging flags.
|
||||
*/
|
||||
public Flag get_flags() {
|
||||
return logging_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if all the flag(s) are set.
|
||||
*/
|
||||
public inline bool are_all_flags_set(Flag flags) {
|
||||
return logging_flags.is_all_set(flags);
|
||||
}
|
||||
|
||||
[PrintfFormat]
|
||||
public inline void error(Flag flags, string fmt, ...) {
|
||||
logv(flags, GLib.LogLevelFlags.LEVEL_ERROR, fmt, va_list());
|
||||
}
|
||||
|
||||
[PrintfFormat]
|
||||
public inline void critical(Flag flags, string fmt, ...) {
|
||||
logv(flags, GLib.LogLevelFlags.LEVEL_CRITICAL, fmt, va_list());
|
||||
}
|
||||
|
||||
[PrintfFormat]
|
||||
public inline void warning(Flag flags, string fmt, ...) {
|
||||
logv(flags, GLib.LogLevelFlags.LEVEL_WARNING, fmt, va_list());
|
||||
}
|
||||
|
||||
[PrintfFormat]
|
||||
public inline void message(Flag flags, string fmt, ...) {
|
||||
logv(flags, GLib.LogLevelFlags.LEVEL_MESSAGE, fmt, va_list());
|
||||
}
|
||||
|
||||
[PrintfFormat]
|
||||
public inline void debug(Flag flags, string fmt, ...) {
|
||||
logv(flags, GLib.LogLevelFlags.LEVEL_DEBUG, fmt, va_list());
|
||||
}
|
||||
|
||||
public inline void logv(Flag flags,
|
||||
GLib.LogLevelFlags level,
|
||||
string fmt,
|
||||
va_list args) {
|
||||
if (flags == ALL || logging_flags.is_any_set(flags)) {
|
||||
GLib.log_structured_array(
|
||||
level,
|
||||
new GLib.LogField[] {
|
||||
GLib.LogField<string>() {
|
||||
key = "GLIB_DOMAIN", value = DOMAIN, length = -1
|
||||
},
|
||||
GLib.LogField<Flag>() {
|
||||
key = "GEARY_FLAGS", value = flags, length = 0
|
||||
},
|
||||
GLib.LogField<string>() {
|
||||
key = "MESSAGE", value = fmt.vprintf(args), length = -1
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the oldest log record in the logging system's buffer. */
|
||||
public Record? get_earliest_record() {
|
||||
return first_record;
|
||||
|
|
|
|||
|
|
@ -123,11 +123,6 @@ public class Geary.App.ConversationMonitor : BaseObject, Logging.Source {
|
|||
get; private set; default = new SimpleProgressMonitor(ProgressType.ACTIVITY);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.CONVERSATIONS;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override string logging_domain {
|
||||
get { return LOGGING_DOMAIN; }
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@ private class Geary.App.ConversationSet : BaseObject, Logging.Source {
|
|||
owned get { return _conversations.read_only_view; }
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.CONVERSATIONS;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override string logging_domain {
|
||||
get { return ConversationMonitor.LOGGING_DOMAIN; }
|
||||
|
|
|
|||
|
|
@ -18,11 +18,6 @@ public abstract class Geary.Db.Context : BaseObject, Logging.Source {
|
|||
/** The GLib logging domain used by this class. */
|
||||
public const string LOGGING_DOMAIN = Logging.DOMAIN + ".Db";
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.SQL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override string logging_domain {
|
||||
get { return LOGGING_DOMAIN; }
|
||||
|
|
@ -68,9 +63,6 @@ public abstract class Geary.Db.Context : BaseObject, Logging.Source {
|
|||
|
||||
[PrintfFormat]
|
||||
protected void log(string fmt, ...) {
|
||||
if (!Logging.are_all_flags_set(Logging.Flag.SQL))
|
||||
return;
|
||||
|
||||
Statement? stmt = get_statement();
|
||||
if (stmt != null) {
|
||||
debug("%s\n\t<%s>",
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@
|
|||
public abstract class Geary.ImapEngine.AccountOperation : BaseObject, Logging.Source {
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.ALL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Source? logging_parent { get { return account; } }
|
||||
|
||||
|
|
|
|||
|
|
@ -39,11 +39,6 @@ internal class Geary.ImapEngine.AccountProcessor :
|
|||
/** Fired when an error occurs processing an operation. */
|
||||
public signal void operation_error(AccountOperation op, Error error);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.ALL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Source? logging_parent { get { return _logging_parent; } }
|
||||
private weak Logging.Source? _logging_parent = null;
|
||||
|
|
|
|||
|
|
@ -29,11 +29,6 @@ private class Geary.ImapEngine.AccountSynchronizer :
|
|||
this.account.folders_contents_altered.connect(on_folders_contents_altered);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.ALL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Source? logging_parent {
|
||||
get { return this.account; }
|
||||
|
|
|
|||
|
|
@ -97,11 +97,6 @@ private class Geary.ImapEngine.ReplayQueue : BaseObject, Logging.Source {
|
|||
return remote_queue.size;
|
||||
} }
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.CONVERSATIONS;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override string logging_domain {
|
||||
get { return Imap.ClientService.REPLAY_QUEUE_LOGGING_DOMAIN; }
|
||||
|
|
|
|||
|
|
@ -23,11 +23,6 @@ public abstract class Geary.Imap.SessionObject : BaseObject, Logging.Source {
|
|||
/** Determines if this object has a valid session or not. */
|
||||
public bool is_valid { get { return this.session != null; } }
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.ALL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Source? logging_parent { get { return _logging_parent; } }
|
||||
private weak Logging.Source? _logging_parent = null;
|
||||
|
|
|
|||
|
|
@ -54,11 +54,6 @@ public class Geary.Imap.ClientConnection : BaseObject, Logging.Source {
|
|||
public bool idle_when_quiet { get; private set; default = false; }
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.NETWORK;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override string logging_domain {
|
||||
get { return ClientService.PROTOCOL_LOGGING_DOMAIN; }
|
||||
|
|
|
|||
|
|
@ -258,11 +258,6 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
|
|||
*/
|
||||
public bool selected_readonly = false;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.ALL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override string logging_domain {
|
||||
get { return ClientService.LOGGING_DOMAIN; }
|
||||
|
|
@ -1234,7 +1229,7 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
|
|||
keepalive_id = 0;
|
||||
|
||||
send_command_async.begin(new NoopCommand(), null, on_keepalive_completed);
|
||||
log(PERIODIC, LEVEL_DEBUG, "Sending keepalive...");
|
||||
debug("Sending keepalive...");
|
||||
|
||||
// No need to reschedule keepalive, as the notification that the command was sent should
|
||||
// do that automatically
|
||||
|
|
@ -1246,7 +1241,7 @@ public class Geary.Imap.ClientSession : BaseObject, Logging.Source {
|
|||
try {
|
||||
send_command_async.end(result);
|
||||
} catch (GLib.Error err) {
|
||||
log(PERIODIC, LEVEL_WARNING, "Keepalive error: %s", err.message);
|
||||
warning("Keepalive error: %s", err.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,11 +75,6 @@ public class Geary.Imap.Deserializer : BaseObject, Logging.Source {
|
|||
"Geary.Imap.Deserializer", State.TAG, State.COUNT, Event.COUNT,
|
||||
state_to_string, event_to_string);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.DESERIALIZER;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public override string logging_domain {
|
||||
get { return ClientService.DESERIALISATION_LOGGING_DOMAIN; }
|
||||
|
|
|
|||
|
|
@ -20,11 +20,6 @@ internal class Geary.Smtp.ClientConnection : BaseObject, Logging.Source {
|
|||
get { return ClientService.PROTOCOL_LOGGING_DOMAIN; }
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.ALL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Source? logging_parent { get { return _logging_parent; } }
|
||||
private weak Logging.Source? _logging_parent = null;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,6 @@ public class Geary.Smtp.ClientSession : BaseObject, Logging.Source {
|
|||
get { return ClientService.LOGGING_DOMAIN; }
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Flag logging_flags {
|
||||
get; protected set; default = Logging.Flag.ALL;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public Logging.Source? logging_parent { get { return _logging_parent; } }
|
||||
private weak Logging.Source? _logging_parent = null;
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ public interface Geary.Logging.Source : GLib.Object {
|
|||
|
||||
|
||||
Context(string domain,
|
||||
Logging.Flag flags,
|
||||
GLib.LogLevelFlags level,
|
||||
string message,
|
||||
va_list args) {
|
||||
|
|
@ -116,7 +115,6 @@ public interface Geary.Logging.Source : GLib.Object {
|
|||
this.count = 0;
|
||||
append("PRIORITY", log_level_to_priority(level));
|
||||
append("GLIB_DOMAIN", domain);
|
||||
append("GEARY_FLAGS", flags);
|
||||
|
||||
this.message = message.vprintf(va_list.copy(args));
|
||||
}
|
||||
|
|
@ -156,11 +154,6 @@ public interface Geary.Logging.Source : GLib.Object {
|
|||
get { return DOMAIN; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Default flags to use for this source when logging messages.
|
||||
*/
|
||||
public abstract Logging.Flag logging_flags { get; protected set; }
|
||||
|
||||
/**
|
||||
* The parent of this source.
|
||||
*
|
||||
|
|
@ -197,9 +190,7 @@ public interface Geary.Logging.Source : GLib.Object {
|
|||
[PrintfFormat]
|
||||
public inline void debug(string fmt, ...) {
|
||||
if (!(this.logging_domain in Logging.suppressed_domains)) {
|
||||
log_structured(
|
||||
this.logging_flags, LogLevelFlags.LEVEL_DEBUG, fmt, va_list()
|
||||
);
|
||||
log_structured(LEVEL_DEBUG, fmt, va_list());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -208,9 +199,7 @@ public interface Geary.Logging.Source : GLib.Object {
|
|||
*/
|
||||
[PrintfFormat]
|
||||
public inline void message(string fmt, ...) {
|
||||
log_structured(
|
||||
this.logging_flags, LogLevelFlags.LEVEL_MESSAGE, fmt, va_list()
|
||||
);
|
||||
log_structured(LEVEL_MESSAGE, fmt, va_list());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -218,9 +207,7 @@ public interface Geary.Logging.Source : GLib.Object {
|
|||
*/
|
||||
[PrintfFormat]
|
||||
public inline void warning(string fmt, ...) {
|
||||
log_structured(
|
||||
this.logging_flags, LogLevelFlags.LEVEL_WARNING, fmt, va_list()
|
||||
);
|
||||
log_structured(LEVEL_WARNING, fmt, va_list());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -229,9 +216,7 @@ public interface Geary.Logging.Source : GLib.Object {
|
|||
[PrintfFormat]
|
||||
[NoReturn]
|
||||
public inline void error(string fmt, ...) {
|
||||
log_structured(
|
||||
this.logging_flags, LogLevelFlags.LEVEL_ERROR, fmt, va_list()
|
||||
);
|
||||
log_structured(LEVEL_ERROR, fmt, va_list());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -239,40 +224,24 @@ public interface Geary.Logging.Source : GLib.Object {
|
|||
*/
|
||||
[PrintfFormat]
|
||||
public inline void critical(string fmt, ...) {
|
||||
log_structured(
|
||||
this.logging_flags, LogLevelFlags.LEVEL_CRITICAL, fmt, va_list()
|
||||
);
|
||||
log_structured(LEVEL_CRITICAL, fmt, va_list());
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message with this object as context.
|
||||
*/
|
||||
[PrintfFormat]
|
||||
public inline void log(Logging.Flag flags,
|
||||
GLib.LogLevelFlags levels,
|
||||
string fmt, ...) {
|
||||
log_structured(flags, levels, fmt, va_list());
|
||||
}
|
||||
|
||||
private inline void log_structured(Logging.Flag flags,
|
||||
GLib.LogLevelFlags levels,
|
||||
private inline void log_structured(GLib.LogLevelFlags levels,
|
||||
string fmt,
|
||||
va_list args) {
|
||||
if (flags == ALL || Logging.get_flags().is_any_set(flags)) {
|
||||
Context context = Context(
|
||||
this.logging_domain, flags, levels, fmt, args
|
||||
);
|
||||
// Don't attempt to this object if it is in the middle of
|
||||
// being destructed, which can happen when logging from
|
||||
// the destructor.
|
||||
Source? decorated = (this.ref_count > 0) ? this : this.logging_parent;
|
||||
while (decorated != null) {
|
||||
context.append_source(decorated);
|
||||
decorated = decorated.logging_parent;
|
||||
}
|
||||
Context context = Context(this.logging_domain, levels, fmt, args);
|
||||
|
||||
GLib.log_structured_array(levels, context.to_array());
|
||||
// Don't attempt to this object if it is in the middle of
|
||||
// being destructed, which can happen when logging from
|
||||
// the destructor.
|
||||
Source? decorated = (this.ref_count > 0) ? this : this.logging_parent;
|
||||
while (decorated != null) {
|
||||
context.append_source(decorated);
|
||||
decorated = decorated.logging_parent;
|
||||
}
|
||||
|
||||
GLib.log_structured_array(levels, context.to_array());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,10 +159,9 @@ int main(string[] args) {
|
|||
}
|
||||
|
||||
stdout.printf("Enabling debug: %s\n", arg_debug.to_string());
|
||||
Geary.Logging.init();
|
||||
if (arg_debug) {
|
||||
Geary.Logging.init();
|
||||
Geary.Logging.log_to(stdout);
|
||||
Geary.Logging.enable_flags(Geary.Logging.Flag.NETWORK);
|
||||
GLib.Log.set_writer_func(Geary.Logging.default_log_writer);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,9 +40,7 @@ int main(string[] args) {
|
|||
Geary.HTML.init();
|
||||
Geary.Logging.init();
|
||||
if (GLib.Test.verbose()) {
|
||||
Geary.Logging.enable_flags(ALL);
|
||||
GLib.Log.set_writer_func(Geary.Logging.default_log_writer);
|
||||
Geary.Logging.enable_flags(ALL);
|
||||
Geary.Logging.log_to(GLib.stdout);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ int main(string[] args) {
|
|||
Geary.HTML.init();
|
||||
Geary.Logging.init();
|
||||
if (GLib.Test.verbose()) {
|
||||
Geary.Logging.enable_flags(ALL);
|
||||
GLib.Log.set_writer_func(Geary.Logging.default_log_writer);
|
||||
Geary.Logging.enable_flags(ALL);
|
||||
Geary.Logging.log_to(GLib.stdout);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue