Dielee / volvo2mqtt

Home Assistant addon for connecting AAOS Volvos
MIT License
162 stars 38 forks source link

Move log file(s) to log-directory? #168

Closed jsassner closed 9 months ago

jsassner commented 10 months ago

I'm on v1.8.27, running it in docker not connected to HA (i run OpenHab). I want to have linux rsyslog read the log file and notify my syslog server with errors, and today i do that by binding the volvo2mqtt.log log file that resides in the main directory. That log file just wrapped around (> 100kb in size) and i ran into docker issues mapping that 2nd file. Any chance you can move the log file to a local directory (like "log" in the main directory) i can bind to instead of binding to the file?

Rustymage commented 10 months ago

Permission issue with the bind mount?

jsassner commented 10 months ago

I'd rather avoid:

volumes:
  - type: bind
    source: ./logs/volvo2mqtt.log
    target: /volvoAAOS2mqtt/volvo2mqtt.log
  - type: bind
    source: ./logs/volvo2mqtt.log.1
    target: /volvoAAOS2mqtt/volvo2mqtt.log.1
  - type: bind
    source: ./logs/volvo2mqtt.log.2
    target: /volvoAAOS2mqtt/volvo2mqtt.log.2
  - type: bind
    source: ./logs/volvo2mqtt.log.3
    target: /volvoAAOS2mqtt/volvo2mqtt.log.3

....

Rustymage commented 10 months ago

is it a permissions issue with access to the directory you've mapped volvo2mqtt.log too?

jsassner commented 10 months ago

No, logging to volvo2mqtt.log works. It was some time since i got the error, so can't remember exactly what error i got. But it was when volvo2mqtt.log was full (100k) and was gonna be moved to volvo2mqtt.log.1 and a new volvo2mqtt.log created. So then i thought: "why do i have to map each file, can't they be put in a log directory instead?"

Rustymage commented 10 months ago

can the docker container create a new file or does it not have write permissions?

what does your docker-compose.yml look?

jsassner commented 9 months ago
  - type: bind
    source: ./logs/volvo2mqtt.log
    target: /volvoAAOS2mqtt/volvo2mqtt.log
  - type: bind
    source: ./logs/volvo2mqtt.log.1
    target: /volvoAAOS2mqtt/volvo2mqtt.log.1
  - type: bind
    source: ./logs/volvo2mqtt.log.2
    target: /volvoAAOS2mqtt/volvo2mqtt.log.2
  - type: bind
    source: ./logs/volvo2mqtt.log.3
    target: /volvoAAOS2mqtt/volvo2mqtt.log.3

But i'd rather have this:

volumes:
  - type: bind
    source: ./logs/
    target: /volvoAAOS2mqtt/logs/

i.e. i don't want to single-bind a log file. This ticket isn't about write permission, it's about log dir structure.

Rustymage commented 9 months ago

Looks like if you run this as a Home Assistant addon you do get the log in /logs

https://github.com/Dielee/volvo2mqtt/blob/907440b81e8e2ba54dd11426b7328dd1070701c7/src/util.py#L44

I'm not sure why ypu can't just do?

 - type: bind
    source: ./logs/volvo2mqtt.log
    target: /volvoAAOS2mqtt/
jsassner commented 9 months ago

I do not run HomeAssistant (see first post).

Never bound a container file to a host directory. But no matter if it works or not, it will still force me to bind each and every log file in the docker-compose file.

Rustymage commented 9 months ago

Never bound a container file to a host directory. But no matter if it works or not, it will still force me to bind each and every log file in the docker-compose file.

I'm not sure why it would require you to create every file if the container had the correct host permissions but I don't feel that I have anything else to add.

Good luck.

Dielee commented 9 months ago

Please bind every single file. It will work and you don't even need five versions from the log, in my opinion.