242 yield entry |
242 yield entry |
243 |
243 |
244 |
244 |
245 /* properties (YXML) */ |
245 /* properties (YXML) */ |
246 |
246 |
247 val xml_cache: XML.Cache = XML.make_cache() |
247 val xml_cache: XML.Cache = XML.Cache.make() |
248 |
248 |
249 def parse_props(text: String): Properties.T = |
249 def parse_props(text: String): Properties.T = |
250 try { xml_cache.props(XML.Decode.properties(YXML.parse_body(text))) } |
250 try { xml_cache.props(XML.Decode.properties(YXML.parse_body(text))) } |
251 catch { case _: XML.Error => log_file.err("malformed properties") } |
251 catch { case _: XML.Error => log_file.err("malformed properties") } |
252 |
252 |
646 task_statistics = |
646 task_statistics = |
647 if (task_statistics) log_file.filter_props(Protocol.Task_Statistics_Marker) else Nil, |
647 if (task_statistics) log_file.filter_props(Protocol.Task_Statistics_Marker) else Nil, |
648 errors = log_file.filter(Protocol.Error_Message_Marker)) |
648 errors = log_file.filter(Protocol.Error_Message_Marker)) |
649 } |
649 } |
650 |
650 |
651 def compress_errors(errors: List[String], cache: XZ.Cache = XZ.cache()): Option[Bytes] = |
651 def compress_errors(errors: List[String], cache: XZ.Cache = XZ.Cache()): Option[Bytes] = |
652 if (errors.isEmpty) None |
652 if (errors.isEmpty) None |
653 else { |
653 else { |
654 Some(Bytes(YXML.string_of_body(XML.Encode.list(XML.Encode.string)(errors))). |
654 Some(Bytes(YXML.string_of_body(XML.Encode.list(XML.Encode.string)(errors))). |
655 compress(cache = cache)) |
655 compress(cache = cache)) |
656 } |
656 } |
657 |
657 |
658 def uncompress_errors(bytes: Bytes, cache: XZ.Cache = XZ.cache()): List[String] = |
658 def uncompress_errors(bytes: Bytes, cache: XZ.Cache = XZ.Cache()): List[String] = |
659 if (bytes.is_empty) Nil |
659 if (bytes.is_empty) Nil |
660 else { |
660 else { |
661 XML.Decode.list(YXML.string_of_body)(YXML.parse_body(bytes.uncompress(cache = cache).text)) |
661 XML.Decode.list(YXML.string_of_body)(YXML.parse_body(bytes.uncompress(cache = cache).text)) |
662 } |
662 } |
663 |
663 |
848 } |
848 } |
849 |
849 |
850 |
850 |
851 /* database access */ |
851 /* database access */ |
852 |
852 |
853 def store(options: Options): Store = new Store(options) |
853 def store(options: Options, |
854 |
854 xml_cache: XML.Cache = XML.Cache.make(), |
855 class Store private[Build_Log](options: Options) |
855 xz_cache: XZ.Cache = XZ.Cache.make()): Store = |
856 { |
856 new Store(options, xml_cache, xz_cache) |
857 val xml_cache: XML.Cache = XML.make_cache() |
857 |
858 val xz_cache: XZ.Cache = XZ.make_cache() |
858 class Store private[Build_Log]( |
859 |
859 options: Options, |
|
860 val xml_cache: XML.Cache, |
|
861 val xz_cache: XZ.Cache) |
|
862 { |
860 def open_database( |
863 def open_database( |
861 user: String = options.string("build_log_database_user"), |
864 user: String = options.string("build_log_database_user"), |
862 password: String = options.string("build_log_database_password"), |
865 password: String = options.string("build_log_database_password"), |
863 database: String = options.string("build_log_database_name"), |
866 database: String = options.string("build_log_database_name"), |
864 host: String = options.string("build_log_database_host"), |
867 host: String = options.string("build_log_database_host"), |
1162 status = res.get_string(Data.status).map(Session_Status.withName), |
1165 status = res.get_string(Data.status).map(Session_Status.withName), |
1163 errors = uncompress_errors(res.bytes(Data.errors), cache = xz_cache), |
1166 errors = uncompress_errors(res.bytes(Data.errors), cache = xz_cache), |
1164 ml_statistics = |
1167 ml_statistics = |
1165 if (ml_statistics) { |
1168 if (ml_statistics) { |
1166 Properties.uncompress( |
1169 Properties.uncompress( |
1167 res.bytes(Data.ml_statistics), cache = xz_cache, Some(xml_cache)) |
1170 res.bytes(Data.ml_statistics), cache = xz_cache, xml_cache = xml_cache) |
1168 } |
1171 } |
1169 else Nil) |
1172 else Nil) |
1170 session_name -> session_entry |
1173 session_name -> session_entry |
1171 }).toMap |
1174 }).toMap |
1172 }) |
1175 }) |