You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/changelogs/v4.8.0.rst
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,6 +74,8 @@ Model
74
74
Libraries
75
75
=========
76
76
77
+
- **Context**: This new feature allows you to easily set and retrieve normal or hidden contextual data for the current request. See :ref:`Context <context>` for details.
Copy file name to clipboardExpand all lines: user_guide_src/source/general/context.rst
+18-8Lines changed: 18 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,11 @@
1
+
.. _context:
2
+
1
3
###################
2
4
Context
3
5
###################
4
6
7
+
.. versionadded:: 4.8.0
8
+
5
9
.. contents::
6
10
:local:
7
11
:depth: 2
@@ -19,9 +23,9 @@ The Context class is particularly useful for:
19
23
- Adding contextual information to your logs automatically
20
24
- Storing sensitive data that should not appear in logs
21
25
22
-
******************
23
-
Accessing Context
24
-
******************
26
+
***********************
27
+
Accessing Context Class
28
+
***********************
25
29
26
30
You can access the Context service anywhere in your application using the ``service()`` function:
27
31
@@ -123,7 +127,9 @@ To remove all context data:
123
127
Hidden Context Data
124
128
*********************
125
129
126
-
The Context class provides a separate storage area for sensitive data that should not be included in logs. This is useful for storing API keys, passwords, tokens, or other sensitive information that you need to access during the request but don't want to expose in log files.
130
+
The Context class provides a separate storage area for sensitive data that should not be included in logs.
131
+
This is useful for storing API keys, passwords, tokens, or other sensitive information that you need to access
132
+
during the request but don't want to expose in log files.
127
133
128
134
Setting Hidden Data
129
135
===================
@@ -172,18 +178,21 @@ To clear both regular and hidden data:
172
178
173
179
.. literalinclude:: context/022.php
174
180
175
-
.. important:: Regular data and hidden data are stored separately. A key can exist in both regular and hidden storage with different values. Use ``get()`` for regular data and ``getHidden()`` for hidden data.
181
+
.. important:: Regular data and hidden data are stored separately. A key can exist in both regular and hidden storage
182
+
with different values. Use ``get()`` for regular data and ``getHidden()`` for hidden data.
176
183
177
184
***********************************
178
185
Integration with Logging
179
186
***********************************
180
187
181
-
The Context class integrates seamlessly with CodeIgniter's logging system. When enabled, context data is automatically appended to log messages, providing additional information for debugging and monitoring.
188
+
The Context class integrates seamlessly with CodeIgniter's logging system. When enabled, context data is automatically
189
+
appended to log messages, providing additional information for debugging and monitoring.
182
190
183
191
Enabling Global Context Logging
184
192
================================
185
193
186
-
To enable automatic logging of context data, set the ``$logGlobalContext`` property to ``true`` in your **app/Config/Logger.php** file:
194
+
To enable automatic logging of context data, set the ``$logGlobalContext`` property to ``true`` in your
195
+
**app/Config/Logger.php** file:
187
196
188
197
.. literalinclude:: context/023.php
189
198
@@ -197,7 +206,8 @@ This would produce a log entry like:
.. note:: Hidden data set with ``setHidden()`` is **never** included in logs, even when ``$logGlobalContext`` is enabled. This ensures sensitive information like API keys or tokens remain secure.
209
+
.. note:: Hidden data set with ``setHidden()`` is **never** included in logs, even when ``$logGlobalContext`` is enabled.
210
+
This ensures sensitive information like API keys or tokens remain secure.
0 commit comments