Created
September 21, 2022 15:59
-
-
Save neelabalan/a3ea4f7020e114660084fe676815e326 to your computer and use it in GitHub Desktop.
Loguru internal logger object creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from loguru import _Logger | |
from loguru import _Core | |
import ray | |
def create_logger_obj(): | |
return _Logger( | |
core=_Core(), | |
exception=None, | |
depth=0, | |
record=False, | |
lazy=False, | |
colors=False, | |
raw=False, | |
capture=True, | |
patcher=None, | |
extra={}, | |
) | |
@ray.remote | |
class StartUp: | |
def __init__(self): | |
self.logger = create_logger_obj() | |
self.logger.add(f'logs/{__name__}.log', filter=__name__, rotation='1 week') | |
def start(self): | |
for i in range(10): | |
self.logger.info(i) | |
def run(): | |
logger.info("started!") | |
agents = [StartUp.remote() for i in range(4)] | |
result = [] | |
for count , agent in enumerate(agents): | |
logger.info(count) | |
result.append(agent.start.remote()) | |
done_id, _ = ray.wait(result) | |
logger.info("complete!") | |
if __name__ == "__main__": | |
logger = create_logger_obj() | |
logger.add(f'logs/{__name__}.log', filter=__name__, rotation='1 week') | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Delgan/loguru#706