Mwalker has uploaded a new change for review.
https://gerrit.wikimedia.org/r/90284
Change subject: Allow the Tagged Logger to Alter Context
......................................................................
Allow the Tagged Logger to Alter Context
Because it was silly to have to call the Logger instance when
you had a perfectly good tagged logger around.
Change-Id: I6de8f8362e552a4d1750a2b25c08549848f8a979
---
M Core/Logging/TaggedLogger.php
1 file changed, 44 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/SmashPig
refs/changes/84/90284/1
diff --git a/Core/Logging/TaggedLogger.php b/Core/Logging/TaggedLogger.php
index 7d2293a..64a1b0b 100644
--- a/Core/Logging/TaggedLogger.php
+++ b/Core/Logging/TaggedLogger.php
@@ -18,6 +18,50 @@
$this->tag = $tag;
}
+ /* === CONTEXT HELPER METHODS === */
+ /**
+ * Enters a new context with the current context as its parent.
+ * Shadows @ref LogContextHandler->enterContext()
+ *
+ * @param string $name Child context name
+ */
+ public static function enterContext( $name ) {
+ Logger::$context->enterContext( $name );
+ }
+
+ /**
+ * Renames the current logging context. Effects the log prefix used for
all
+ * events under this context. May have adverse effects on logstreams
that log
+ * in real time (IE: Syslog) because they will have logged items under
the old
+ * context name.
+ *
+ * Shadows @ref LogContextHandler->renameContext()
+ *
+ * @param string $newName New name for the current context
+ * @param bool $addLogEntry If false will not create a log line
stating the name change
+ *
+ * @return string The old name of this context
+ */
+ public static function renameContext( $newName, $addLogEntry = true ) {
+ return Logger::$context->renameContext( $newName, $addLogEntry
);
+ }
+
+ /**
+ * Leaves the current context for the parent context. You may not leave
the root
+ * context.
+ *
+ * Side effects include removing all stored log lines for this context.
Before this
+ * happens all LogStreams have the opportunity to do last chance
processing.
+ *
+ * Shadows @ref LogContextHandler->leaveContext()
+ *
+ * @return string|bool The current context name, or false if this is
the root context
+ */
+ public static function leaveContext() {
+ return Logger::$context->leaveContext();
+ }
+
+ /* === EVENT HANDLING === */
/**
* Log an immediate/critical failure. Will be immediately forwarded to
the designated
* error contact. Use this for things like database failures, top of
PHP error stack
--
To view, visit https://gerrit.wikimedia.org/r/90284
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6de8f8362e552a4d1750a2b25c08549848f8a979
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/SmashPig
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits