generate_log_config 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env python3
  2. # Copyright 2020 The Matrix.org Foundation C.I.C.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import argparse
  16. import sys
  17. from synapse.config.logger import DEFAULT_LOG_CONFIG
  18. if __name__ == "__main__":
  19. parser = argparse.ArgumentParser()
  20. parser.add_argument(
  21. "-o",
  22. "--output-file",
  23. type=argparse.FileType("w"),
  24. default=sys.stdout,
  25. help="File to write the configuration to. Default: stdout",
  26. )
  27. parser.add_argument(
  28. "-f",
  29. "--log-file",
  30. type=str,
  31. default="/var/log/matrix-synapse/homeserver.log",
  32. help="name of the log file",
  33. )
  34. args = parser.parse_args()
  35. out = args.output_file
  36. out.write(DEFAULT_LOG_CONFIG.substitute(log_file=args.log_file))
  37. out.flush()