The following compiles
with Util.Log.Loggers;
package body LogTest is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create("./abc.log");
...
end LogTest;
The problem is that I need to read in the filename from a configuration file so I tried
package body LogTest is
Log: Util.Log.Loggers.Logger;
procedure LogTestInit(filename : String) is
begin
Log := Util.Log.Loggers.Create(filename);
end LogTestInit;
but it comes up with left hand side of assignment must not be limited type
. Two questions
- What should I do if I wish to pass in the filename? How do I create the log instance.
- Why does the assignment work in the first case but not in the second?
The following compiles
with Util.Log.Loggers;
package body LogTest is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create("./abc.log");
...
end LogTest;
The problem is that I need to read in the filename from a configuration file so I tried
package body LogTest is
Log: Util.Log.Loggers.Logger;
procedure LogTestInit(filename : String) is
begin
Log := Util.Log.Loggers.Create(filename);
end LogTestInit;
but it comes up with left hand side of assignment must not be limited type
. Two questions
- What should I do if I wish to pass in the filename? How do I create the log instance.
- Why does the assignment work in the first case but not in the second?
2 Answers
Reset to default 1Off the top of my head:
- Create a function which by some appropriate means determines the required filename and returns that.
- In the first case, a new
Loggers.Logger
is being initialised with the function result. In the second case, there’s already a limitedLoggers.Logger
, and you’re trying to assign to it.
I've since found that the string passed in
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create("./abc.log");
is not a filename but an identification tag, so it can be a hard coded constant, or, as @simonwright hinted, a function that returns a string. If there are multiple tasks or packages, each can have its own tag. The actual log filename is set in the configuration file that is passed to the Initialize
function.
For C# people, limited means it is not ICloneable.
For C++ people, limited means it is a non-copyable object.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745074557a4609754.html
评论列表(0条)