You can use LKP_SRC/lib/log.rb directly, instead of re-create a wheel.
-------- Thanks Yu Chuan
On Wed, Jan 20, 2021 at 04:46:21PM +0800, Xiao Shenwei wrote:
format: datetime-severity: message such as: 2021-01-20 16:04:03 +0800-INFO: xxxxxx
Signed-off-by: Xiao Shenwei xiaoshenwei96@163.com
providers/libvirt/lib/mylog.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 providers/libvirt/lib/mylog.rb
diff --git a/providers/libvirt/lib/mylog.rb b/providers/libvirt/lib/mylog.rb new file mode 100644 index 0000000..69061ca --- /dev/null +++ b/providers/libvirt/lib/mylog.rb @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true
+require 'logger'
+# define a logger format +class Mylog < Logger
- def initialize(filename)
- @name = filename
- if FileTest.exist?(filename)
File.delete(filename)
- end
- super(filename)
- self.datetime_format = '%Y-%m-%d %H:%M:%s'
- self.formatter = proc do |severity, datetime, _, msg|
"#{datetime}-#{severity}: #{msg}\n"
- end
- end
+end
2.23.0