Skip to content

Commit 7bdfdff

Browse files
committed
also include logging.yaml files for s3worker and webapp
1 parent 8c0bac9 commit 7bdfdff

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

logs/s3worker_logging.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package logs
2+
3+
const S3WORKER_LOGGING = `version: 1
4+
disable_existing_loggers: false
5+
6+
formatters:
7+
verbose:
8+
format: '%(levelname)s %(asctime)s %(module)s %(message)s'
9+
10+
handlers:
11+
console:
12+
class: logging.StreamHandler
13+
formatter: verbose
14+
15+
loggers:
16+
celery:
17+
level: DEBUG
18+
handlers: [console]
19+
s3worker:
20+
level: DEBUG
21+
handlers: [console]
22+
propagate: no
23+
`

logs/webapp_logging.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package logs
2+
3+
const WEBAPP_LOGGING = `version: 1
4+
disable_existing_loggers: false
5+
6+
formatters:
7+
verbose:
8+
format: '%(levelname)s %(asctime)s %(module)s %(message)s'
9+
10+
handlers:
11+
console:
12+
class: logging.StreamHandler
13+
formatter: verbose
14+
15+
loggers:
16+
papermerge.core.tasks:
17+
level: DEBUG
18+
handlers: [console]
19+
propagate: no
20+
`

pmcompose.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"text/template"
77

88
"github.com/papermerge/pmcompose/ask"
9+
"github.com/papermerge/pmcompose/logs"
910
"github.com/papermerge/pmcompose/utils"
1011
)
1112

@@ -100,4 +101,17 @@ func main() {
100101
}
101102

102103
fmt.Println("✅ docker-compose.yml generated successfully.")
104+
105+
err = os.WriteFile("webapp_logging.yaml", []byte(logs.WEBAPP_LOGGING), 0644)
106+
if err != nil {
107+
fmt.Println("Error writing webapp_logging.yaml file")
108+
}
109+
110+
if cfg.S3StorageBackend.S3BucketName != "" {
111+
err = os.WriteFile("s3worker_logging.yaml", []byte(logs.S3WORKER_LOGGING), 0644)
112+
if err != nil {
113+
fmt.Println("Error writing s3worker_logging.yaml file")
114+
}
115+
}
116+
103117
}

pmcompose_templates/docker-compose.yaml.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ services:
88
PAPERMERGE__DATABASE__URL: postgresql://coco:jumbo@db:5432/pmgdb
99
PAPERMERGE__REDIS__URL: redis://redis:6379/0
1010
PAPERMERGE__MAIN__MEDIA_ROOT: /var/media/pmg
11+
PAPERMERGE__MAIN__LOGGING_CFG: /etc/papermerge/logging.yaml
1112
ports:
1213
- "{{ .WebAppPort }}:80"
1314
depends_on:
1415
- db
1516
- redis
1617
volumes:
1718
- media_root:/var/media/pmg
19+
- ${PWD}/webapp_logging.yaml:/etc/papermerge/logging.yaml
1820
path_template_worker:
1921
image: papermerge/path-tmpl-worker:0.4
2022
command: worker
@@ -34,6 +36,7 @@ services:
3436
PAPERMERGE__REDIS__URL: redis://redis:6379/0
3537
PAPERMERGE__MAIN__MEDIA_ROOT: /var/media/pmg
3638
PAPERMERGE__S3__BUCKET_NAME: {{ .S3StorageBackend.S3BucketName }}
39+
PAPERMERGE__MAIN__LOGGING_CFG: /etc/papermerge/logging.yaml
3740
S3_WORKER_ARGS: "-Q s3 -c 2"
3841
AWS_REGION_NAME: {{ .S3StorageBackend.AWSRegionName }}
3942
AWS_ACCESS_KEY_ID: {{ .S3StorageBackend.AWSAccessKeyID }}
@@ -43,6 +46,7 @@ services:
4346
- redis
4447
volumes:
4548
- media_root:/var/media/pmg
49+
- ${PWD}/s3worker_logging.yaml:/etc/papermerge/logging.yaml
4650
{{- end }}
4751
db:
4852
image: postgres:16.1

0 commit comments

Comments
 (0)