Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DG_PY_FOFBTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DG
DS_DG_PyTango_Package
DG_PY_FOFBTool
Commits
b1c62c00
Commit
b1c62c00
authored
11 months ago
by
BRONES Romain
Browse files
Options
Downloads
Patches
Plain Diff
Add specific log appender
* Its adds the log messages to the log attribute
parent
92d4525a
Branches
Branches containing commit
Tags
1.54.0
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
DG_PY_FOFBTool.py
+13
-17
13 additions, 17 deletions
DG_PY_FOFBTool.py
with
13 additions
and
17 deletions
DG_PY_FOFBTool.py
+
13
−
17
View file @
b1c62c00
...
@@ -29,6 +29,14 @@ import FofbTool.Configuration
...
@@ -29,6 +29,14 @@ import FofbTool.Configuration
import
logging
import
logging
import
numpy
as
np
import
numpy
as
np
class
ds_logappender
(
logging
.
Handler
):
def
__init__
(
self
,
parent
):
self
.
parent
=
parent
logging
.
Handler
.
__init__
(
self
=
self
)
def
emit
(
self
,
record
):
self
.
parent
.
_logs
=
[
record
.
getMessage
(),]
+
self
.
parent
.
_logs
[:
-
1
]
#----- PROTECTED REGION END -----# // DG_PY_FOFBTool.additionnal_import
#----- PROTECTED REGION END -----# // DG_PY_FOFBTool.additionnal_import
__all__
=
[
"
DG_PY_FOFBTool
"
,
"
main
"
]
__all__
=
[
"
DG_PY_FOFBTool
"
,
"
main
"
]
...
@@ -204,18 +212,11 @@ class DG_PY_FOFBTool(Device):
...
@@ -204,18 +212,11 @@ class DG_PY_FOFBTool(Device):
self
.
info_stream
(
"
FofbTool {}
"
.
format
(
FofbTool
.
__version__
))
self
.
info_stream
(
"
FofbTool {}
"
.
format
(
FofbTool
.
__version__
))
logger
=
logging
.
getLogger
(
"
FofbTool
"
)
self
.
_logs
=
[
''
,]
*
logs
.
max_dim_x
try
:
fh
=
logging
.
FileHandler
(
self
.
logfilepath
)
except
FileNotFoundError
:
logger
.
warning
(
"
Not logging to file, could not open location {}
"
.
format
(
self
.
logfilepath
))
else
:
fh
.
setLevel
(
logging
.
DEBUG
)
fh
.
setFormatter
(
logging
.
Formatter
(
"
{asctime} {levelname:8}: {message}
"
,
style
=
'
{
'
))
logger
.
addHandler
(
fh
)
self
.
filehandler
=
fh
logger
=
logging
.
getLogger
(
"
FofbTool
"
)
la
=
ds_logappender
(
self
)
logger
.
addHandler
(
la
)
logger
.
setLevel
(
getattr
(
logging
,
self
.
loglevel
.
upper
()))
logger
.
setLevel
(
getattr
(
logging
,
self
.
loglevel
.
upper
()))
if
not
hasattr
(
self
,
"
_include_lbp
"
):
if
not
hasattr
(
self
,
"
_include_lbp
"
):
...
@@ -270,12 +271,7 @@ class DG_PY_FOFBTool(Device):
...
@@ -270,12 +271,7 @@ class DG_PY_FOFBTool(Device):
def
read_logs
(
self
):
def
read_logs
(
self
):
# PROTECTED REGION ID(DG_PY_FOFBTool.logs_read) ENABLED START #
# PROTECTED REGION ID(DG_PY_FOFBTool.logs_read) ENABLED START #
"""
Return the logs attribute.
"""
"""
Return the logs attribute.
"""
try
:
return
_logs
with
open
(
self
.
logfilepath
,
'
r
'
)
as
fp
:
lines
=
fp
.
readlines
()
return
[
l
.
replace
(
'
\n
'
,
''
)
for
l
in
lines
[:
-
100
:
-
1
]]
except
FileNotFoundError
:
return
[
''
]
# PROTECTED REGION END # // DG_PY_FOFBTool.logs_read
# PROTECTED REGION END # // DG_PY_FOFBTool.logs_read
# --------
# --------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment