@@ -31,6 +31,14 @@ component accessors="true" {
3131 */
3232 property name = " levelMax" ;
3333
34+ /**
35+ * Flag to allow serializing complex objects in `extraInfo`.
36+ */
37+ property
38+ name = " serializeExtraInfo"
39+ type = " boolean"
40+ default = " true" ;
41+
3442 // The log levels enum as a public property
3543 this .logLevels = new coldbox .system .logging .LogLevels ();
3644
@@ -41,17 +49,20 @@ component accessors="true" {
4149 * @levelMin The default log level for this appender, by default it is 0. Optional. ex: LogBox.logLevels.WARN
4250 * @levelMax The default log level for this appender, by default it is 0. Optional. ex: LogBox.logLevels.WARN
4351 * @appenders A struct of already created appenders for this category, or blank to use the root logger.
52+ * @serial izeExtraInfo Flag to allow serializing complex objects in `extraInfo`. Default is true.
4453 */
4554 function init (
4655 required category ,
4756 numeric levelMin = 0 ,
4857 numeric levelMax = 4 ,
49- struct appenders = {}
58+ struct appenders = {},
59+ boolean serializeExtraInfo = true
5060 ){
5161 // Save Properties
5262 variables .rootLogger = " " ;
5363 variables .category = arguments .category ;
5464 variables .appenders = arguments .appenders ;
65+ variables .serializeExtraInfo = arguments .serializeExtraInfo ;
5566
5667 // Logger Logging Level defaults, which is wideeeee open!
5768 variables .levelMin = arguments .levelMin ;
@@ -61,7 +72,6 @@ component accessors="true" {
6172 variables ._hash = createUUID ();
6273 variables .util = new coldbox .system .core .util .Util ();
6374
64-
6575 // Local Locking
6676 variables .lockName = variables ._hash & " LoggerOperation" ;
6777 variables .lockTimeout = 20 ;
@@ -320,11 +330,13 @@ component accessors="true" {
320330 * @message A message to log or a closure that returns a message to log
321331 * @severity The severity level to log, if invalid, it will default to **Info**
322332 * @extraInfo Extra information to send to appenders
333+ * @serial izeExtraInfo Flag to allow serializing complex objects in `extraInfo`. Default is the logger's setting.
323334 */
324335 Logger function logMessage (
325336 required message ,
326337 required severity ,
327- extraInfo = " "
338+ extraInfo = " " ,
339+ boolean serializeExtraInfo = variables .serializeExtraInfo
328340 ){
329341 var target = this ;
330342
@@ -381,17 +393,20 @@ component accessors="true" {
381393 message = " #arguments .message #"
382394 severity = " #arguments .severity #"
383395 extraInfo = " #arguments .extraInfo #"
384- category = " #arguments .category #" {
396+ category = " #arguments .category #"
397+ serializeExtraInfo = " #arguments .serializeExtraInfo #"
398+ {
385399 var target = this ;
386400 if ( ! hasAppenders () ) {
387401 target = getRootLogger ();
388402 }
389403 var this Appender = target .getAppender ( attributes .appenderName );
390404 thread .logEvent = new coldbox .system .logging .LogEvent (
391- message = attributes .message ,
392- severity = attributes .severity ,
393- extraInfo = attributes .extraInfo ,
394- category = attributes .category
405+ message : attributes .message ,
406+ severity : attributes .severity ,
407+ extraInfo : attributes .extraInfo ,
408+ category : attributes .category ,
409+ serializeExtraInfo : attributes .serializeExtraInfo
395410 );
396411 this Appender .logMessage ( thread .logEvent );
397412 }
0 commit comments