Skip to content

Commit

Permalink
set default log path to /var/log/tedge (#2480)
Browse files Browse the repository at this point in the history
Signed-off-by: Pradeep Kumar K J <pkj@softwareag.com>
  • Loading branch information
PradeepKiruvale authored Nov 27, 2023
1 parent 6a0a834 commit fcc552b
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions configuration/init/initd/tedge
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ user="tedge"
name=$(basename $0)
pid_file="/var/run/$name.pid"

# Default location for logging assumed to be /var/log.
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
# Default location for logging assumed to be /var/log/tedge.
stdout_log="/var/log/tedge/$name.log"
stderr_log="/var/log/tedge/$name.err"

get_pid() {
cat "$pid_file"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ define_tedge_config! {

logs: {
/// The directory used to store logs
#[tedge_config(example = "/var/log", default(value = "/var/log"))]
#[tedge_config(example = "/var/log/tedge", default(value = "/var/log/tedge"))]
#[doku(as = "PathBuf")]
path: Utf8PathBuf,
},
Expand Down
2 changes: 1 addition & 1 deletion crates/core/tedge/src/cli/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl TEdgeInitCmd {
let config = self.context.config_repository.load()?;

create_directory(
config.logs.path.join("tedge"),
config.logs.path.clone(),
PermissionEntry::new(
Some(self.user.clone()),
Some(self.group.clone()),
Expand Down
2 changes: 1 addition & 1 deletion crates/core/tedge_agent/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl AgentConfig {
let use_lock = tedge_config.run.lock_files;

// For agent specific
let log_dir = tedge_config.logs.path.join("tedge").join("agent");
let log_dir = tedge_config.logs.path.join("agent");
let operations_dir = config_dir.join("operations");

let identity = tedge_config.http.client.auth.identity()?;
Expand Down
2 changes: 1 addition & 1 deletion crates/core/tedge_agent/src/software_manager/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl SoftwareManagerConfig {

let tmp_dir = &tedge_config.tmp.path;
let sm_plugins_dir = config_dir.join("sm-plugins");
let log_dir = tedge_config.logs.path.join("tedge").join("agent");
let log_dir = tedge_config.logs.path.join("agent");
let default_plugin_type = tedge_config
.software
.plugin
Expand Down
2 changes: 1 addition & 1 deletion crates/extensions/c8y_log_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl LogManagerBuilder {
create_directory_with_defaults(&config.plugin_config_dir)?;

// creating c8y-log-plugin.toml
let logs_path = format!("{}/tedge/agent/software-*", config.log_dir.display());
let logs_path = format!("{}/agent/software-*", config.log_dir.display());
let data = format!(
r#"files = [
{{ type = "software-management", path = "{logs_path}" }},
Expand Down
2 changes: 1 addition & 1 deletion crates/extensions/c8y_mapper_ext/src/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const C8Y_CLOUD: &str = "c8y";
const SUPPORTED_OPERATIONS_DIRECTORY: &str = "operations";
const INTERNAL_ALARMS_TOPIC: &str = "c8y-internal/alarms/";
const C8Y_JSON_MQTT_EVENTS_TOPIC: &str = "c8y/event/events/create";
const TEDGE_AGENT_LOG_DIR: &str = "tedge/agent";
const TEDGE_AGENT_LOG_DIR: &str = "agent";
const CREATE_EVENT_SMARTREST_CODE: u16 = 400;
const DEFAULT_EVENT_TYPE: &str = "ThinEdgeEvent";
const FORBIDDEN_ID_CHARS: [char; 3] = ['/', '+', '#'];
Expand Down
2 changes: 1 addition & 1 deletion crates/extensions/c8y_mapper_ext/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2475,7 +2475,7 @@ async fn c8y_mapper_nested_child_service_event_mapping_to_smartrest() {
}

fn assert_command_exec_log_content(cfg_dir: TempTedgeDir, expected_contents: &str) {
let paths = fs::read_dir(cfg_dir.to_path_buf().join("tedge/agent")).unwrap();
let paths = fs::read_dir(cfg_dir.to_path_buf().join("agent")).unwrap();
for path in paths {
let mut file =
File::open(path.unwrap().path()).expect("Unable to open the command exec log file");
Expand Down
2 changes: 1 addition & 1 deletion docs/src/operate/configuration/update_config_paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The following table captures the paths that can be changed, with their default l
| Config Key | Description | Default Value |
|------------|-------------|---------------|
| tmp.path | Directory where temporary files are created/stored. E.g: while downloading files | `/tmp` |
| logs.path | Directory where log files are created | `/var/log` |
| logs.path | Directory where log files are created | `/var/log/tedge` |
| run.path | Directory where runtime information are stored | `/run` |
| data.path | Directory where data files are stored. E.g: Cached binary files, operation metadata etc | `/var/tedge` |

Expand Down
4 changes: 2 additions & 2 deletions tests/RobotFramework/tests/customizing/log_path_config.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Suite Setup Custom Setup
Suite Teardown Custom Teardown

*** Test Cases ***
Validate updated data path used by tedge-agent
Validate updated log path used by tedge-agent
Execute Command sudo tedge config set logs.path /var/test
Restart Service tedge-agent
Directory Should Exist /var/test/tedge/agent
Directory Should Exist /var/test/agent

*** Keywords ***
Custom Setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ set/unset logs.path
# Undo the change by using the 'unset' command, value returns to default one
Execute Command sudo tedge config unset logs.path
${unset} Execute Command tedge config list
Should Contain ${unset} logs.path=/var/log
Should Contain ${unset} logs.path=/var/log/tedge

set/unset run.path
Execute Command sudo tedge config set run.path /run1 # Changing run.path
Expand Down

1 comment on commit fcc552b

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
378 1 3 379 99.74 58m13.482s

Failed Tests

Name Message ⏱️ Duration Suite
Nested child device service support sending simple measurements Expected total device services count to be greater than or equal to 1 32.858 s Child Device Telemetry

Please sign in to comment.