{"id":22930876,"url":"https://github.com/zewebdev1337/logln","last_synced_at":"2025-10-26T17:16:29.911Z","repository":{"id":257823238,"uuid":"871042197","full_name":"zewebdev1337/logln","owner":"zewebdev1337","description":"Simple Go package for logging messages to a file and console with different log levels.","archived":false,"fork":false,"pushed_at":"2024-10-19T16:29:39.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T17:24:56.328Z","etag":null,"topics":["go","golang","golang-library","golang-package","logging","logging-library"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zewebdev1337.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-11T06:46:35.000Z","updated_at":"2024-10-19T16:29:43.000Z","dependencies_parsed_at":"2025-04-01T17:22:38.777Z","dependency_job_id":"0cbea386-702e-4537-a265-da13b13d0d3b","html_url":"https://github.com/zewebdev1337/logln","commit_stats":null,"previous_names":["zewebdev1337/logln"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/zewebdev1337/logln","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zewebdev1337%2Flogln","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zewebdev1337%2Flogln/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zewebdev1337%2Flogln/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zewebdev1337%2Flogln/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zewebdev1337","download_url":"https://codeload.github.com/zewebdev1337/logln/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zewebdev1337%2Flogln/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281139296,"owners_count":26450196,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","golang-library","golang-package","logging","logging-library"],"created_at":"2024-12-14T10:30:31.152Z","updated_at":"2025-10-26T17:16:29.882Z","avatar_url":"https://github.com/zewebdev1337.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# logln\n\nA simple Go package for logging messages to a file and console with different log levels.\n\n## Installation\n\n```\ngo get github.com/zewebdev1337/logln\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/zewebdev1337/logln\"\n)\n\nfunc main() {\n\t// Initialize the log file\n\tlogln.Init()\n\tdefer logln.Close()\n\n\t// Log an info message\n\tlogln.Logln(\"This is an info message\", 0, false)\n\t// Output: 2006/01/02 15:04:05 INFO This is an info message\n\n\t// Log a warning message\n\tlogln.Logln(\"This is a warning message\", 1, false)\n\t// Output: 2006/01/02 15:04:05 WARNING This is a warning message\n\n\t// Log a debug message\n\tlogln.Logln(\"This is a debug message\", 5, false)\n\t// Output: 2006/01/02 15:04:05 DEBUG This is a debug message\n\n\t// Log a debug message (to file only)\n\tlogln.Logln(\"This is a debug message\", 5, true)\n\t// Output: 2006/01/02 15:04:05 DEBUG This is a debug message\n\n\t// Log an warning if the condition is false\n\tlogln.PrintErrorOrSuccessIfNotOk(ok, \"something is not ok\", 0, false)\n\t// Output: 2006/01/02 15:04:05 WARNING something is not ok.\n\n\t// Log an error if the condition is false\n\tlogln.PrintErrorOrSuccessIfNotOk(ok, \"something is not ok\", 0, false)\n\t// Output: 2006/01/02 15:04:05 ERROR An error ocurred: something is not ok.\n\n\t// Log a fatal error if the condition is false and exit\n\tlogln.PrintFatalOrSuccessIfNotOk(ok, \"something is fatally not ok\", 0, false)\n\t// Output: 2006/01/02 15:04:05 FATAL Fatal error encountered: something is fatally not ok.\n\n\t// Log a panic if the condition is false and panic\n\tlogln.PrintPanicOrSuccessIfNotOk(ok, \"something is not ok\", 0, false)\n\t// Output: 2006/01/02 15:04:05 FATAL Panic: something is not ok.\n\n\t// Log an error if the error is not nil\n\terr := fmt.Errorf(\"this is an error\")\n\tlogln.PrintErrorOrSuccess(\"trying to do something\", err, 0, false)\n\t// Output: 2006/01/02 15:04:05 ERROR An error occurred trying to do something: this is an error.\n\n\tlogln.PrintWarningOrSuccess(\"this error triggered this warning\", err, 0, false)\n\t// Output: 2006/01/02 15:04:05 WARNING this error triggered this warning: this is an error.\n\n\t// Log a fatal error if the error is not nil and exit\n\tlogln.PrintFatalOrSuccess(\"reading essential data\", err, 0, false)\n\t// Output: 2006/01/02 15:04:05 FATAL A fatal error encountered reading essential data: this is an error.\n\n\t// Log a panic if the error is not nil and panic\n\tlogln.PrintPanicOrSuccess(\"expecting something different\", err, 0, false)\n\t// Output: 2006/01/02 15:04:05 FATAL Panic expecting something different: this is an error.\n\n\t// Log a success if the error is nil\n\terr := nil\n\tlogln.PrintErrorOrSuccess(\"trying to do something\", err, 5, false)\n\t// Output: 2006/01/02 15:04:05 DEBUG Success trying to do something.\n}\n```\n\n## Log Levels\n\nThe following log levels are available:\n\n- `0`: INFO\n- `1`: WARNING\n- `2`: ERROR\n- `3`: FATAL\n- `4`: PANIC\n- `5`: DEBUG\n\n## Functions\n\n### `Init()`\n\nInitializes the log file.\n\n### `Close()`\n\nCloses the log file.\n\n### `Logln(line string, level int, isSilent bool)`\n\nLogs a message with the given level and message.\n\n- `line`: The message to log.\n- `level`: The log level.\n- `isSilent`: Whether to suppress the message from the console output.\n\n### `Printf(text string, level int, isSilent bool)`\n\nLogs a message without appending a newline.\n\n- `text`: The message to log.\n- `level`: The log level.\n- `isSilent`: Whether to suppress the message from the console output.\n\n### `ManualLogf(text string, level int, isSilent bool)`\n\nLogs a message without appending a newline and without the date and time prefix.\n\n- `text`: The message to log.\n- `level`: The log level.\n- `isSilent`: Whether to suppress the message from the console output.\n\n### `PrintErrorOrSuccessIfNotOk(ok bool, msg string, successLevel int, isSuccessSilent bool)`\n\nLogs an error message if `ok` is false, otherwise logs a success message.\n\n- `ok`: The condition to check.\n- `msg`: The message to log.\n- `successLevel`: The log level for the success message.\n- `isSuccessSilent`: Whether to suppress the success message from the console output.\n\n### `PrintFatalOrSuccessIfNotOk(ok bool, msg string, successLevel int, isSuccessSilent bool)`\n\nLogs a fatal error message if `ok` is false and exits, otherwise logs a success message.\n\n- `ok`: The condition to check.\n- `msg`: The message to log.\n- `successLevel`: The log level for the success message.\n- `isSuccessSilent`: Whether to suppress the success message from the console output.\n\n### `PrintPanicOrSuccessIfNotOk(ok bool, msg string, successLevel int, isSuccessSilent bool)`\n\nLogs a panic message if `ok` is false and panics, otherwise logs a success message.\n\n- `ok`: The condition to check.\n- `msg`: The message to log.\n- `successLevel`: The log level for the success message.\n- `isSuccessSilent`: Whether to suppress the success message from the console output.\n\n### `PrintErrorOrSuccess(msg string, err error, successLevel int, isSuccessSilent bool)`\n\nLogs an error message if `err` is not nil, otherwise logs a success message.\n\n- `msg`: The message to log.\n- `err`: The error to check.\n- `successLevel`: The log level for the success message.\n- `isSuccessSilent`: Whether to suppress the success message from the console output.\n\n### `PrintFatalOrSuccess(msg string, err error, successLevel int, isSuccessSilent bool)`\n\nLogs a fatal error message if `err` is not nil and exits, otherwise logs a success message.\n\n- `msg`: The message to log.\n- `err`: The error to check.\n- `successLevel`: The log level for the success message.\n- `isSuccessSilent`: Whether to suppress the success message from the console output.\n\n### `PrintPanicOrSuccess(msg string, err error, successLevel int, isSuccessSilent bool)`\n\nLogs a panic message if `err` is not nil and panics, otherwise logs a success message.\n\n- `msg`: The message to log.\n- `err`: The error to check.\n- `successLevel`: The log level for the success message.\n- `isSuccessSilent`: Whether to suppress the success message from the console output.\n\n## License\n\nThis package is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzewebdev1337%2Flogln","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzewebdev1337%2Flogln","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzewebdev1337%2Flogln/lists"}