File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
tests/TestCase/Model/Table Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -100,12 +100,20 @@ public function searchManager() {
100100 public function log ($ level , $ message , array $ context = []) {
101101 $ message = trim ($ message );
102102 $ summary = Text::truncate ($ message , 255 );
103+ $ context = trim (print_r ($ context , true ));
104+
105+ if (mb_strlen ($ message ) > 65535 ) {
106+ $ message = mb_substr ($ message , 0 , 65535 );
107+ }
108+ if (mb_strlen ($ context ) > 65535 ) {
109+ $ context = mb_substr ($ context , 0 , 65535 );
110+ }
103111
104112 $ data = [
105113 'type ' => $ level ,
106114 'summary ' => $ summary ,
107115 'message ' => $ message ,
108- 'context ' => trim ( print_r ( $ context, true )) ,
116+ 'context ' => $ context ,
109117 'count ' => 1 ,
110118 ];
111119 $ log = $ this ->newEntity ($ data );
Original file line number Diff line number Diff line change @@ -62,6 +62,28 @@ public function testSave() {
6262 $ this ->assertTrue ($ log ->isCli ());
6363 }
6464
65+ /**
66+ * @return void
67+ */
68+ public function testSaveHugeText () {
69+ $ string = $ this ->string (66000 );
70+ $ result = $ this ->Logs ->log (LOG_INFO , $ string , [$ string ]);
71+ $ this ->assertTrue ($ result );
72+ }
73+
74+ /**
75+ * @param int $length
76+ * @return string
77+ */
78+ protected function string (int $ length ): string {
79+ $ string = '' ;
80+ for ($ i = 0 ; $ i < $ length ; $ i ++) {
81+ $ string .= 'X ' ;
82+ }
83+
84+ return $ string ;
85+ }
86+
6587 /**
6688 * @return void
6789 */
You can’t perform that action at this time.
0 commit comments