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
+# 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
what does this @name for, it seems no anywhere else use it.
Thanks, Luan Shengde
- 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
On Thu, Jan 21, 2021 at 10:23:42AM +0800, Luan Shengde wrote:
+# 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
what does this @name for, it seems no anywhere else use it.
ok, i will del it
Thanks, Shenwei
Thanks, Luan Shengde
- 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
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
On Thu, Jan 21, 2021 at 10:27:04AM +0800, Yu Chuan wrote:
You can use LKP_SRC/lib/log.rb directly, instead of re-create a wheel.
got it,
Thanks, Shenwei
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
On Thu, Jan 21, 2021 at 10:27:04AM +0800, Yu Chuan wrote:
You can use LKP_SRC/lib/log.rb directly, instead of re-create a wheel.
good
Thanks, Shenwei
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
- self.formatter = proc do |severity, datetime, _, msg|
Does _ mean a meaningless var? If so, you can refer the follow to make it more code-friendly? log_formatter = proc do |severity, datetime, _progname, msg|
-------- Thanks Yu Chuan
"#{datetime}-#{severity}: #{msg}\n"
- end
- end
+end
2.23.0
On Thu, Jan 21, 2021 at 04:21:59PM +0800, Yu Chuan wrote:
- self.formatter = proc do |severity, datetime, _, msg|
Does _ mean a meaningless var? If so, you can refer the follow to make it more code-friendly? log_formatter = proc do |severity, datetime, _progname, msg|
good!
Thanks, Shenwei
Thanks Yu Chuan
"#{datetime}-#{severity}: #{msg}\n"
- end
- end
+end
2.23.0