Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-sims
csst_mci_sim
Commits
4350f0cb
Commit
4350f0cb
authored
Oct 25, 2024
by
Yan Zhaojun
Browse files
Delete logger.py
parent
309a7037
Pipeline
#7073
failed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
csst_mci_sim/support/logger.py
deleted
100644 → 0
View file @
309a7037
"""
These functions can be used for logging information.
.. Warning:: logger is not multiprocessing safe.
:version: 0.3
"""
import
logging
import
logging.handlers
def
setUpLogger
(
log_filename
,
loggername
=
'logger'
):
"""
Sets up a logger.
:param: log_filename: name of the file to save the log.
:param: loggername: name of the logger
:return: logger instance
"""
# create logger
logger
=
logging
.
getLogger
(
loggername
)
logger
.
setLevel
(
logging
.
DEBUG
)
# Add the log message handler to the logger
handler
=
logging
.
handlers
.
RotatingFileHandler
(
log_filename
)
#maxBytes=20, backupCount=5)
# create formatter
formatter
=
logging
.
Formatter
(
'%(asctime)s - %(module)s - %(funcName)s - %(levelname)s - %(message)s'
)
# add formatter to ch
handler
.
setFormatter
(
formatter
)
# add handler to logger
if
(
logger
.
hasHandlers
()):
logger
.
handlers
.
clear
()
logger
.
addHandler
(
handler
)
return
logger
# class SimpleLogger(object):
# """
# A simple class to create a log file or print the information on screen.
# """
# def __init__(self, filename, verbose=False):
# self.file = open(filename, 'w')
# self.verbose = verbose
# def write(self, text):
# """
# Writes text either to file or screen.
# """
# print >> self.file, text
# if self.verbose: print( text)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment