2 years ago
I heard when railway deploys a project after a git commit to the main branch, it's supposed to remove the previous deployment after it finishes, but when it's a python script (discord bot) it doesn't do that (the attached image is from using a template)
When using
logging.getLogger().info("message"), railway flags it as an error in logs, but when usingprint("message")(not recommended to use) it's a normal log. Is there a way to fix this?
0 Replies
2 years ago
old deployments will be removed, refresh.
logs are red when logging to stderr, print() prints to stdout, i would highly recommend looking into JSON logging as railway has amazing support for it.
2 years ago
the overlap is there as a default for websites/APIs to mitigate downtime, for discord bots that irrelevant, so you can disable the overlap by setting a service variable RAILWAY_DEPLOYMENT_OVERLAP_SECONDS to 0
in case anyone else searches for this, there's a nice python library named structlog that can give you json logging functionality built in:
import structlog
structlog.configure(
processors=[
structlog.processors.add_log_level, # adds {"level" = "info"}
structlog.processors.EventRenamer("message"), # renames {"event": "hello"} to {"message": "hello"}
structlog.processors.JSONRenderer(), # outputs as json
]
)
logger: structlog.stdlib.BoundLogger = structlog.get_logger()
logger.debug("hello", key="value?")
logger.info("hi", key="value.")
logger.warn("hey :(", key="value!")
logger.error("oh no", key="value!!!")output:

2 years ago
awsome, thanks for coming back with that info!!
2 years ago
thanks for this
